7
7
import com .netflix .conductor .common .metadata .workflow .WorkflowDef ;
8
8
import com .netflix .conductor .common .metadata .workflow .WorkflowTask ;
9
9
import com .netflix .conductor .common .run .Workflow ;
10
+ import org .junit .jupiter .api .AfterAll ;
10
11
import org .junit .jupiter .api .BeforeAll ;
11
12
import org .junit .jupiter .api .Test ;
12
13
13
14
import java .util .List ;
14
15
import java .util .Map ;
16
+ import java .util .concurrent .TimeUnit ;
15
17
18
+ import static java .util .concurrent .TimeUnit .SECONDS ;
16
19
import static org .junit .Assert .assertEquals ;
17
20
import static org .junit .Assert .assertNotNull ;
21
+ import static org .testcontainers .shaded .org .awaitility .Awaitility .await ;
18
22
19
23
public class ApiClientTest {
20
24
private static final String workflowName = "test_api_client_wf" ;
@@ -33,14 +37,20 @@ public static void init() {
33
37
registerWorkflowDef ();
34
38
}
35
39
40
+ @ AfterAll
41
+ public static void cleanUp () {
42
+ // Clean up resources
43
+ metadataClient .unregisterWorkflowDef (workflowName , 1 );
44
+ }
45
+
36
46
static void registerWorkflowDef () {
37
47
WorkflowTask httpTask = new WorkflowTask ();
38
48
httpTask .setDescription ("HTTP Task" );
39
49
httpTask .setWorkflowTaskType (TaskType .HTTP );
40
50
httpTask .setTaskReferenceName (taskName );
41
51
httpTask .setName (taskName );
42
52
httpTask .setInputParameters (Map .of (
43
- "uri" , "http://httpbin-server :8081/api/hello?name=apiClientTest" ,
53
+ "uri" , "http://httpBin :8081/api/hello?name=apiClientTest" ,
44
54
"method" , "GET"
45
55
));
46
56
@@ -61,7 +71,10 @@ void testApiClient() {
61
71
.withVersion (1 ));
62
72
63
73
System .out .println ("Started workflow " + workflowId );
64
-
74
+ await ().atMost (30 , SECONDS ).pollInterval (1 , SECONDS ).until (() -> {
75
+ var wf = workflowClient .getWorkflow (workflowId , true );
76
+ return wf .getStatus ().isTerminal ();
77
+ });
65
78
var workflow = workflowClient .getWorkflow (workflowId , true );
66
79
67
80
assertNotNull (workflowId );
0 commit comments