-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProcessConnectorIntegrationTest.kt
54 lines (47 loc) · 1.86 KB
/
ProcessConnectorIntegrationTest.kt
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
package de.akquinet.camunda.fhir
import io.camunda.zeebe.client.ZeebeClient
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.web.client.RestClient
import java.time.Duration
@SpringBootTest(properties = ["hapi.fhir.serverbase=http://localhost:8081/Patient/"])
class ProcessConnectorIntegrationTest(@Autowired val client: ZeebeClient): WiremockTestBase() {
@Test
fun testDeploymentAndStartProcessInstance() {
val processInstance = client
.newCreateInstanceCommand()
.bpmnProcessId("camundafhirconnector")
.latestVersion()
.variable("patientId", "example")
.send()
.join()
val restClient = RestClient.create()
restClient
.post()
.uri("http://localhost:8080/api/login?username=demo&password=demo")
.retrieve()
Awaitility
.await()
.atMost(Duration.ofSeconds(20))
.until { checkForProcessInstanceIsCompleted(restClient, processInstance.processInstanceKey) }
}
private fun checkForProcessInstanceIsCompleted(restClient: RestClient, processInstanceKey: Long): Boolean {
val result = restClient
.post()
.uri("http://localhost:8080/v1/process-instances/search")
.contentType(MediaType.APPLICATION_JSON)
.body(
"""{
"filter": {
"key": $processInstanceKey
}
}"""
)
.retrieve()
.toEntity(String::class.java)
return result.statusCode.is2xxSuccessful && result.body!!.contains("COMPLETED")
}
}