|
25 | 25 | import io.serverlessworkflow.api.datainputschema.DataInputSchema; |
26 | 26 | import io.serverlessworkflow.api.defaultdef.DefaultConditionDefinition; |
27 | 27 | import io.serverlessworkflow.api.end.End; |
| 28 | +import io.serverlessworkflow.api.events.EventRef; |
28 | 29 | import io.serverlessworkflow.api.functions.FunctionDefinition; |
29 | 30 | import io.serverlessworkflow.api.functions.FunctionRef; |
30 | 31 | import io.serverlessworkflow.api.functions.SubFlowRef; |
@@ -798,4 +799,41 @@ public void testContinueAsObject(String workflowLocation) { |
798 | 799 | assertNotNull(end.getContinueAs().getWorkflowExecTimeout()); |
799 | 800 | assertEquals("PT1M", end.getContinueAs().getWorkflowExecTimeout().getDuration()); |
800 | 801 | } |
| 802 | + |
| 803 | + @ParameterizedTest |
| 804 | + @ValueSource(strings = {"/features/invoke.json", "/features/invoke.yml"}) |
| 805 | + public void testFunctionInvoke(String workflowLocation) { |
| 806 | + Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation)); |
| 807 | + |
| 808 | + assertNotNull(workflow); |
| 809 | + assertNotNull(workflow.getId()); |
| 810 | + assertNotNull(workflow.getName()); |
| 811 | + assertNotNull(workflow.getStates()); |
| 812 | + |
| 813 | + assertNotNull(workflow.getStates()); |
| 814 | + assertEquals(1, workflow.getStates().size()); |
| 815 | + |
| 816 | + OperationState operationState = (OperationState) workflow.getStates().get(0); |
| 817 | + assertNotNull(operationState.getEnd()); |
| 818 | + assertNotNull(operationState.getActions()); |
| 819 | + assertEquals(3, operationState.getActions().size()); |
| 820 | + |
| 821 | + Action action1 = operationState.getActions().get(0); |
| 822 | + assertNotNull(action1.getFunctionRef()); |
| 823 | + assertNotNull(action1.getFunctionRef().getInvoke()); |
| 824 | + assertEquals(FunctionRef.Invoke.ASYNC, action1.getFunctionRef().getInvoke()); |
| 825 | + |
| 826 | + Action action2 = operationState.getActions().get(1); |
| 827 | + assertNotNull(action2.getSubFlowRef()); |
| 828 | + assertNotNull(action2.getSubFlowRef().getOnParentComplete()); |
| 829 | + assertEquals( |
| 830 | + SubFlowRef.OnParentComplete.CONTINUE, action2.getSubFlowRef().getOnParentComplete()); |
| 831 | + assertNotNull(action2.getSubFlowRef().getInvoke()); |
| 832 | + assertEquals(SubFlowRef.Invoke.ASYNC, action2.getSubFlowRef().getInvoke()); |
| 833 | + |
| 834 | + Action action3 = operationState.getActions().get(2); |
| 835 | + assertNotNull(action3.getEventRef()); |
| 836 | + assertNotNull(action3.getEventRef().getInvoke()); |
| 837 | + assertEquals(EventRef.Invoke.ASYNC, action3.getEventRef().getInvoke()); |
| 838 | + } |
801 | 839 | } |
0 commit comments