diff --git a/spring-boot/task/pom.xml b/spring-boot/task/pom.xml
index b2d4f74..e5e72ce 100644
--- a/spring-boot/task/pom.xml
+++ b/spring-boot/task/pom.xml
@@ -15,21 +15,26 @@
jar
- 8.4.0
8.4.0.7
- io.camunda.spring
- spring-boot-starter-camunda
+ io.camunda.connector
+ spring-boot-starter-camunda-connectors
${camunda.version}
-
-
-
-
-
+
+ io.camunda.connector
+ connector-http-json
+ ${camunda.version}
+
+
+ io.camunda.connector
+ connector-test
+ ${camunda.version}
+ test
+
io.camunda
camunda-tasklist-client-java
diff --git a/spring-boot/task/src/main/java/com/micasa/tutorial/Application.java b/spring-boot/task/src/main/java/com/micasa/tutorial/Application.java
index 85dceb9..bc2621d 100644
--- a/spring-boot/task/src/main/java/com/micasa/tutorial/Application.java
+++ b/spring-boot/task/src/main/java/com/micasa/tutorial/Application.java
@@ -2,9 +2,14 @@
import io.camunda.zeebe.spring.client.annotation.Deployment;
import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
+@ImportAutoConfiguration({
+ io.camunda.connector.runtime.InboundConnectorsAutoConfiguration.class,
+ io.camunda.connector.runtime.OutboundConnectorsAutoConfiguration.class
+})
@Deployment(resources = "classpath*:*.bpmn")
public class Application {
public static void main(String[] args) {
diff --git a/spring-boot/task/src/main/java/com/micasa/tutorial/config/TaskListClientConfig.java b/spring-boot/task/src/main/java/com/micasa/tutorial/config/TaskListClientConfig.java
index e283e4a..396e464 100644
--- a/spring-boot/task/src/main/java/com/micasa/tutorial/config/TaskListClientConfig.java
+++ b/spring-boot/task/src/main/java/com/micasa/tutorial/config/TaskListClientConfig.java
@@ -10,7 +10,6 @@
@Configuration
@ConfigurationProperties(prefix = "tasklist")
-@Profile("!test")
public class TaskListClientConfig {
private String url;
@@ -64,12 +63,14 @@ public CamundaTaskListClient camundaTaskListClient() throws TaskListException {
.jwtConfig(jwtConfig)
.build();
- return CamundaTaskListClient.builder()
+ var client = CamundaTaskListClient.builder()
.taskListUrl(url)
.shouldReturnVariables()
.shouldLoadTruncatedVariables()
.authentication(auth)
.build();
+
+ return client;
}
}
\ No newline at end of file
diff --git a/spring-boot/task/src/main/java/com/micasa/tutorial/controller/ProcessController.java b/spring-boot/task/src/main/java/com/micasa/tutorial/controller/ProcessController.java
index d3f71cb..ea8bc16 100644
--- a/spring-boot/task/src/main/java/com/micasa/tutorial/controller/ProcessController.java
+++ b/spring-boot/task/src/main/java/com/micasa/tutorial/controller/ProcessController.java
@@ -8,7 +8,6 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
-
@RestController
public class ProcessController {
diff --git a/spring-boot/task/src/main/resources/application-local.yaml b/spring-boot/task/src/main/resources/application-local.yaml
new file mode 100644
index 0000000..d5daf23
--- /dev/null
+++ b/spring-boot/task/src/main/resources/application-local.yaml
@@ -0,0 +1,22 @@
+# https://github.com/camunda-community-hub/spring-zeebe#configuring-camunda-platform-8-saas-connection
+# https://github.com/camunda-community-hub/spring-zeebe#additional-configuration-options
+
+zeebe:
+ client:
+ broker:
+ gateway-address: localhost:26500
+ security:
+ plaintext: true
+ cloud:
+ client-id: zeebe
+ client-secret: zecret
+ auth-url: http://localhost:18080/auth/realms/camunda-platform/protocol/openid-connect/token
+
+tasklist:
+ url: http://localhost:8082
+ keycloak-url: http://localhost:18080
+ client-id: ${zeebe.client.cloud.client-id}
+ client-secret: ${zeebe.client.cloud.client-secret}
+
+api:
+ url: http://${ENV:prod}-rates:9999/exchangeRates
diff --git a/spring-boot/task/src/main/resources/application.yaml b/spring-boot/task/src/main/resources/application.yaml
index ee345a5..47f4606 100644
--- a/spring-boot/task/src/main/resources/application.yaml
+++ b/spring-boot/task/src/main/resources/application.yaml
@@ -1,39 +1,29 @@
# https://github.com/camunda-community-hub/spring-zeebe#configuring-camunda-platform-8-saas-connection
# https://github.com/camunda-community-hub/spring-zeebe#additional-configuration-options
-#zeebe:
-# client:
-# cloud:
-# region: ont-1
-# clusterId: 35eedd8b-35e5-4373-8a4c-f211043e42da
-# clientId: kMVnghsS4TV7lqocluB9AsLNNRSNsCr1
-# clientSecret: EIt0BqN-bEK~hVbvN8tZO4vPgmZYQ-RbQdnqRwIsyQnZ9Bp-h5XJBT9NuS8cFnu-
-
-#camunda:
-# client:
-# mode: oidc
-# auth:
-# client-id: zeebe
-# client-secret: zecret
zeebe:
client:
broker:
gateway-address: localhost:26500
security:
plaintext: true
-# connection-mode: ADDRESS
cloud:
client-id: zeebe
client-secret: zecret
auth-url: http://localhost:18080/auth/realms/camunda-platform/protocol/openid-connect/token
tasklist:
-# url: https://ont-1.tasklist.camunda.io/35eedd8b-35e5-4373-8a4c-f211043e42da
-# keycloak-url: https://login.cloud.camunda.io/oauth/token
url: http://localhost:8082
keycloak-url: http://localhost:18080
client-id: ${zeebe.client.cloud.client-id}
client-secret: ${zeebe.client.cloud.client-secret}
+camunda:
+ connector:
+ polling:
+ enabled: false
+ webhook:
+ enabled: false
+
api:
url: http://${ENV:prod}-rates:9999/exchangeRates
diff --git a/spring-boot/task/src/main/resources/userTask.bpmn b/spring-boot/task/src/main/resources/userTask.bpmn
index d4fdba1..7c0fed8 100644
--- a/spring-boot/task/src/main/resources/userTask.bpmn
+++ b/spring-boot/task/src/main/resources/userTask.bpmn
@@ -13,7 +13,7 @@
Flow_1necipk
-
+
@@ -52,13 +52,13 @@
Flow_09fsnwm
Flow_14rbqge
-
+
Flow_1necipk
Flow_17ovhw0
Flow_0ghnk0a
-
-
+
+
=fromAmount >= 1000
@@ -94,8 +94,11 @@
-
+
+
+
+
diff --git a/spring-boot/task/src/test/java/com/micasa/tutorial/TaskProcessTest.java b/spring-boot/task/src/test/java/com/micasa/tutorial/TaskProcessTest.java
index 298845e..12357ea 100644
--- a/spring-boot/task/src/test/java/com/micasa/tutorial/TaskProcessTest.java
+++ b/spring-boot/task/src/test/java/com/micasa/tutorial/TaskProcessTest.java
@@ -8,22 +8,34 @@
import io.camunda.zeebe.process.test.inspections.InspectionUtility;
import io.camunda.zeebe.process.test.inspections.model.InspectedProcessInstance;
import io.camunda.zeebe.spring.test.ZeebeSpringTest;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
-import static com.github.tomakehurst.wiremock.client.WireMock.*;
+//import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static io.camunda.zeebe.spring.test.ZeebeTestThreadSupport.waitForProcessInstanceCompleted;
+import static io.camunda.zeebe.spring.test.ZeebeTestThreadSupport.waitForProcessInstanceHasPassedElement;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
+import org.springframework.http.MediaType;
import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.MvcResult;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+import org.springframework.web.context.WebApplicationContext;
import java.time.Duration;
import java.util.concurrent.TimeoutException;
@SpringBootTest
+@AutoConfigureMockMvc
@ZeebeSpringTest
-@WireMockTest(httpPort = 9999)
+//@WireMockTest(httpPort = 9999)
@ActiveProfiles("test")
@DisplayName("User Task Test")
class TaskProcessTest {
@@ -36,75 +48,37 @@ class TaskProcessTest {
@Autowired
private ZeebeService zeebeService;
- @Test
- @DisplayName("Amount >= 1000 --> preferential rate")
- void preferentialRate() {
- zeebeService.startProcess(new ExchangeRateRequest("USD", "CAD", 1000));
-
- InspectedProcessInstance processInstance = InspectionUtility
- .findProcessInstances()
- .withBpmnProcessId(processId)
- .findFirstProcessInstance()
- .get();
+ @Autowired
+ private MockMvc mvc;
- waitForProcessInstanceCompleted(processInstance);
+ @Autowired
+ private WebApplicationContext webApplicationContext;
- BpmnAssert.assertThat(processInstance)
- .hasPassedElement("Start_ExchangeRateRequest")
- .isWaitingAtElements("UserTask_PreferentialRate");
+ @BeforeEach
+ public void setup() {
+ //Init MockMvc Object and build
+ mvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
}
@Test
- @DisplayName("API error -> default rate")
- void error() {
- stubFor(
- get(urlPathEqualTo("/exchangeRates"))
- .withQueryParam("fromCurrency", equalTo("INVALID"))
- .withQueryParam("toCurrency", equalTo("CAD"))
- .withQueryParam("amount", equalTo("1000"))
- .willReturn(serverError())
- );
-
- zeebeService.startProcess(new ExchangeRateRequest("INVALID", "CAD", 1000));
+ @DisplayName("Amount >= 1000 --> preferential rate")
+ void preferentialRate() throws Exception {
+ zeebeService.startProcess(new ExchangeRateRequest("USD", "CAD", 1000));
InspectedProcessInstance processInstance = InspectionUtility
.findProcessInstances()
- .withBpmnProcessId("Process_RESTConnector")
+ .withBpmnProcessId(processId)
.findFirstProcessInstance()
.get();
- waitForProcessInstanceCompleted(processInstance);
+ waitForProcessInstanceHasPassedElement(processInstance, "Gateway_LargeAmount");
BpmnAssert.assertThat(processInstance)
- .hasPassedElement("Task-DefaultRate")
- .hasVariableWithValue("fromCurrency", "INVALID")
- .hasVariableWithValue("exchangeRate", 1.3); // default rate
- }
-
- @Test
- @DisplayName("Request error -> incident")
- void incident() throws InterruptedException, TimeoutException {
- stubFor(
- get(urlPathEqualTo("/exchangeRates"))
- .withQueryParam("fromCurrency", equalTo("USD"))
- .withQueryParam("toCurrency", equalTo("CAD"))
- .withQueryParam("amount", equalTo("0"))
- .willReturn(badRequest())
- );
-
- zeebeService.startProcess(new ExchangeRateRequest("USD", "CAD", 0));
-
- InspectedProcessInstance processInstance = InspectionUtility
- .findProcessInstances()
- .withBpmnProcessId("Process_RESTConnector")
- .findFirstProcessInstance()
- .get();
-
- engine.waitForBusyState(Duration.ofSeconds(10));
+ .isWaitingAtElements("UserTask_PreferentialRate");
- BpmnAssert.assertThat(processInstance)
- .hasNotPassedElement("Task_CallExchangeRateAPI")
- .hasAnyIncidents();
+ mvc.perform(get("/task"))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.length()").value(1));
}
}