From 0b6912afafd5beff53916fd9d823e4075f0881e1 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 30 Oct 2024 11:29:54 +0100 Subject: [PATCH] explicitly fetch contact emailaddress in UnsubscribeFromMailinglist --- .../hs/office/scenarios/HsOfficeScenarioTests.java | 7 ++++--- .../subscription/UnsubscribeFromMailinglist.java | 13 ++++++++++++- 2 files changed, 16 insertions(+), 4 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 23ff1d5c..c3512b34 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 @@ -3,8 +3,8 @@ package net.hostsharing.hsadminng.hs.office.scenarios; import net.hostsharing.hsadminng.HsadminNgApplication; import net.hostsharing.hsadminng.hs.office.scenarios.debitor.CreateExternalDebitorForPartner; import net.hostsharing.hsadminng.hs.office.scenarios.debitor.CreateSelfDebitorForPartner; -import net.hostsharing.hsadminng.hs.office.scenarios.debitor.CreateSepaMandataForDebitor; -import net.hostsharing.hsadminng.hs.office.scenarios.debitor.DeleteSepaMandataForDebitor; +import net.hostsharing.hsadminng.hs.office.scenarios.debitor.CreateSepaMandateForDebitor; +import net.hostsharing.hsadminng.hs.office.scenarios.debitor.DeleteSepaMandateForDebitor; import net.hostsharing.hsadminng.hs.office.scenarios.debitor.DontDeleteDefaultDebitor; import net.hostsharing.hsadminng.hs.office.scenarios.debitor.InvalidateSepaMandateForDebitor; import net.hostsharing.hsadminng.hs.office.scenarios.membership.CreateMembership; @@ -233,7 +233,8 @@ class HsOfficeScenarioTests extends ScenarioTest { @Requires("Subscription: Michael Miller to operations-announce") void shouldUnsubscribeNewPersonAndContactToMailinglist() { new UnsubscribeFromMailinglist(this) - .given("subscriptionUuid", "%{Subscription: Michael Miller to operations-announce}") + .given("mailingList", "operations-announce") + .given("subscriberEMailAddress", "michael.miller@example.org") .doRun(); } } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/subscription/UnsubscribeFromMailinglist.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/subscription/UnsubscribeFromMailinglist.java index b0754161..6f059902 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/subscription/UnsubscribeFromMailinglist.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/subscription/UnsubscribeFromMailinglist.java @@ -3,7 +3,9 @@ package net.hostsharing.hsadminng.hs.office.scenarios.subscription; import net.hostsharing.hsadminng.hs.office.scenarios.UseCase; import net.hostsharing.hsadminng.hs.office.scenarios.ScenarioTest; +import static io.restassured.http.ContentType.JSON; import static org.springframework.http.HttpStatus.NO_CONTENT; +import static org.springframework.http.HttpStatus.OK; public class UnsubscribeFromMailinglist extends UseCase { @@ -14,7 +16,16 @@ public class UnsubscribeFromMailinglist extends UseCase + httpGet("/api/hs/office/relations?relationType=SUBSCRIBER" + + "&mark=" + uriEncoded("%{mailingList}") + + "&contactData=" + uriEncoded("%{subscriberEMailAddress}")) + .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." + ); + + return httpDelete("/api/hs/office/relations/" + uuid("Subscription: %{subscriberEMailAddress}")) .expecting(NO_CONTENT); } }