17
17
package io .serverlessworkflow .api .test ;
18
18
19
19
import io .serverlessworkflow .api .Workflow ;
20
+ import io .serverlessworkflow .api .interfaces .State ;
21
+ import io .serverlessworkflow .api .states .EventState ;
22
+ import io .serverlessworkflow .api .states .OperationState ;
20
23
import io .serverlessworkflow .api .test .utils .WorkflowTestUtils ;
21
24
import org .junit .jupiter .params .ParameterizedTest ;
22
25
import org .junit .jupiter .params .provider .ValueSource ;
23
26
24
- import static org .junit .jupiter .api .Assertions .assertNotNull ;
25
- import static org .junit .jupiter .api .Assertions .assertTrue ;
27
+ import static org .junit .jupiter .api .Assertions .*;
26
28
27
29
public class MarkupToWorkflowTest {
28
30
@@ -74,7 +76,7 @@ public void testSpecFreatureFunctionRef(String workflowLocation) {
74
76
}
75
77
76
78
@ ParameterizedTest
77
- @ ValueSource (strings = {"/features/vetappointment.json" })
79
+ @ ValueSource (strings = {"/features/vetappointment.json" , "/features/vetappointment.yml" })
78
80
public void testSpecFreatureEventRef (String workflowLocation ) {
79
81
Workflow workflow = Workflow .fromSource (WorkflowTestUtils .readWorkflowFile (workflowLocation ));
80
82
@@ -90,4 +92,29 @@ public void testSpecFreatureEventRef(String workflowLocation) {
90
92
assertNotNull (workflow .getRetries ());
91
93
assertTrue (workflow .getRetries ().getRetryDefs ().size () == 1 );
92
94
}
95
+
96
+ @ ParameterizedTest
97
+ @ ValueSource (strings = {"/features/compensationworkflow.json" , "/features/compensationworkflow.yml" })
98
+ public void testSpecFreatureCompensation (String workflowLocation ) {
99
+ Workflow workflow = Workflow .fromSource (WorkflowTestUtils .readWorkflowFile (workflowLocation ));
100
+
101
+ assertNotNull (workflow );
102
+ assertNotNull (workflow .getId ());
103
+ assertNotNull (workflow .getName ());
104
+ assertNotNull (workflow .getStates ());
105
+
106
+ assertNotNull (workflow .getStates ());
107
+ assertTrue (workflow .getStates ().size () == 2 );
108
+
109
+ State firstState = workflow .getStates ().get (0 );
110
+ assertTrue (firstState instanceof EventState );
111
+ assertNotNull (firstState .getCompensatedBy ());
112
+ assertEquals ("CancelPurchase" , firstState .getCompensatedBy ());
113
+
114
+ State secondState = workflow .getStates ().get (1 );
115
+ assertTrue (secondState instanceof OperationState );
116
+ OperationState operationState = (OperationState ) secondState ;
117
+
118
+ assertTrue (operationState .isUsedForCompensation ());
119
+ }
93
120
}
0 commit comments