-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathScopeSequentialTest.java
More file actions
64 lines (50 loc) · 2.22 KB
/
ScopeSequentialTest.java
File metadata and controls
64 lines (50 loc) · 2.22 KB
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
58
59
60
61
62
63
64
package org.example.it;
import java.util.List;
import org.camunda.community.bpmndt.api.CallActivityHandler;
import org.camunda.community.bpmndt.api.JobHandler;
import org.camunda.community.bpmndt.api.MessageEventHandler;
import org.camunda.community.bpmndt.api.UserTaskHandler;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import generated.scopesequential.TC_startEvent__endEvent;
import io.camunda.zeebe.client.ZeebeClient;
import io.camunda.zeebe.process.test.api.ZeebeTestEngine;
import io.camunda.zeebe.process.test.assertions.ProcessInstanceAssert;
import io.camunda.zeebe.process.test.extension.ZeebeProcessTest;
@ZeebeProcessTest
class ScopeSequentialTest {
@RegisterExtension
TC_startEvent__endEvent tc = new TC_startEvent__endEvent();
ZeebeTestEngine engine;
ZeebeClient client;
@Test
void testExecute() {
var elements = List.of(1, 2, 3);
tc.handleMultiInstanceScope().verifyLoopCount(3).verifySequential().executeLoop((testCaseInstance, flowScopeKey) -> {
var userTaskHandler = new UserTaskHandler("userTask");
var messageCatchEventHandler = new MessageEventHandler("messageCatchEvent");
var serviceTaskHandler = new JobHandler("serviceTask");
var callActivityHandler = new CallActivityHandler("callActivity");
testCaseInstance.apply(flowScopeKey, userTaskHandler);
testCaseInstance.apply(flowScopeKey, messageCatchEventHandler);
var workerBuilder = client.newWorker()
.jobType("advanced")
.handler((client, job) -> client.newCompleteCommand(job).send());
try (var ignored = workerBuilder.open()) {
testCaseInstance.apply(flowScopeKey, serviceTaskHandler);
testCaseInstance.hasPassed(flowScopeKey, "serviceTask");
}
testCaseInstance.apply(flowScopeKey, callActivityHandler);
});
var workerBuilder = client.newWorker()
.jobType("advanced")
.handler((client, job) -> client.newCompleteCommand(job).send());
try (var ignored = workerBuilder.open()) {
tc.createExecutor(engine)
.simulateProcess("advanced")
.withVariable("elements", elements)
.verify(ProcessInstanceAssert::isCompleted)
.execute();
}
}
}