Skip to content

Commit

Permalink
migrated to sdk and camunda process test (#1082)
Browse files Browse the repository at this point in the history
* migrated to sdk and camunda process test

* example use sdk as well
  • Loading branch information
jonathanlukas authored Dec 16, 2024
1 parent f867172 commit dd1adec
Show file tree
Hide file tree
Showing 21 changed files with 571 additions and 711 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);
}
}
13 changes: 2 additions & 11 deletions example/code-migration-detector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,8 @@
<artifactId>spring-boot-starter</artifactId>
<version>3.3.6</version>
</dependency>
<dependency>
<groupId>io.camunda.spring</groupId>
<artifactId>spring-boot-starter-camunda</artifactId>
<version>8.5.15</version>
</dependency>
<dependency>
<groupId>io.camunda.spring</groupId>
<artifactId>spring-boot-starter-camunda-test-testcontainer</artifactId>
<version>8.5.15</version>
<scope>test</scope>
</dependency>


<dependency>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-engine-spring</artifactId>
Expand Down
14 changes: 6 additions & 8 deletions example/process-solution-migrated/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
<version.spring-boot>3.3.6</version.spring-boot>
<version.camunda>7.22.0</version.camunda>
<version.adapter>0.10.2</version.adapter>
<version.spring-zeebe>8.5.13</version.spring-zeebe>

<version.zeebe>8.6.6</version.zeebe>
<plugin.version.maven-surefire-plugin>3.5.2</plugin.version.maven-surefire-plugin>
</properties>

Expand Down Expand Up @@ -54,11 +53,10 @@
<artifactId>camunda-7-adapter</artifactId>
<version>${version.adapter}</version>
</dependency>
<!-- Testcontainers is required as we run on Java 1.8 here. 'spring-boot-starter-camunda-test' can be used with Java 17 upwards-->
<dependency>
<groupId>io.camunda.spring</groupId>
<artifactId>spring-boot-starter-camunda-test-testcontainer</artifactId>
<version>${version.spring-zeebe}</version>
<groupId>io.camunda</groupId>
<artifactId>camunda-process-test-spring</artifactId>
<version>${version.zeebe}</version>
</dependency>
</dependencies>
</dependencyManagement>
Expand All @@ -69,8 +67,8 @@
<artifactId>camunda-7-adapter</artifactId>
</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>
</dependencies>
Expand Down
Loading

0 comments on commit dd1adec

Please sign in to comment.