From 01b17a5b2833c05c99b44bee42753851a386ccf9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lukas=20M=C3=B6sle?=
<37705369+lmoesle@users.noreply.github.com>
Date: Thu, 14 Dec 2023 11:38:59 +0100
Subject: [PATCH] hotfix(#1114): switch to camunda rest client feign (#1117)
* refactor: use camunda-platform-7-rest-client-spring-boot in connector
* refactor: use camunda-platform-7-rest-client-spring-boot in connector
* refactor: rm tests
* refactor: use message api again
* refactor: use message api again
* refactor: remove unused okhttp3
---
.../digiwf-camunda-connector-service/pom.xml | 6 ---
.../connector/CamundaSecurityConfig.java | 43 +++++-------------
.../connector/DigiWFConnectorApplication.java | 2 +
.../src/main/resources/application.properties | 2 +
.../digiwf-camunda-connector-starter/pom.xml | 13 +++---
...giWFCamundaConnectorAutoConfiguration.java | 2 +-
.../digiwf-camunda-connector/pom.xml | 15 +++++--
.../bpmnerror/BpmnErrorServiceImpl.java | 10 +----
.../connector/data/EngineDataSerializer.java | 4 +-
.../incident/IncidentServiceImpl.java | 44 +++++++++----------
.../connector/message/MessageServiceImpl.java | 12 ++---
.../oss/digiwf/connector/BaseSpringTest.java | 13 ------
.../bpmnerror/BpmnErrorServiceTest.java | 23 +++-------
.../incident/IncidentServiceTest.java | 26 +++++------
.../connector/message/MessageServiceTest.java | 21 +++------
.../adapter/in/MessageProcessor.java | 6 +--
.../resources/rest-api-client/example.http | 6 +--
.../src/main/resources/application.yml | 5 +--
18 files changed, 90 insertions(+), 163 deletions(-)
delete mode 100644 digiwf-connector/digiwf-camunda-connector/src/test/java/de/muenchen/oss/digiwf/connector/BaseSpringTest.java
diff --git a/digiwf-connector/digiwf-camunda-connector-service/pom.xml b/digiwf-connector/digiwf-camunda-connector-service/pom.xml
index dc75e130e2..91ca331ad9 100644
--- a/digiwf-connector/digiwf-camunda-connector-service/pom.xml
+++ b/digiwf-connector/digiwf-camunda-connector-service/pom.xml
@@ -27,12 +27,6 @@
spring-cloud-starter-stream-kafka
-
- com.squareup.okhttp3
- okhttp
- ${okhttp.version}
-
-
de.muenchen.oss.digiwf
diff --git a/digiwf-connector/digiwf-camunda-connector-service/src/main/java/de/muenchen/oss/digiwf/connector/CamundaSecurityConfig.java b/digiwf-connector/digiwf-camunda-connector-service/src/main/java/de/muenchen/oss/digiwf/connector/CamundaSecurityConfig.java
index 18f7f8814b..d2967aa5b0 100644
--- a/digiwf-connector/digiwf-camunda-connector-service/src/main/java/de/muenchen/oss/digiwf/connector/CamundaSecurityConfig.java
+++ b/digiwf-connector/digiwf-camunda-connector-service/src/main/java/de/muenchen/oss/digiwf/connector/CamundaSecurityConfig.java
@@ -1,22 +1,13 @@
package de.muenchen.oss.digiwf.connector;
import de.muenchen.oss.digiwf.spring.security.client.OAuth2AccessTokenSupplier;
+import feign.RequestInterceptor;
import lombok.AllArgsConstructor;
-import okhttp3.Interceptor;
-import okhttp3.Request;
-import okhttp3.Response;
-import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
-import org.apache.hc.core5.http.EntityDetails;
-import org.apache.hc.core5.http.HttpRequest;
-import org.apache.hc.core5.http.protocol.HttpContext;
import org.camunda.bpm.client.interceptor.ClientRequestInterceptor;
-import org.camunda.community.rest.client.invoker.ApiClient;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
-
-import java.io.IOException;
+import org.springframework.http.HttpHeaders;
@Configuration
@Profile("!no-security")
@@ -25,31 +16,17 @@ public class CamundaSecurityConfig {
private final OAuth2AccessTokenSupplier tokenSupplier;
+ // Camunda External Task
@Bean
public ClientRequestInterceptor interceptor() {
- return context -> {
- context.addHeader("Authorization", this.getAccessToken());
- };
- }
-
- @Autowired
- public void addOAuthInterceptor(final ApiClient apiClient) {
- apiClient.setHttpClient(HttpClientBuilder.create().addRequestInterceptorFirst(this::intercept).build());
- }
-
- private void intercept(HttpRequest httpRequest, EntityDetails entityDetails, HttpContext httpContext) {
- httpRequest.addHeader("Authorization", this.getAccessToken());
- }
-
- public Response intercept(final Interceptor.Chain chain) throws IOException {
- final Request originalRequest = chain.request();
- final Request requestWithToken = originalRequest.newBuilder()
- .header("Authorization", this.getAccessToken())
- .build();
- return chain.proceed(requestWithToken);
+ return context ->
+ context.addHeader(HttpHeaders.AUTHORIZATION, "Bearer " + this.tokenSupplier.get().getTokenValue());
}
- public String getAccessToken() {
- return "Bearer " + this.tokenSupplier.get().getTokenValue();
+ // Feign
+ @Bean
+ public RequestInterceptor oAuth2RequestInterceptor() {
+ return (requestTemplate ->
+ requestTemplate.header(HttpHeaders.AUTHORIZATION, "Bearer " + tokenSupplier.get().getTokenValue()));
}
}
diff --git a/digiwf-connector/digiwf-camunda-connector-service/src/main/java/de/muenchen/oss/digiwf/connector/DigiWFConnectorApplication.java b/digiwf-connector/digiwf-camunda-connector-service/src/main/java/de/muenchen/oss/digiwf/connector/DigiWFConnectorApplication.java
index 5068501e9c..7248f311a2 100644
--- a/digiwf-connector/digiwf-camunda-connector-service/src/main/java/de/muenchen/oss/digiwf/connector/DigiWFConnectorApplication.java
+++ b/digiwf-connector/digiwf-camunda-connector-service/src/main/java/de/muenchen/oss/digiwf/connector/DigiWFConnectorApplication.java
@@ -1,10 +1,12 @@
package de.muenchen.oss.digiwf.connector;
+import org.camunda.community.rest.EnableCamundaRestClient;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
+@EnableCamundaRestClient
public class DigiWFConnectorApplication {
public static void main(final String[] args) {
diff --git a/digiwf-connector/digiwf-camunda-connector-service/src/main/resources/application.properties b/digiwf-connector/digiwf-camunda-connector-service/src/main/resources/application.properties
index d9baf95f9a..fe7b37f85d 100644
--- a/digiwf-connector/digiwf-camunda-connector-service/src/main/resources/application.properties
+++ b/digiwf-connector/digiwf-camunda-connector-service/src/main/resources/application.properties
@@ -1,3 +1,5 @@
server.port=8080
spring.application.name=@project.artifactId@
camunda.bpm.client.date-format=yyyy-MM-dd'T'HH:mm:ss.SSSX
+
+feign.client.config.default.url=${ENGINE_CAMUNDA_REST_ENDPOINT_URL}
diff --git a/digiwf-connector/digiwf-camunda-connector-starter/pom.xml b/digiwf-connector/digiwf-camunda-connector-starter/pom.xml
index b9004d61bd..fe160b49b6 100644
--- a/digiwf-connector/digiwf-camunda-connector-starter/pom.xml
+++ b/digiwf-connector/digiwf-camunda-connector-starter/pom.xml
@@ -62,18 +62,17 @@
${project.version}
-
-
- org.camunda.community
- camunda-engine-rest-client-openapi-springboot
- ${camunda-engine-rest-client-openapi-java.version}
-
-
org.camunda.bpm.springboot
camunda-bpm-spring-boot-starter-external-task-client
${camunda.version}
+
+
+ javax.xml.bind
+ jaxb-api
+ 2.4.0-b180830.0359
+
diff --git a/digiwf-connector/digiwf-camunda-connector-starter/src/main/java/de/muenchen/oss/digiwf/camunda/connector/configuration/DigiWFCamundaConnectorAutoConfiguration.java b/digiwf-connector/digiwf-camunda-connector-starter/src/main/java/de/muenchen/oss/digiwf/camunda/connector/configuration/DigiWFCamundaConnectorAutoConfiguration.java
index 3f0369d09b..dad58bc901 100644
--- a/digiwf-connector/digiwf-camunda-connector-starter/src/main/java/de/muenchen/oss/digiwf/camunda/connector/configuration/DigiWFCamundaConnectorAutoConfiguration.java
+++ b/digiwf-connector/digiwf-camunda-connector-starter/src/main/java/de/muenchen/oss/digiwf/camunda/connector/configuration/DigiWFCamundaConnectorAutoConfiguration.java
@@ -1,7 +1,7 @@
package de.muenchen.oss.digiwf.camunda.connector.configuration;
-import de.muenchen.oss.digiwf.camunda.connector.output.CamundaOutputClient;
import de.muenchen.oss.digiwf.camunda.connector.data.EngineDataSerializer;
+import de.muenchen.oss.digiwf.camunda.connector.output.CamundaOutputClient;
import de.muenchen.oss.digiwf.camunda.connector.output.CamundaOutputConfiguration;
import de.muenchen.oss.digiwf.connector.api.output.OutputService;
import de.muenchen.oss.digiwf.connector.output.internal.OutputServiceImpl;
diff --git a/digiwf-connector/digiwf-camunda-connector/pom.xml b/digiwf-connector/digiwf-camunda-connector/pom.xml
index 83d60e5ee0..52de0a2eb4 100644
--- a/digiwf-connector/digiwf-camunda-connector/pom.xml
+++ b/digiwf-connector/digiwf-camunda-connector/pom.xml
@@ -34,10 +34,19 @@
- org.camunda.community
- camunda-engine-rest-client-openapi-java
- ${camunda-engine-rest-client-openapi-java.version}
+ org.camunda.community.rest
+ camunda-platform-7-rest-client-spring-boot-starter
+ 7.20.0
+
+ org.springframework.cloud
+ spring-cloud-starter-openfeign
+
+
+ io.github.openfeign
+ feign-httpclient
+
+
org.camunda.bpm
camunda-external-task-client-spring
diff --git a/digiwf-connector/digiwf-camunda-connector/src/main/java/de/muenchen/oss/digiwf/camunda/connector/bpmnerror/BpmnErrorServiceImpl.java b/digiwf-connector/digiwf-camunda-connector/src/main/java/de/muenchen/oss/digiwf/camunda/connector/bpmnerror/BpmnErrorServiceImpl.java
index cfac9c2920..c9ccdbe90e 100644
--- a/digiwf-connector/digiwf-camunda-connector/src/main/java/de/muenchen/oss/digiwf/camunda/connector/bpmnerror/BpmnErrorServiceImpl.java
+++ b/digiwf-connector/digiwf-camunda-connector/src/main/java/de/muenchen/oss/digiwf/camunda/connector/bpmnerror/BpmnErrorServiceImpl.java
@@ -8,8 +8,7 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.camunda.community.rest.client.api.MessageApi;
-import org.camunda.community.rest.client.dto.CorrelationMessageDto;
-import org.camunda.community.rest.client.invoker.ApiException;
+import org.camunda.community.rest.client.model.CorrelationMessageDto;
import org.springframework.stereotype.Service;
@Slf4j
@@ -42,12 +41,7 @@ public void createBpmnError(final BpmnError bpmnError) {
correlationMessageDto.putProcessVariablesItem(VARIABLEKEY_ERROR_MESSAGE, this.serializer.toEngineData(bpmnError.getErrorMessage()));
}
- try {
- this.messageApi.deliverMessage(correlationMessageDto);
- } catch (final ApiException apiException) {
- log.error("Bpmn error could not be sent.", apiException);
- throw new RuntimeException(apiException);
- }
+ this.messageApi.deliverMessage(correlationMessageDto);
}
}
diff --git a/digiwf-connector/digiwf-camunda-connector/src/main/java/de/muenchen/oss/digiwf/camunda/connector/data/EngineDataSerializer.java b/digiwf-connector/digiwf-camunda-connector/src/main/java/de/muenchen/oss/digiwf/camunda/connector/data/EngineDataSerializer.java
index a4f976e41a..2e1de9bd9b 100644
--- a/digiwf-connector/digiwf-camunda-connector/src/main/java/de/muenchen/oss/digiwf/camunda/connector/data/EngineDataSerializer.java
+++ b/digiwf-connector/digiwf-camunda-connector/src/main/java/de/muenchen/oss/digiwf/camunda/connector/data/EngineDataSerializer.java
@@ -2,7 +2,7 @@
import org.camunda.bpm.engine.variable.VariableMap;
import org.camunda.bpm.engine.variable.value.TypedValue;
-import org.camunda.community.rest.client.dto.VariableValueDto;
+import org.camunda.community.rest.client.model.VariableValueDto;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.stereotype.Component;
@@ -58,6 +58,4 @@ private Object fromEngineData(final Object value) {
}
return new JSONObject(value.toString()).toMap();
}
-
-
}
diff --git a/digiwf-connector/digiwf-camunda-connector/src/main/java/de/muenchen/oss/digiwf/camunda/connector/incident/IncidentServiceImpl.java b/digiwf-connector/digiwf-camunda-connector/src/main/java/de/muenchen/oss/digiwf/camunda/connector/incident/IncidentServiceImpl.java
index b5ca23da24..c9b13ba2a2 100644
--- a/digiwf-connector/digiwf-camunda-connector/src/main/java/de/muenchen/oss/digiwf/camunda/connector/incident/IncidentServiceImpl.java
+++ b/digiwf-connector/digiwf-camunda-connector/src/main/java/de/muenchen/oss/digiwf/camunda/connector/incident/IncidentServiceImpl.java
@@ -6,12 +6,12 @@
import lombok.extern.slf4j.Slf4j;
import org.camunda.community.rest.client.api.EventSubscriptionApi;
import org.camunda.community.rest.client.api.ExecutionApi;
-import org.camunda.community.rest.client.dto.CreateIncidentDto;
-import org.camunda.community.rest.client.dto.EventSubscriptionDto;
-import org.camunda.community.rest.client.invoker.ApiException;
+import org.camunda.community.rest.client.model.CreateIncidentDto;
+import org.camunda.community.rest.client.model.EventSubscriptionDto;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
+import java.util.List;
import java.util.NoSuchElementException;
@Slf4j
@@ -34,21 +34,25 @@ public void createIncident(final String processInstanceId, final String messageN
Assert.notNull(messageName, "message name cannot be empty");
//load corresponding event subscription
- final String executionId = this.eventSubscriptionApi.getEventSubscriptions(
- null,
- messageName,
- EVENT_TYPE,
- null,
- processInstanceId,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null)
- .stream()
+ final List eventSubscriptions = this.eventSubscriptionApi.getEventSubscriptions(
+ null,
+ messageName,
+ EVENT_TYPE,
+ null,
+ processInstanceId,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null)
+ .getBody();
+ if (eventSubscriptions.isEmpty()) {
+ throw new NoSuchElementException();
+ }
+ final String executionId = eventSubscriptions.stream()
.findFirst()
.map(EventSubscriptionDto::getExecutionId)
.orElseThrow();
@@ -64,10 +68,6 @@ public void createIncident(final String processInstanceId, final String messageN
// send create incident call
this.executionApi.createIncident(executionId, createIncidentDto);
-
- } catch (final ApiException e) {
- log.error("Cannot create incident for processinstance id {} and message name {}: {}", processInstanceId, messageName, e.getResponseBody());
- throw new RuntimeException(e);
} catch (final NoSuchElementException | IllegalArgumentException e) {
log.error("Cannot create incident for processinstance id {} and message name {}", processInstanceId, messageName);
throw new RuntimeException(e);
diff --git a/digiwf-connector/digiwf-camunda-connector/src/main/java/de/muenchen/oss/digiwf/camunda/connector/message/MessageServiceImpl.java b/digiwf-connector/digiwf-camunda-connector/src/main/java/de/muenchen/oss/digiwf/camunda/connector/message/MessageServiceImpl.java
index 3a5e1c7975..92216f8743 100644
--- a/digiwf-connector/digiwf-camunda-connector/src/main/java/de/muenchen/oss/digiwf/camunda/connector/message/MessageServiceImpl.java
+++ b/digiwf-connector/digiwf-camunda-connector/src/main/java/de/muenchen/oss/digiwf/camunda/connector/message/MessageServiceImpl.java
@@ -8,9 +8,8 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.camunda.community.rest.client.api.MessageApi;
-import org.camunda.community.rest.client.dto.CorrelationMessageDto;
-import org.camunda.community.rest.client.dto.VariableValueDto;
-import org.camunda.community.rest.client.invoker.ApiException;
+import org.camunda.community.rest.client.model.CorrelationMessageDto;
+import org.camunda.community.rest.client.model.VariableValueDto;
import org.springframework.stereotype.Service;
import java.util.Map;
@@ -48,12 +47,7 @@ public void correlateMessage(final CorrelateMessage correlateMessage) {
correlationMessageDto.setBusinessKey(correlateMessage.getBusinessKey());
}
- try {
- this.messageApi.deliverMessage(correlationMessageDto);
- } catch (final ApiException apiException) {
- log.error("Message could not be sent.", apiException);
- throw new RuntimeException(apiException);
- }
+ this.messageApi.deliverMessage(correlationMessageDto);
}
}
diff --git a/digiwf-connector/digiwf-camunda-connector/src/test/java/de/muenchen/oss/digiwf/connector/BaseSpringTest.java b/digiwf-connector/digiwf-camunda-connector/src/test/java/de/muenchen/oss/digiwf/connector/BaseSpringTest.java
deleted file mode 100644
index 4dd99a13ef..0000000000
--- a/digiwf-connector/digiwf-camunda-connector/src/test/java/de/muenchen/oss/digiwf/connector/BaseSpringTest.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package de.muenchen.oss.digiwf.connector;
-
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.junit.jupiter.MockitoExtension;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit.jupiter.SpringExtension;
-
-@ExtendWith({SpringExtension.class, MockitoExtension.class})
-@ActiveProfiles(profiles = {"test"})
-public class BaseSpringTest {
-
-
-}
diff --git a/digiwf-connector/digiwf-camunda-connector/src/test/java/de/muenchen/oss/digiwf/connector/bpmnerror/BpmnErrorServiceTest.java b/digiwf-connector/digiwf-camunda-connector/src/test/java/de/muenchen/oss/digiwf/connector/bpmnerror/BpmnErrorServiceTest.java
index f8475b10a7..50f843e0dc 100644
--- a/digiwf-connector/digiwf-camunda-connector/src/test/java/de/muenchen/oss/digiwf/connector/bpmnerror/BpmnErrorServiceTest.java
+++ b/digiwf-connector/digiwf-camunda-connector/src/test/java/de/muenchen/oss/digiwf/connector/bpmnerror/BpmnErrorServiceTest.java
@@ -3,42 +3,34 @@
import de.muenchen.oss.digiwf.camunda.connector.bpmnerror.BpmnErrorServiceImpl;
import de.muenchen.oss.digiwf.camunda.connector.data.EngineDataSerializer;
-import de.muenchen.oss.digiwf.connector.bpmnerror.internal.impl.model.BpmnErrorImpl;
-import de.muenchen.oss.digiwf.connector.BaseSpringTest;
import de.muenchen.oss.digiwf.connector.api.bpmnerror.BpmnError;
import de.muenchen.oss.digiwf.connector.api.bpmnerror.BpmnErrorService;
+import de.muenchen.oss.digiwf.connector.bpmnerror.internal.impl.model.BpmnErrorImpl;
import org.camunda.community.rest.client.api.MessageApi;
-import org.camunda.community.rest.client.invoker.ApiException;
import org.junit.jupiter.api.*;
-import org.mockito.Mock;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Import;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@DisplayName("Bpmn error Service Test")
-@Import({EngineDataSerializer.class})
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
-public class BpmnErrorServiceTest extends BaseSpringTest {
+class BpmnErrorServiceTest {
+ private final MessageApi messageApi = mock(MessageApi.class);
- @Mock
- private MessageApi messageApi;
-
- @Autowired
- private EngineDataSerializer engineDataSerializer;
+ private final EngineDataSerializer engineDataSerializer = new EngineDataSerializer();
private BpmnErrorService bpmnErrorService;
@BeforeEach
- private void initTests() {
+ void initTests() {
this.bpmnErrorService = new BpmnErrorServiceImpl(this.messageApi, this.engineDataSerializer);
}
@Order(1)
@Test
@DisplayName("should correlate bpmn error")
- public void shouldCorrelateBpmnError() throws ApiException {
+ void shouldCorrelateBpmnError() {
final BpmnError bpmnError = BpmnErrorImpl.builder()
.messageName("myMessage")
@@ -51,5 +43,4 @@ public void shouldCorrelateBpmnError() throws ApiException {
verify(this.messageApi).deliverMessage(any());
}
-
}
diff --git a/digiwf-connector/digiwf-camunda-connector/src/test/java/de/muenchen/oss/digiwf/connector/incident/IncidentServiceTest.java b/digiwf-connector/digiwf-camunda-connector/src/test/java/de/muenchen/oss/digiwf/connector/incident/IncidentServiceTest.java
index 3135e34023..c08dd7b7f1 100644
--- a/digiwf-connector/digiwf-camunda-connector/src/test/java/de/muenchen/oss/digiwf/connector/incident/IncidentServiceTest.java
+++ b/digiwf-connector/digiwf-camunda-connector/src/test/java/de/muenchen/oss/digiwf/connector/incident/IncidentServiceTest.java
@@ -2,22 +2,22 @@
import de.muenchen.oss.digiwf.camunda.connector.incident.IncidentServiceImpl;
-import de.muenchen.oss.digiwf.connector.BaseSpringTest;
import de.muenchen.oss.digiwf.connector.api.incident.IncidentService;
import org.camunda.community.rest.client.api.EventSubscriptionApi;
import org.camunda.community.rest.client.api.ExecutionApi;
-import org.camunda.community.rest.client.dto.CreateIncidentDto;
-import org.camunda.community.rest.client.dto.EventSubscriptionDto;
-import org.camunda.community.rest.client.invoker.ApiException;
-import org.junit.jupiter.api.*;
+import org.camunda.community.rest.client.model.CreateIncidentDto;
+import org.camunda.community.rest.client.model.EventSubscriptionDto;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
import java.util.List;
import static org.mockito.Mockito.*;
@DisplayName("Incident Service Test")
-public class IncidentServiceTest {
-
+class IncidentServiceTest {
private final ExecutionApi executionApi = mock(ExecutionApi.class);
private final EventSubscriptionApi eventSubscriptionApi = mock(EventSubscriptionApi.class);
@@ -26,7 +26,7 @@ public class IncidentServiceTest {
@Test
@DisplayName("should create incident with default error message")
- public void shouldCreateIncidentWithDefaultErrorMessage() throws ApiException {
+ void shouldCreateIncidentWithDefaultErrorMessage() {
final EventSubscriptionDto eventSubscriptionDto = new EventSubscriptionDto();
eventSubscriptionDto.setExecutionId("executionId");
@@ -48,7 +48,7 @@ public void shouldCreateIncidentWithDefaultErrorMessage() throws ApiException {
null,
null,
null,
- null)).thenReturn(List.of(eventSubscriptionDto));
+ null)).thenReturn(new ResponseEntity>(List.of(eventSubscriptionDto), null, HttpStatus.OK));
this.incidentService.createIncident("instanceId", "messageName", null);
@@ -72,7 +72,7 @@ public void shouldCreateIncidentWithDefaultErrorMessage() throws ApiException {
@Test
@DisplayName("should create incident with default error message when message body is blank")
- public void shouldCreateIncidentWithDefaultErrorMessageWhenMessageBodyIsBlank() throws ApiException {
+ void shouldCreateIncidentWithDefaultErrorMessageWhenMessageBodyIsBlank() {
final EventSubscriptionDto eventSubscriptionDto = new EventSubscriptionDto();
eventSubscriptionDto.setExecutionId("executionId");
@@ -94,7 +94,7 @@ public void shouldCreateIncidentWithDefaultErrorMessageWhenMessageBodyIsBlank()
null,
null,
null,
- null)).thenReturn(List.of(eventSubscriptionDto));
+ null)).thenReturn(new ResponseEntity>(List.of(eventSubscriptionDto), null, HttpStatus.OK));
this.incidentService.createIncident("instanceId", "messageName", " ");
@@ -118,7 +118,7 @@ public void shouldCreateIncidentWithDefaultErrorMessageWhenMessageBodyIsBlank()
@Test
@DisplayName("should create incident with given error message")
- public void shouldCreateIncidentWithGivenErrorMessage() throws ApiException {
+ void shouldCreateIncidentWithGivenErrorMessage() {
final EventSubscriptionDto eventSubscriptionDto = new EventSubscriptionDto();
eventSubscriptionDto.setExecutionId("executionId");
@@ -140,7 +140,7 @@ public void shouldCreateIncidentWithGivenErrorMessage() throws ApiException {
null,
null,
null,
- null)).thenReturn(List.of(eventSubscriptionDto));
+ null)).thenReturn(new ResponseEntity>(List.of(eventSubscriptionDto), null, HttpStatus.OK));
this.incidentService.createIncident("instanceId", "messageName", "my-error-message");
diff --git a/digiwf-connector/digiwf-camunda-connector/src/test/java/de/muenchen/oss/digiwf/connector/message/MessageServiceTest.java b/digiwf-connector/digiwf-camunda-connector/src/test/java/de/muenchen/oss/digiwf/connector/message/MessageServiceTest.java
index aebef8424c..a5de4ef264 100644
--- a/digiwf-connector/digiwf-camunda-connector/src/test/java/de/muenchen/oss/digiwf/connector/message/MessageServiceTest.java
+++ b/digiwf-connector/digiwf-camunda-connector/src/test/java/de/muenchen/oss/digiwf/connector/message/MessageServiceTest.java
@@ -3,44 +3,36 @@
import de.muenchen.oss.digiwf.camunda.connector.data.EngineDataSerializer;
import de.muenchen.oss.digiwf.camunda.connector.message.MessageServiceImpl;
-import de.muenchen.oss.digiwf.connector.BaseSpringTest;
import de.muenchen.oss.digiwf.connector.api.message.CorrelateMessage;
import de.muenchen.oss.digiwf.connector.api.message.MessageService;
import de.muenchen.oss.digiwf.connector.message.internal.impl.model.CorrelateMessageImpl;
import org.camunda.community.rest.client.api.MessageApi;
-import org.camunda.community.rest.client.invoker.ApiException;
import org.junit.jupiter.api.*;
-import org.mockito.Mock;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Import;
import java.util.Map;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@DisplayName("Message Service Test")
-@Import({EngineDataSerializer.class})
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
-public class MessageServiceTest extends BaseSpringTest {
+class MessageServiceTest {
+ private final MessageApi messageApi = mock(MessageApi.class);
- @Mock
- private MessageApi messageApi;
-
- @Autowired
- private EngineDataSerializer engineDataSerializer;
+ private final EngineDataSerializer engineDataSerializer = new EngineDataSerializer();
private MessageService messageService;
@BeforeEach
- private void initTests() {
+ void initTests() {
this.messageService = new MessageServiceImpl(this.messageApi, this.engineDataSerializer);
}
@Order(1)
@Test
@DisplayName("should correlate message")
- public void shouldCorrelateMessage() throws ApiException {
+ void shouldCorrelateMessage() {
final CorrelateMessage correlateMessage = CorrelateMessageImpl.builder()
.messageName("myMessage")
@@ -54,5 +46,4 @@ public void shouldCorrelateMessage() throws ApiException {
verify(this.messageApi).deliverMessage(any());
}
-
}
diff --git a/digiwf-integrations/digiwf-email-integration/digiwf-email-integration-core/src/main/java/de/muenchen/oss/digiwf/email/integration/adapter/in/MessageProcessor.java b/digiwf-integrations/digiwf-email-integration/digiwf-email-integration-core/src/main/java/de/muenchen/oss/digiwf/email/integration/adapter/in/MessageProcessor.java
index f9b80e9056..f3c0c829b2 100644
--- a/digiwf-integrations/digiwf-email-integration/digiwf-email-integration-core/src/main/java/de/muenchen/oss/digiwf/email/integration/adapter/in/MessageProcessor.java
+++ b/digiwf-integrations/digiwf-email-integration/digiwf-email-integration-core/src/main/java/de/muenchen/oss/digiwf/email/integration/adapter/in/MessageProcessor.java
@@ -6,12 +6,10 @@
import de.muenchen.oss.digiwf.message.process.api.ErrorApi;
import de.muenchen.oss.digiwf.message.process.api.error.BpmnError;
import de.muenchen.oss.digiwf.message.process.api.error.IncidentError;
+import jakarta.validation.ValidationException;
import lombok.RequiredArgsConstructor;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
-import org.springframework.context.annotation.Bean;
import org.springframework.messaging.Message;
-import jakarta.validation.ValidationException;
import java.util.function.Consumer;
import static de.muenchen.oss.digiwf.message.common.MessageConstants.DIGIWF_MESSAGE_NAME;
@@ -24,8 +22,6 @@ public class MessageProcessor {
private final SendMail mailUseCase;
private final MonitoringService monitoringService;
- @ConditionalOnMissingBean
- @Bean
public Consumer> emailIntegration() {
return message -> {
try {
diff --git a/digiwf-integrations/digiwf-email-integration/digiwf-email-integration-example/src/main/resources/rest-api-client/example.http b/digiwf-integrations/digiwf-email-integration/digiwf-email-integration-example/src/main/resources/rest-api-client/example.http
index 31ff2d6c0f..87b7ccbb78 100644
--- a/digiwf-integrations/digiwf-email-integration/digiwf-email-integration-example/src/main/resources/rest-api-client/example.http
+++ b/digiwf-integrations/digiwf-email-integration/digiwf-email-integration-example/src/main/resources/rest-api-client/example.http
@@ -7,11 +7,7 @@ Content-Type: application/json
"subject": "Testing Email Integration",
"body": "This is a test email. You can delete it safely",
"attachments": [
- {
- "url": "http://127.0.0.1:9000/test/email-attachment-test/Workshop-LHM-%28MPDZ%29-20-07-2023.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=JCXDR004T558IUPC9VIX%2F20230828%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230828T070615Z&X-Amz-Expires=604800&X-Amz-Security-Token=eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3NLZXkiOiJKQ1hEUjAwNFQ1NThJVVBDOVZJWCIsImV4cCI6MTY5MzI0OTM3OSwicGFyZW50IjoibWluaW8ifQ.JMuUDc84vfXQOd191fcixiqeNApyMGsY2H3kBG-DGxu63HUFthwHTX7z6u1Esm0wyAjLodrNJvVQhE3rjPCVlw&X-Amz-SignedHeaders=host&versionId=null&X-Amz-Signature=4aaeab93df6fa39589752e4e691e06750c432610babc3e1edbfd7a49b3f34262",
- "path": "/test/email-attachment-test/Workshop-LHM-%28MPDZ%29-20-07-2023.pdf",
- "action": "GET"
- }
+
]
}
diff --git a/digiwf-integrations/digiwf-email-integration/digiwf-email-integration-service/src/main/resources/application.yml b/digiwf-integrations/digiwf-email-integration/digiwf-email-integration-service/src/main/resources/application.yml
index ccb97a60d7..ea297e8cd9 100644
--- a/digiwf-integrations/digiwf-email-integration/digiwf-email-integration-service/src/main/resources/application.yml
+++ b/digiwf-integrations/digiwf-email-integration/digiwf-email-integration-service/src/main/resources/application.yml
@@ -5,12 +5,9 @@ spring:
name: @project.artifactId@
cloud:
function:
- definition: functionRouter;sendMessage;
+ definition: functionRouter;sendMessage;sendMailFromEventBus;
routing-expression: "headers['type']"
stream:
- function:
- routing:
- enabled: 'true'
bindings:
functionRouter-in-0:
group: "dwf-email-service"