Skip to content

Commit

Permalink
migrated to sdk and camunda process test
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanlukas committed Dec 16, 2024
1 parent e290194 commit e3740be
Show file tree
Hide file tree
Showing 16 changed files with 478 additions and 608 deletions.
5 changes: 0 additions & 5 deletions backend-diagram-converter/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.camunda</groupId>
<artifactId>zeebe-process-test-extension-testcontainer</artifactId>
<scope>test</scope>
</dependency>
</dependencies>


Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.RandomStringUtils;
import org.camunda.bpm.model.bpmn.Bpmn;
import org.camunda.bpm.model.bpmn.BpmnModelInstance;
import org.testcontainers.shaded.org.apache.commons.lang3.RandomStringUtils;

public class TestUtil {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import static org.camunda.community.migration.converter.message.MessageFactory.*;
import static org.junit.jupiter.api.Assertions.*;

import org.apache.commons.lang3.RandomStringUtils;
import org.junit.jupiter.api.Test;
import org.testcontainers.shaded.org.apache.commons.lang3.RandomStringUtils;

// TODO create more fine-grained tests
public class MessageFactoryTest {
Expand Down
36 changes: 21 additions & 15 deletions camunda-7-adapter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,38 @@
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>io.camunda.spring</groupId>
<artifactId>spring-boot-starter-camunda</artifactId>
</dependency>
<dependency>
<groupId>io.camunda.spring</groupId>
<artifactId>java-common</artifactId>
</dependency>
<dependency>
<groupId>io.camunda.spring</groupId>
<artifactId>spring-boot-starter-camunda-test-testcontainer</artifactId>
<scope>test</scope>
<groupId>io.camunda</groupId>
<artifactId>spring-boot-starter-camunda-sdk</artifactId>
</dependency>

<dependency>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-engine-spring</artifactId>
<exclusions>
<exclusion>
<groupId>org.camunda.feel</groupId>
<artifactId>feel-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-external-task-client-spring</artifactId>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
</dependency>
<dependency>
<groupId>io.camunda</groupId>
<artifactId>camunda-process-test-spring</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>



</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

/**
* DelegateExecution implementation that can be initialized with an {@link ActivatedJob} and
* provides all methods required for executing a JavaDelegate as part of an job worker.
* provides all methods required for executing a JavaDelegate as part of a job worker.
*
* @author Falko Menge (Camunda)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import io.camunda.zeebe.client.api.response.ActivatedJob;
import io.camunda.zeebe.client.api.worker.JobClient;
import io.camunda.zeebe.spring.client.annotation.JobWorker;
import io.camunda.zeebe.spring.client.exception.ZeebeBpmnError;
import io.camunda.zeebe.spring.common.exception.ZeebeBpmnError;
import java.util.HashMap;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,36 @@
package org.camunda.community.migration.adapter;

import static io.camunda.zeebe.spring.test.ZeebeTestThreadSupport.*;
import static org.junit.jupiter.api.Assertions.*;

import io.camunda.process.test.api.CamundaAssert;
import io.camunda.process.test.api.CamundaSpringProcessTest;
import io.camunda.zeebe.client.ZeebeClient;
import io.camunda.zeebe.client.api.response.ProcessInstanceEvent;
import io.camunda.zeebe.model.bpmn.Bpmn;
import io.camunda.zeebe.model.bpmn.BpmnModelInstance;
import io.camunda.zeebe.spring.test.ZeebeSpringTest;
import java.time.Duration;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
import java.util.Collections;
import org.camunda.community.migration.adapter.CamundaPlatform7AdapterTest.Config;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;

@SpringBootTest(
classes = CamundaPlatform7AdapterConfig.class,
properties = "logging.level.root=INFO")
@ZeebeSpringTest
@SpringBootTest(classes = Config.class, properties = "logging.level.root=INFO")
@CamundaSpringProcessTest
public class CamundaPlatform7AdapterTest {

@Import({CamundaPlatform7AdapterConfig.class})
static class Config {
@Bean
public MeterRegistry meterRegistry() {
return new SimpleMeterRegistry();
}
}

@Autowired private ZeebeClient zeebeClient;

@BeforeEach
Expand Down Expand Up @@ -59,8 +69,7 @@ public void testDelegateClass() {
.variables(Collections.singletonMap("someVariable", variableValue))
.send()
.join();

waitForProcessInstanceCompleted(processInstance, Duration.ofSeconds(60));
CamundaAssert.assertThat(processInstance).isCompleted();

assertTrue(SampleDelegate.executed);
assertFalse(SampleDelegate.canReachExecutionVariable);
Expand Down Expand Up @@ -89,8 +98,7 @@ public void testDelegateExpression() {
.variables(Collections.singletonMap("someVariable", "value"))
.send()
.join();

waitForProcessInstanceCompleted(processInstance, Duration.ofSeconds(60));
CamundaAssert.assertThat(processInstance).isCompleted();

assertTrue(SampleDelegateBean.executed);
assertFalse(SampleDelegateBean.canReachExecutionVariable);
Expand Down Expand Up @@ -120,7 +128,7 @@ public void testExpression() {
.send()
.join();

waitForProcessInstanceCompleted(processInstance, Duration.ofSeconds(60));
CamundaAssert.assertThat(processInstance).isCompleted();

assertTrue(SampleBean.executionReceived);
assertTrue(SampleBean.someVariableReceived);
Expand All @@ -147,7 +155,7 @@ public void testExternalTaskHandlerWrapper() {
.send()
.join();

waitForProcessInstanceCompleted(processInstance, Duration.ofSeconds(60));
CamundaAssert.assertThat(processInstance).isCompleted();
assertEquals("value", SampleExternalTaskHandler.someVariable);
}

Expand All @@ -158,14 +166,14 @@ void testBpmnError() {
.addResourceFromClasspath("test-with-error-event.bpmn")
.send()
.join();
ProcessInstanceEvent join =
ProcessInstanceEvent processInstance =
zeebeClient
.newCreateInstanceCommand()
.bpmnProcessId("error-test")
.latestVersion()
.send()
.join();
waitForProcessInstanceCompleted(join, Duration.ofSeconds(60));
CamundaAssert.assertThat(processInstance).isCompleted();
assertTrue(SampleDelegateBean.executed);
}
}
34 changes: 18 additions & 16 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
<maven.compiler.target>${version.java}</maven.compiler.target>

<version.zeebe>8.6.6</version.zeebe>
<version.spring-boot-starter-camunda>8.5.13</version.spring-boot-starter-camunda>
<version.zeebe-process-test-extension-testcontainer>8.6.6</version.zeebe-process-test-extension-testcontainer>
<version.camunda.platform>7.22.0</version.camunda.platform>
<version.jsoup>1.18.3</version.jsoup>
Expand Down Expand Up @@ -127,31 +126,34 @@
<version>${version.commons-io}</version>
</dependency>
<dependency>
<groupId>io.camunda.spring</groupId>
<artifactId>spring-boot-starter-camunda</artifactId>
<version>${version.spring-boot-starter-camunda}</version>
<groupId>io.camunda</groupId>
<artifactId>spring-boot-starter-camunda-sdk</artifactId>
<version>${version.zeebe}</version>
</dependency>
<dependency>
<groupId>io.camunda.spring</groupId>
<artifactId>java-common</artifactId>
<version>${version.spring-boot-starter-camunda}</version>
<artifactId>spring-boot-starter-camunda-operate</artifactId>
<version>8.6.2</version>
</dependency>
<dependency>
<groupId>io.camunda</groupId>
<artifactId>camunda-operate-client-java</artifactId>
<version>${version.operate-client}</version>
<groupId>org.camunda.feel</groupId>
<artifactId>feel-engine</artifactId>
<version>1.18.1</version>
</dependency>
<dependency>
<groupId>io.camunda.spring</groupId>
<artifactId>spring-boot-starter-camunda-test-testcontainer</artifactId>
<version>${version.spring-boot-starter-camunda}</version>
<scope>test</scope>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.13.15</version>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>4.0.2</version>
</dependency>
<dependency>
<groupId>io.camunda</groupId>
<artifactId>zeebe-process-test-extension-testcontainer</artifactId>
<version>${version.zeebe-process-test-extension-testcontainer}</version>
<scope>test</scope>
<artifactId>camunda-process-test-spring</artifactId>
<version>${version.zeebe}</version>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
Expand Down
15 changes: 10 additions & 5 deletions process-instance-migration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>io.camunda.spring</groupId>
<artifactId>spring-boot-starter-camunda</artifactId>
<groupId>io.camunda</groupId>
<artifactId>spring-boot-starter-camunda-sdk</artifactId>
<exclusions>
<exclusion>
<groupId>org.camunda.feel</groupId>
Expand All @@ -26,7 +26,7 @@
</dependency>
<dependency>
<groupId>io.camunda.spring</groupId>
<artifactId>java-common</artifactId>
<artifactId>spring-boot-starter-camunda-operate</artifactId>
</dependency>
<dependency>
<groupId>io.camunda</groupId>
Expand All @@ -38,8 +38,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.camunda.spring</groupId>
<artifactId>spring-boot-starter-camunda-test-testcontainer</artifactId>
<groupId>io.camunda</groupId>
<artifactId>camunda-process-test-spring</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -72,6 +72,11 @@
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Loading

0 comments on commit e3740be

Please sign in to comment.