From 6051b9136243067f23de76df6f3df9dff979e838 Mon Sep 17 00:00:00 2001 From: "stephan.strehler" Date: Wed, 29 Nov 2023 17:07:31 +0100 Subject: [PATCH] #768: finished e2e tests --- .../in/streaming/MessageProcessor.java | 20 ++++++------ ...tRequest.java => OkEwoOmBasedRequest.java} | 4 +-- .../OkEwoIntegrationApplicationE2eTest.java | 31 ++++++++++--------- 3 files changed, 28 insertions(+), 27 deletions(-) rename digiwf-integrations/digiwf-okewo-integration/digiwf-okewo-integration-core/src/main/java/de/muenchen/oss/digiwf/okewo/integration/domain/model/request/{OkEwoEventRequest.java => OkEwoOmBasedRequest.java} (67%) diff --git a/digiwf-integrations/digiwf-okewo-integration/digiwf-okewo-integration-core/src/main/java/de/muenchen/oss/digiwf/okewo/integration/adapter/in/streaming/MessageProcessor.java b/digiwf-integrations/digiwf-okewo-integration/digiwf-okewo-integration-core/src/main/java/de/muenchen/oss/digiwf/okewo/integration/adapter/in/streaming/MessageProcessor.java index 60838569ae..5963b4c2cc 100644 --- a/digiwf-integrations/digiwf-okewo-integration/digiwf-okewo-integration-core/src/main/java/de/muenchen/oss/digiwf/okewo/integration/adapter/in/streaming/MessageProcessor.java +++ b/digiwf-integrations/digiwf-okewo-integration/digiwf-okewo-integration-core/src/main/java/de/muenchen/oss/digiwf/okewo/integration/adapter/in/streaming/MessageProcessor.java @@ -7,7 +7,7 @@ import de.muenchen.oss.digiwf.okewo.integration.application.in.SearchPersonInPort; import de.muenchen.oss.digiwf.okewo.integration.application.out.IntegrationOutPort; import de.muenchen.oss.digiwf.okewo.integration.client.model.*; -import de.muenchen.oss.digiwf.okewo.integration.domain.model.request.OkEwoEventRequest; +import de.muenchen.oss.digiwf.okewo.integration.domain.model.request.OkEwoOmBasedRequest; import de.muenchen.oss.digiwf.okewo.integration.domain.model.request.OkEwoSearchPersonExtendedRequest; import de.muenchen.oss.digiwf.okewo.integration.domain.model.request.OkEwoSearchPersonRequest; import de.muenchen.oss.digiwf.okewo.integration.domain.model.request.OrdnungsmerkmalDto; @@ -37,22 +37,21 @@ public class MessageProcessor { private final SearchPersonErweitertInPort searchPersonErweitertInPort; /** - * The Consumer expects an {@link OkEwoEventRequest} which represents an {@link OrdnungsmerkmalDto} for OK.EWO. + * The Consumer expects an {@link OkEwoOmBasedRequest} which represents an {@link OrdnungsmerkmalDto} for OK.EWO. *

* After successfully requesting OK.EWO a JSON representing a {@link Person} is returned. *

* In case of an error the error message is returned as a JSON representing {@link OkEwoErrorDto}. */ @Bean - public Consumer>>> getPerson() { + public Consumer> getPerson() { return message -> { log.debug("Processing new request \"getPerson\" from eventbus: {}", message); val payload = message.getPayload(); val headers = message.getHeaders(); val request = payload.getRequest(); - val om = request.get("ordnungsmerkmal"); try { - val response = getPersonInPort.getPerson(om); + val response = getPersonInPort.getPerson(request.getOrdnungsmerkmal()); Map result = Map.of(RESPONSE, response); integration.correlateProcessMessage(headers, result); } catch (Exception e) { @@ -63,7 +62,7 @@ public Consumer>>> getPerson() { } /** - * The Consumer expects a {@link OkEwoEventRequest} which represents the {@link SuchePersonAnfrage} for OK.EWO. + * The Consumer expects a {@link OkEwoOmBasedRequest} which represents the {@link SuchePersonAnfrage} for OK.EWO. *

* After successfully requesting OK.EWO a JSON representing a {@link SuchePersonAntwort} is returned. *

@@ -88,23 +87,22 @@ public Consumer> searchPerson() { /** - * The Consumer expects an {@link OkEwoEventRequest} which represents an {@link OrdnungsmerkmalDto} for OK.EWO. + * The Consumer expects an {@link OkEwoOmBasedRequest} which represents an {@link OrdnungsmerkmalDto} for OK.EWO. *

* After successfully requesting OK.EWO a JSON representing a {@link de.muenchen.oss.digiwf.okewo.integration.client.model.PersonErweitert} is returned. *

* In case of an error the error message is returned as a JSON representing {@link OkEwoErrorDto}. */ @Bean - public Consumer>>> getPersonErweitert() { + public Consumer> getPersonErweitert() { return message -> { log.debug("Processing new request \"getPersonErweitert\" from eventbus: {}", message); val payload = message.getPayload(); val headers = message.getHeaders(); val request = payload.getRequest(); - val om = request.get("ordnungsmerkmal"); try { - val response = getPersonErweitertInPort.getPerson(om); + val response = getPersonErweitertInPort.getPerson(request.getOrdnungsmerkmal()); Map result = Map.of(RESPONSE, response); integration.correlateProcessMessage(headers, result); } catch (Exception e) { @@ -115,7 +113,7 @@ public Consumer>>> getPersonErweit /** - * The Consumer expects a {@link OkEwoEventRequest} which represents the {@link SuchePersonerweitertAnfrage} for OK.EWO. + * The Consumer expects a {@link OkEwoOmBasedRequest} which represents the {@link SuchePersonerweitertAnfrage} for OK.EWO. *

* After successfully requesting OK.EWO a JSON representing a {@link SuchePersonerweitertAntwort} is returned. *

diff --git a/digiwf-integrations/digiwf-okewo-integration/digiwf-okewo-integration-core/src/main/java/de/muenchen/oss/digiwf/okewo/integration/domain/model/request/OkEwoEventRequest.java b/digiwf-integrations/digiwf-okewo-integration/digiwf-okewo-integration-core/src/main/java/de/muenchen/oss/digiwf/okewo/integration/domain/model/request/OkEwoOmBasedRequest.java similarity index 67% rename from digiwf-integrations/digiwf-okewo-integration/digiwf-okewo-integration-core/src/main/java/de/muenchen/oss/digiwf/okewo/integration/domain/model/request/OkEwoEventRequest.java rename to digiwf-integrations/digiwf-okewo-integration/digiwf-okewo-integration-core/src/main/java/de/muenchen/oss/digiwf/okewo/integration/domain/model/request/OkEwoOmBasedRequest.java index ecadd12cbe..8729315548 100644 --- a/digiwf-integrations/digiwf-okewo-integration/digiwf-okewo-integration-core/src/main/java/de/muenchen/oss/digiwf/okewo/integration/domain/model/request/OkEwoEventRequest.java +++ b/digiwf-integrations/digiwf-okewo-integration/digiwf-okewo-integration-core/src/main/java/de/muenchen/oss/digiwf/okewo/integration/domain/model/request/OkEwoOmBasedRequest.java @@ -3,11 +3,11 @@ import lombok.Data; @Data -public class OkEwoEventRequest { +public class OkEwoOmBasedRequest { /** * The payload to request OK.EWO. */ - private T request; + private OrdnungsmerkmalDto request; } diff --git a/digiwf-integrations/digiwf-okewo-integration/digiwf-okewo-integration-service/src/test/java/de/muenchen/oss/digiwf/okewo/integration/OkEwoIntegrationApplicationE2eTest.java b/digiwf-integrations/digiwf-okewo-integration/digiwf-okewo-integration-service/src/test/java/de/muenchen/oss/digiwf/okewo/integration/OkEwoIntegrationApplicationE2eTest.java index f18a314e16..1e4fc4c738 100644 --- a/digiwf-integrations/digiwf-okewo-integration/digiwf-okewo-integration-service/src/test/java/de/muenchen/oss/digiwf/okewo/integration/OkEwoIntegrationApplicationE2eTest.java +++ b/digiwf-integrations/digiwf-okewo-integration/digiwf-okewo-integration-service/src/test/java/de/muenchen/oss/digiwf/okewo/integration/OkEwoIntegrationApplicationE2eTest.java @@ -4,9 +4,10 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.github.tomakehurst.wiremock.client.WireMock; import com.github.tomakehurst.wiremock.junit5.WireMockTest; -import com.github.tomakehurst.wiremock.matching.ContentPattern; import de.muenchen.oss.digiwf.okewo.integration.client.model.*; -import de.muenchen.oss.digiwf.okewo.integration.domain.model.request.OkEwoEventRequest; +import de.muenchen.oss.digiwf.okewo.integration.domain.model.request.OkEwoOmBasedRequest; +import de.muenchen.oss.digiwf.okewo.integration.domain.model.request.OkEwoSearchPersonExtendedRequest; +import de.muenchen.oss.digiwf.okewo.integration.domain.model.request.OkEwoSearchPersonRequest; import de.muenchen.oss.digiwf.okewo.integration.domain.model.request.OrdnungsmerkmalDto; import de.muenchen.oss.digiwf.okewo.integration.utility.DigiWFIntegrationE2eTest; import lombok.val; @@ -59,11 +60,11 @@ public void shouldStart() { void shouldProcessGetPersonEvent() throws InterruptedException, JsonProcessingException { val ordnungsmerkmal = new OrdnungsmerkmalDto(); ordnungsmerkmal.setOrdnungsmerkmal("om"); - val request = new OkEwoEventRequest(); + val request = new OkEwoOmBasedRequest(); request.setRequest(ordnungsmerkmal); val person = new Person().ordnungsmerkmal("om"); - this.setupGetPathOfWiremock("/personen/2.0/rest/person/om?benutzerId=benutzerId", objectMapper.writeValueAsString(person)); + this.setupGetPathOfWiremock("/personen/2.0/rest/person/om?benutzerId=benutzerId", "username", "password", objectMapper.writeValueAsString(person)); // send and receive messages final Map payload = super.runIntegration(request, processInstanceId, "getPerson"); @@ -78,14 +79,14 @@ void shouldProcessGetPersonEvent() throws InterruptedException, JsonProcessingEx void shouldProcessSearchPersonEvent() throws InterruptedException, JsonProcessingException { val ordnungsmerkmal = new OrdnungsmerkmalDto(); ordnungsmerkmal.setOrdnungsmerkmal("om"); - val request = new OkEwoEventRequest(); + val request = new OkEwoSearchPersonRequest(); val searchRequest = new SuchePersonAnfrage(); searchRequest.setBenutzer(new BenutzerType().benutzerId("benutzerId")); request.setRequest(searchRequest); val person = new Person().ordnungsmerkmal("om"); val apiResponse = new SuchePersonAntwort().personen(List.of(person)); - this.setupPostPathOfWiremock("/personen/2.0/rest/person/search", objectMapper.writeValueAsString(searchRequest),objectMapper.writeValueAsString(apiResponse)); + this.setupPostPathOfWiremock("/personen/2.0/rest/person/search", objectMapper.writeValueAsString(searchRequest), "username", "password", objectMapper.writeValueAsString(apiResponse)); // send and receive messages final Map payload = super.runIntegration(request, processInstanceId, "searchPerson"); @@ -100,11 +101,11 @@ void shouldProcessSearchPersonEvent() throws InterruptedException, JsonProcessin void shouldProcessGetPersonErweitertEvent() throws InterruptedException, JsonProcessingException { val ordnungsmerkmal = new OrdnungsmerkmalDto(); ordnungsmerkmal.setOrdnungsmerkmal("om"); - val request = new OkEwoEventRequest(); + val request = new OkEwoOmBasedRequest(); request.setRequest(ordnungsmerkmal); val person = new PersonErweitert().ordnungsmerkmal("om"); - this.setupGetPathOfWiremock("/personen/2.0/rest/personErweitert/om?benutzerId=benutzerId", objectMapper.writeValueAsString(person)); + this.setupGetPathOfWiremock("/personen/2.0/rest/personErweitert/om?benutzerId=benutzerId", "username", "password", objectMapper.writeValueAsString(person)); // send and receive messages final Map payload = super.runIntegration(request, processInstanceId, "getPersonErweitert"); @@ -119,14 +120,14 @@ void shouldProcessGetPersonErweitertEvent() throws InterruptedException, JsonPro void shouldProcessSearchPersonErweitertEvent() throws InterruptedException, JsonProcessingException { val ordnungsmerkmal = new OrdnungsmerkmalDto(); ordnungsmerkmal.setOrdnungsmerkmal("om"); - val request = new OkEwoEventRequest(); + val request = new OkEwoSearchPersonExtendedRequest(); val searchRequest = new SuchePersonerweitertAnfrage(); searchRequest.setBenutzer(new BenutzerType().benutzerId("benutzerId")); request.setRequest(searchRequest); val person = new PersonErweitert().ordnungsmerkmal("om"); val apiResponse = new SuchePersonerweitertAntwort().personen(List.of(person)); - this.setupPostPathOfWiremock("/personen/2.0/rest/personErweitert/search", objectMapper.writeValueAsString(searchRequest),objectMapper.writeValueAsString(apiResponse)); + this.setupPostPathOfWiremock("/personen/2.0/rest/personErweitert/search", objectMapper.writeValueAsString(searchRequest), "username", "password", objectMapper.writeValueAsString(apiResponse)); // send and receive messages final Map payload = super.runIntegration(request, processInstanceId, "searchPersonErweitert"); @@ -137,20 +138,22 @@ void shouldProcessSearchPersonErweitertEvent() throws InterruptedException, Json assertEquals(1, personenResponse.size()); } - private void setupGetPathOfWiremock(final String url, final String expectedResponse) { + private void setupGetPathOfWiremock(final String url, final String username, final String password, final String expectedResponse) { WireMock.stubFor(WireMock .get(url) -// .withBasicAuth() + .withBasicAuth(username, password) .willReturn(WireMock .aResponse() .withBody(expectedResponse) .withHeader("Content-Type", "application/json") .withStatus(200))); } - private void setupPostPathOfWiremock(final String url, final String requestBody, final String expectedResponse) { + + private void setupPostPathOfWiremock(final String url, final String requestBody, final String username, final String password, final String expectedResponse) { WireMock.stubFor(WireMock .post(url) - .withRequestBody(equalToJson(requestBody)) + .withRequestBody(equalToJson(requestBody)) + .withBasicAuth(username, password) .willReturn(WireMock .aResponse() .withBody(expectedResponse)