|
23 | 23 | import io.serverlessworkflow.api.Workflow; |
24 | 24 | import io.serverlessworkflow.api.auth.AuthDefinition; |
25 | 25 | import io.serverlessworkflow.api.auth.BasicAuthDefinition; |
| 26 | +import io.serverlessworkflow.api.defaultdef.DefaultConditionDefinition; |
26 | 27 | import io.serverlessworkflow.api.end.End; |
27 | 28 | import io.serverlessworkflow.api.events.EventDefinition; |
28 | 29 | import io.serverlessworkflow.api.functions.FunctionDefinition; |
|
31 | 32 | import io.serverlessworkflow.api.schedule.Schedule; |
32 | 33 | import io.serverlessworkflow.api.start.Start; |
33 | 34 | import io.serverlessworkflow.api.states.SleepState; |
| 35 | +import io.serverlessworkflow.api.states.SwitchState; |
| 36 | +import io.serverlessworkflow.api.switchconditions.DataCondition; |
| 37 | +import io.serverlessworkflow.api.switchconditions.EventCondition; |
| 38 | +import io.serverlessworkflow.api.transitions.Transition; |
34 | 39 | import io.serverlessworkflow.api.workflow.Auth; |
35 | 40 | import io.serverlessworkflow.api.workflow.Constants; |
36 | 41 | import io.serverlessworkflow.api.workflow.Events; |
@@ -189,4 +194,46 @@ public void testAuth() { |
189 | 194 | assertEquals( |
190 | 195 | "testPassword", workflow.getAuth().getAuthDefs().get(0).getBasicauth().getPassword()); |
191 | 196 | } |
| 197 | + |
| 198 | + @Test |
| 199 | + public void testSwitchConditionWithTransition() { |
| 200 | + Workflow workflow = |
| 201 | + new Workflow() |
| 202 | + .withId("test-workflow") |
| 203 | + .withName("test-workflow-name") |
| 204 | + .withVersion("1.0") |
| 205 | + .withSpecVersion("0.8") |
| 206 | + .withStates( |
| 207 | + Arrays.asList( |
| 208 | + new SwitchState() |
| 209 | + .withDataConditions( |
| 210 | + Arrays.asList( |
| 211 | + new DataCondition() |
| 212 | + .withCondition("test-condition") |
| 213 | + .withTransition( |
| 214 | + new Transition().withNextState("test-next-state")))) |
| 215 | + .withDefaultCondition( |
| 216 | + new DefaultConditionDefinition() |
| 217 | + .withTransition(new Transition("test-next-state-default"))))); |
| 218 | + assertNotNull(Workflow.toJson(workflow)); |
| 219 | + assertNotNull(Workflow.toYaml(workflow)); |
| 220 | + } |
| 221 | + |
| 222 | + @Test |
| 223 | + public void testSwitchConditionWithEnd() { |
| 224 | + Workflow workflow = |
| 225 | + new Workflow() |
| 226 | + .withId("test-workflow") |
| 227 | + .withName("test-workflow-name") |
| 228 | + .withVersion("1.0") |
| 229 | + .withSpecVersion("0.8") |
| 230 | + .withStates( |
| 231 | + Arrays.asList( |
| 232 | + new SwitchState() |
| 233 | + .withEventConditions(Arrays.asList(new EventCondition().withEnd(new End()))) |
| 234 | + .withDefaultCondition( |
| 235 | + new DefaultConditionDefinition().withEnd(new End())))); |
| 236 | + assertNotNull(Workflow.toJson(workflow)); |
| 237 | + assertNotNull(Workflow.toYaml(workflow)); |
| 238 | + } |
192 | 239 | } |
0 commit comments