From bc099ada40000096bcfd96db6e1517cdad290187 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 30 Oct 2024 07:22:08 +0100 Subject: [PATCH] explicitly fetch Dennis Krause in RemoveOperationsContactFromPartner --- .../hs/office/scenarios/HsOfficeScenarioTests.java | 2 +- .../hsadminng/hs/office/scenarios/ScenarioTest.java | 8 +++++--- .../RemoveOperationsContactFromPartner.java | 11 ++++++++++- 3 files changed, 16 insertions(+), 5 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 4c0f5732..fcd7cacb 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 @@ -94,7 +94,7 @@ class HsOfficeScenarioTests extends ScenarioTest { @Requires("Operations-Contact: Dennis Krause for Test AG") void shouldRemoveOperationsContactFromPartner() { new RemoveOperationsContactFromPartner(this) - .given("operationContactRelationUuid", "%{Operations-Contact: Dennis Krause for Test AG}") + .given("operationsContactPerson", "Dennis Krause") .doRun(); } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/ScenarioTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/ScenarioTest.java index 43c1e399..efc11c54 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/ScenarioTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/ScenarioTest.java @@ -68,6 +68,7 @@ public abstract class ScenarioTest extends ContextBasedTest { @AfterEach void cleanup() { // final TestInfo testInfo properties.clear(); + // FIXME: Delete all aliases as well to force HTTP GET queries in each scenario? testReport.close(); } @@ -137,9 +138,10 @@ public abstract class ScenarioTest extends ContextBasedTest { return aliases.containsKey(alias); } - static UUID uuid(final String name) { - final UUID alias = ofNullable(knowVariables().get(name)).filter(v -> v instanceof UUID).map(UUID.class::cast).orElse(null); - assertThat(alias).as("alias '" + name + "' not found in aliases nor in properties [" + + static UUID uuid(final String nameWithPlaceholders) { + final var resoledName = resolve(nameWithPlaceholders); + final UUID alias = ofNullable(knowVariables().get(resoledName)).filter(v -> v instanceof UUID).map(UUID.class::cast).orElse(null); + assertThat(alias).as("alias '" + resoledName + "' not found in aliases nor in properties [" + knowVariables().keySet().stream().map(v -> "'" + v + "'").collect(Collectors.joining(", ")) + "]" ).isNotNull(); return alias; diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/subscription/RemoveOperationsContactFromPartner.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/subscription/RemoveOperationsContactFromPartner.java index f11fcaac..f629aa01 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/subscription/RemoveOperationsContactFromPartner.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/subscription/RemoveOperationsContactFromPartner.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 RemoveOperationsContactFromPartner extends UseCase { @@ -14,7 +16,14 @@ public class RemoveOperationsContactFromPartner extends UseCase + httpGet("/api/hs/office/relations?relationType=OPERATIONS&name=" + uriEncoded("%{operationsContactPerson}")) + .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("Operations-Contact: %{operationsContactPerson}")) .expecting(NO_CONTENT); } }