diff --git a/pom.xml b/pom.xml
index 4330075..bc6774b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -99,12 +99,6 @@
org.springframework.boot
spring-boot-starter-test
test
-
-
- org.junit.vintage
- junit-vintage-engine
-
-
@@ -128,10 +122,10 @@
- junit
- junit
+ org.junit.jupiter
+ junit-jupiter
+ 5.7.1
test
- 4.13.2
@@ -142,8 +136,16 @@
- io.camunda
- zeebe-test
+ org.testcontainers
+ junit-jupiter
+ 1.15.3
+ test
+
+
+
+ io.zeebe
+ zeebe-test-container
+ 3.0.0
test
@@ -152,6 +154,12 @@
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.22.2
+
+
org.apache.maven.plugins
maven-javadoc-plugin
diff --git a/src/test/java/io/zeebe/script/EvaluationFeelTest.java b/src/test/java/io/zeebe/script/EvaluationFeelTest.java
index 7f76c9c..08e7ddb 100644
--- a/src/test/java/io/zeebe/script/EvaluationFeelTest.java
+++ b/src/test/java/io/zeebe/script/EvaluationFeelTest.java
@@ -23,7 +23,7 @@
import java.util.List;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class EvaluationFeelTest {
diff --git a/src/test/java/io/zeebe/script/EvaluationGroovyTest.java b/src/test/java/io/zeebe/script/EvaluationGroovyTest.java
index 65e4fef..8743b51 100644
--- a/src/test/java/io/zeebe/script/EvaluationGroovyTest.java
+++ b/src/test/java/io/zeebe/script/EvaluationGroovyTest.java
@@ -22,7 +22,7 @@
import java.util.List;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class EvaluationGroovyTest {
diff --git a/src/test/java/io/zeebe/script/EvaluationJavaScriptTest.java b/src/test/java/io/zeebe/script/EvaluationJavaScriptTest.java
index 198eecf..42f0a0d 100644
--- a/src/test/java/io/zeebe/script/EvaluationJavaScriptTest.java
+++ b/src/test/java/io/zeebe/script/EvaluationJavaScriptTest.java
@@ -21,7 +21,7 @@
import java.util.Collections;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class EvaluationJavaScriptTest {
diff --git a/src/test/java/io/zeebe/script/EvaluationKotlinTest.java b/src/test/java/io/zeebe/script/EvaluationKotlinTest.java
index 718f3a3..a4fe8e4 100644
--- a/src/test/java/io/zeebe/script/EvaluationKotlinTest.java
+++ b/src/test/java/io/zeebe/script/EvaluationKotlinTest.java
@@ -6,7 +6,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class EvaluationKotlinTest {
diff --git a/src/test/java/io/zeebe/script/EvaluationMustacheTest.java b/src/test/java/io/zeebe/script/EvaluationMustacheTest.java
index 3d9cd7c..396bfcb 100644
--- a/src/test/java/io/zeebe/script/EvaluationMustacheTest.java
+++ b/src/test/java/io/zeebe/script/EvaluationMustacheTest.java
@@ -15,7 +15,7 @@
*/
package io.zeebe.script;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.List;
import java.util.Map;
diff --git a/src/test/java/io/zeebe/script/ScriptEvaluatorTest.java b/src/test/java/io/zeebe/script/ScriptEvaluatorTest.java
index 3000b4c..33d0721 100644
--- a/src/test/java/io/zeebe/script/ScriptEvaluatorTest.java
+++ b/src/test/java/io/zeebe/script/ScriptEvaluatorTest.java
@@ -19,7 +19,7 @@
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import java.util.Collections;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class ScriptEvaluatorTest {
diff --git a/src/test/java/io/zeebe/script/WorkflowTest.java b/src/test/java/io/zeebe/script/WorkflowTest.java
index 9c7c035..fa545f0 100644
--- a/src/test/java/io/zeebe/script/WorkflowTest.java
+++ b/src/test/java/io/zeebe/script/WorkflowTest.java
@@ -2,33 +2,34 @@
import static org.assertj.core.api.Assertions.assertThat;
-import io.camunda.zeebe.client.api.response.ProcessInstanceEvent;
+import io.camunda.zeebe.client.ZeebeClient;
+import io.camunda.zeebe.client.api.response.ProcessInstanceResult;
+import io.zeebe.containers.ZeebeContainer;
import io.camunda.zeebe.model.bpmn.Bpmn;
import io.camunda.zeebe.model.bpmn.BpmnModelInstance;
-import io.camunda.zeebe.protocol.record.intent.MessageIntent;
-import io.camunda.zeebe.protocol.record.value.MessageRecordValue;
-import io.camunda.zeebe.test.ZeebeTestRule;
-import io.camunda.zeebe.test.util.record.RecordingExporter;
import java.util.Collections;
import java.util.Map;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.BeforeAll;
import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.testcontainers.junit.jupiter.Container;
+import org.testcontainers.junit.jupiter.Testcontainers;
-@RunWith(SpringRunner.class)
@SpringBootTest
+@Testcontainers
public class WorkflowTest {
- @ClassRule public static final ZeebeTestRule TEST_RULE = new ZeebeTestRule();
+ @Container private static final ZeebeContainer ZEEBE_CONTAINER = new ZeebeContainer();
- @BeforeClass
+ private static ZeebeClient ZEEBE_CLIENT;
+
+ @BeforeAll
public static void init() {
- System.setProperty(
- "zeebe.client.broker.contactPoint",
- TEST_RULE.getClient().getConfiguration().getGatewayAddress());
+ final var gatewayContactPoint = ZEEBE_CONTAINER.getExternalGatewayAddress();
+ System.setProperty("zeebe.client.broker.contactPoint", gatewayContactPoint);
+
+ ZEEBE_CLIENT =
+ ZeebeClient.newClientBuilder().gatewayAddress(gatewayContactPoint).usePlaintext().build();
}
@Test
@@ -45,10 +46,10 @@ public void shouldReturnResult() {
.zeebeTaskHeader("script", "x + 1"))
.done();
- final ProcessInstanceEvent workflowInstance =
+ final var workflowInstanceResult =
deployAndCreateInstance(workflow, Collections.singletonMap("x", 2));
- ZeebeTestRule.assertThat(workflowInstance).isEnded().hasVariable("result", 3);
+ assertThat(workflowInstanceResult.getVariablesAsMap()).containsEntry("result", 3);
}
@Test
@@ -65,59 +66,56 @@ public void shouldGetCurrentJob() {
.zeebeTaskHeader("script", "job.processInstanceKey"))
.done();
- final ProcessInstanceEvent workflowInstance =
- deployAndCreateInstance(workflow, Collections.emptyMap());
+ final var workflowInstanceResult = deployAndCreateInstance(workflow, Collections.emptyMap());
- ZeebeTestRule.assertThat(workflowInstance)
- .isEnded()
- .hasVariable("result", workflowInstance.getProcessInstanceKey());
+ assertThat(workflowInstanceResult.getVariablesAsMap())
+ .containsEntry("result", workflowInstanceResult.getProcessInstanceKey());
}
@Test
public void shouldUseZeebeClient() {
+ final String groovyScript =
+ "zeebeClient.newPublishMessageCommand()"
+ + ".messageName('foo')"
+ + ".correlationKey(key)"
+ + ".timeToLive(java.time.Duration.ofMinutes(1))"
+ + ".variables('{\"x\":1}')"
+ + ".send().join()";
final BpmnModelInstance workflow =
Bpmn.createExecutableProcess("process")
.startEvent()
+ .parallelGateway("fork")
.serviceTask(
"task",
- t ->
- t.zeebeJobType("script")
- .zeebeTaskHeader("language", "groovy")
- .zeebeTaskHeader(
- "script",
- "zeebeClient.newPublishMessageCommand().messageName('foo').correlationKey('bar').send().join()"))
+ t -> {
+ t.zeebeJobType("script")
+ .zeebeTaskHeader("language", "groovy")
+ .zeebeTaskHeader("script", groovyScript);
+ })
+ .endEvent()
+ .moveToNode("fork")
+ .intermediateCatchEvent(
+ "message", e -> e.message(m -> m.name("foo").zeebeCorrelationKeyExpression("key")))
+ .endEvent()
.done();
- final ProcessInstanceEvent workflowInstance =
- deployAndCreateInstance(workflow, Collections.emptyMap());
-
- ZeebeTestRule.assertThat(workflowInstance).isEnded();
+ final var workflowInstanceResult = deployAndCreateInstance(workflow, Map.of("key", "key-1"));
- final MessageRecordValue publishedMessage =
- RecordingExporter.messageRecords(MessageIntent.PUBLISHED).getFirst().getValue();
- assertThat(publishedMessage.getName()).isEqualTo("foo");
- assertThat(publishedMessage.getCorrelationKey()).isEqualTo("bar");
+ assertThat(workflowInstanceResult.getVariablesAsMap()).containsEntry("x", 1);
}
- private ProcessInstanceEvent deployAndCreateInstance(
+ private ProcessInstanceResult deployAndCreateInstance(
final BpmnModelInstance workflow, Map variables) {
- TEST_RULE
- .getClient()
- .newDeployCommand()
- .addProcessModel(workflow, "process.bpmn")
+ ZEEBE_CLIENT.newDeployCommand().addProcessModel(workflow, "process.bpmn").send().join();
+
+ return ZEEBE_CLIENT
+ .newCreateInstanceCommand()
+ .bpmnProcessId("process")
+ .latestVersion()
+ .variables(variables)
+ .withResult()
.send()
.join();
-
- final ProcessInstanceEvent workflowInstance =
- TEST_RULE
- .getClient()
- .newCreateInstanceCommand()
- .bpmnProcessId("process")
- .latestVersion()
- .variables(variables)
- .send()
- .join();
- return workflowInstance;
}
}