From 84a0799065102a882325c3a5ca266c40f471ecdb Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 30 Oct 2024 09:50:10 +0100 Subject: [PATCH] explicitly fetch Test AG in SubscribeToMailinglist --- .../hs/office/scenarios/HsOfficeScenarioTests.java | 2 +- .../subscription/SubscribeToMailinglist.java | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java index 2ec80c6a..23ff1d5c 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/HsOfficeScenarioTests.java @@ -219,7 +219,7 @@ class HsOfficeScenarioTests extends ScenarioTest { void shouldSubscribeNewPersonAndContactToMailinglist() { new SubscribeToMailinglist(this) // TODO.spec: do we need the personType? or is an operational contact always a natural person? what about distribution lists? - .given("partnerPersonUuid", "%{Person: Test AG}") + .given("partnerPersonTradeName", "Test AG") .given("subscriberFamilyName", "Miller") .given("subscriberGivenName", "Michael") .given("subscriberEMailAddress", "michael.miller@example.org") diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/subscription/SubscribeToMailinglist.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/subscription/SubscribeToMailinglist.java index ecf22305..3c84603f 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/subscription/SubscribeToMailinglist.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/subscription/SubscribeToMailinglist.java @@ -7,6 +7,7 @@ import org.springframework.http.HttpStatus; import static io.restassured.http.ContentType.JSON; import static org.springframework.http.HttpStatus.CREATED; +import static org.springframework.http.HttpStatus.OK; public class SubscribeToMailinglist extends UseCase { @@ -16,6 +17,14 @@ public class SubscribeToMailinglist extends UseCase { @Override protected HttpResponse run() { + + obtain("Person: %{partnerPersonTradeName}", () -> + httpGet("/api/hs/office/persons?name=" + uriEncoded("%{partnerPersonTradeName}")) + .expecting(OK).expecting(JSON), + response -> response.expectArrayElements(1).getFromBody("[0].uuid"), + "In production data this query could result in multiple outputs. In that case, you have to find out which is the right one." + ); + obtain("Person: %{subscriberGivenName} %{subscriberFamilyName}", () -> httpPost("/api/hs/office/persons", usingJsonBody(""" { @@ -43,7 +52,7 @@ public class SubscribeToMailinglist extends UseCase { { "type": "SUBSCRIBER", "mark": ${mailingList}, - "anchorUuid": ${partnerPersonUuid}, + "anchorUuid": ${Person: %{partnerPersonTradeName}}, "holderUuid": ${Person: %{subscriberGivenName} %{subscriberFamilyName}}, "contactUuid": ${Contact: %{subscriberGivenName} %{subscriberFamilyName}} }