5
5
import org .junit .jupiter .api .Order ;
6
6
import org .junit .jupiter .api .Tag ;
7
7
import org .junit .jupiter .api .Test ;
8
+ import org .junit .jupiter .params .ParameterizedTest ;
9
+ import org .junit .jupiter .params .provider .ValueSource ;
8
10
9
11
import static io .restassured .RestAssured .get ;
10
12
import static io .restassured .RestAssured .post ;
@@ -26,14 +28,7 @@ public void basicChain() throws InterruptedException {
26
28
Response response = post (startOrchestrationPath );
27
29
JsonPath jsonPath = response .jsonPath ();
28
30
String statusQueryGetUri = jsonPath .get ("statusQueryGetUri" );
29
- String runTimeStatus = null ;
30
- for (int i = 0 ; i < 15 ; i ++) {
31
- Response statusResponse = get (statusQueryGetUri );
32
- runTimeStatus = statusResponse .jsonPath ().get ("runtimeStatus" );
33
- if (!"Completed" .equals (runTimeStatus )) {
34
- Thread .sleep (1000 );
35
- } else break ;
36
- }
31
+ String runTimeStatus = waitForCompletion (statusQueryGetUri );
37
32
assertEquals ("Completed" , runTimeStatus );
38
33
}
39
34
@@ -59,4 +54,44 @@ public void continueAsNew() throws InterruptedException {
59
54
runTimeStatus = statusResponse .jsonPath ().get ("runtimeStatus" );
60
55
assertEquals ("Terminated" , runTimeStatus );
61
56
}
57
+
58
+ @ ParameterizedTest
59
+ @ ValueSource (booleans = {true , false })
60
+ public void restart (boolean restartWithNewInstanceId ) throws InterruptedException {
61
+ String startOrchestrationPath = "/api/StartOrchestration" ;
62
+ Response response = post (startOrchestrationPath );
63
+ JsonPath jsonPath = response .jsonPath ();
64
+ String statusQueryGetUri = jsonPath .get ("statusQueryGetUri" );
65
+ String runTimeStatus = waitForCompletion (statusQueryGetUri );
66
+ assertEquals ("Completed" , runTimeStatus );
67
+ Response statusResponse = get (statusQueryGetUri );
68
+ String instanceId = statusResponse .jsonPath ().get ("instanceId" );
69
+
70
+ String restartPostUri = jsonPath .get ("restartPostUri" ) + "&restartWithNewInstanceId=" + restartWithNewInstanceId ;
71
+ Response restartResponse = post (restartPostUri );
72
+ JsonPath restartJsonPath = restartResponse .jsonPath ();
73
+ String restartStatusQueryGetUri = restartJsonPath .get ("statusQueryGetUri" );
74
+ String restartRuntimeStatus = waitForCompletion (restartStatusQueryGetUri );
75
+ assertEquals ("Completed" , restartRuntimeStatus );
76
+ Response restartStatusResponse = get (restartStatusQueryGetUri );
77
+ String newInstanceId = restartStatusResponse .jsonPath ().get ("instanceId" );
78
+ if (restartWithNewInstanceId ) {
79
+ assertNotEquals (instanceId , newInstanceId );
80
+ } else {
81
+ assertEquals (instanceId , newInstanceId );
82
+ }
83
+ }
84
+
85
+ private String waitForCompletion (String statusQueryGetUri ) throws InterruptedException {
86
+ String runTimeStatus = null ;
87
+ for (int i = 0 ; i < 15 ; i ++) {
88
+ Response statusResponse = get (statusQueryGetUri );
89
+ runTimeStatus = statusResponse .jsonPath ().get ("runtimeStatus" );
90
+ if (!"Completed" .equals (runTimeStatus )) {
91
+ Thread .sleep (1000 );
92
+ } else break ;
93
+ }
94
+ return runTimeStatus ;
95
+ }
96
+
62
97
}
0 commit comments