-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProcessConnectorIntegrationTest.java
57 lines (49 loc) · 2.12 KB
/
ProcessConnectorIntegrationTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package de.akquinet.camunda.fhir;
import io.camunda.zeebe.client.ZeebeClient;
import io.camunda.zeebe.client.api.response.ProcessInstanceEvent;
import org.awaitility.Awaitility;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestClient;
import java.time.Duration;
@SpringBootTest(properties = {"hapi.fhir.serverbase=http://localhost:8081/"})
public class ProcessConnectorIntegrationTest extends WiremockTestBase {
@Autowired
private ZeebeClient client;
@Test
public void testDeploymentAndStartProcessInstance() {
ProcessInstanceEvent processInstance = client
.newCreateInstanceCommand()
.bpmnProcessId("camundafhirconnector")
.latestVersion()
.variable("patientId", "example")
.send()
.join();
RestClient restClient = RestClient.create();
restClient
.post()
.uri("http://localhost:8080/api/login?username=demo&password=demo")
.retrieve();
Awaitility
.await()
.atMost(Duration.ofSeconds(30))
.until(() -> checkForProcessInstanceIsCompleted(restClient, processInstance.getProcessInstanceKey()));
}
private boolean checkForProcessInstanceIsCompleted(RestClient restClient, long processInstanceKey) {
ResponseEntity<String> result = restClient
.post()
.uri("http://localhost:8080/v1/process-instances/search")
.contentType(MediaType.APPLICATION_JSON)
.body("{\n" +
" \"filter\": { \n" +
" \"key\": " + processInstanceKey +
" }\n" +
"}")
.retrieve()
.toEntity(String.class);
return result.getStatusCode().is2xxSuccessful() && result.getBody().contains("COMPLETED");
}
}