From 691c7efc825b8142f5b669fcc65279d4ee7d6801 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Mon, 4 Nov 2024 19:07:40 +0100 Subject: [PATCH] verify CreatePartner --- .../hsadminng/hs/office/scenarios/UseCase.java | 5 +++-- .../contact/AddPhoneNumberToContactData.java | 2 +- .../contact/RemovePhoneNumberFromContactData.java | 2 +- .../scenarios/contact/ReplaceContactData.java | 2 +- .../hs/office/scenarios/partner/CreatePartner.java | 14 ++++++++++++-- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/UseCase.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/UseCase.java index 2788c21c..8cbea0d6 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/UseCase.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/UseCase.java @@ -20,6 +20,7 @@ import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpRequest.BodyPublishers; import java.net.http.HttpResponse.BodyHandlers; +import java.nio.charset.StandardCharsets; import java.time.Duration; import java.util.Arrays; import java.util.LinkedHashMap; @@ -192,7 +193,7 @@ public abstract class UseCase> { return new PathAssertion(path); } - protected void validate( + protected void verify( final String title, final Supplier http, final Consumer assertion) { @@ -208,7 +209,7 @@ public abstract class UseCase> { } public String uriEncoded(final String text) { - return encode(ScenarioTest.resolve(text)); + return encode(ScenarioTest.resolve(text), StandardCharsets.UTF_8); } public static class JsonTemplate { diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/contact/AddPhoneNumberToContactData.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/contact/AddPhoneNumberToContactData.java index 0905cd4f..3e837195 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/contact/AddPhoneNumberToContactData.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/contact/AddPhoneNumberToContactData.java @@ -41,7 +41,7 @@ public class AddPhoneNumberToContactData extends UseCase httpGet("/api/hs/office/relations?relationType=PARTNER&personData=" + uriEncoded("%{partnerName}")) .expecting(OK).expecting(JSON).expectArrayElements(1), diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/contact/RemovePhoneNumberFromContactData.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/contact/RemovePhoneNumberFromContactData.java index 55ce710a..c499ee71 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/contact/RemovePhoneNumberFromContactData.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/contact/RemovePhoneNumberFromContactData.java @@ -40,7 +40,7 @@ public class RemovePhoneNumberFromContactData extends UseCase httpGet("/api/hs/office/relations?relationType=PARTNER&personData=" + uriEncoded("%{partnerName}")) .expecting(OK).expecting(JSON).expectArrayElements(1), diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/contact/ReplaceContactData.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/contact/ReplaceContactData.java index 300f5c1e..b4916dda 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/contact/ReplaceContactData.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/contact/ReplaceContactData.java @@ -54,7 +54,7 @@ public class ReplaceContactData extends UseCase { @Override protected void verify() { - validate( + verify( "Verify if the Contact-Relation Got Replaced in the Partner-Relation", () -> httpGet("/api/hs/office/relations?relationType=PARTNER&personData=" + uriEncoded("%{partnerName}")) .expecting(OK).expecting(JSON).expectArrayElements(1), diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/partner/CreatePartner.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/partner/CreatePartner.java index 47c302c8..eb13bd4a 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/partner/CreatePartner.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/partner/CreatePartner.java @@ -28,7 +28,7 @@ public class CreatePartner extends UseCase { "Even in production data we expect this query to return just a single result." // TODO.impl: add constraint? ); - obtain("Person: %{tradeName???%{givenName???} %{familyName???}}", () -> + obtain("Person: %{%{tradeName???}???%{givenName???} %{familyName???}}", () -> httpPost("/api/hs/office/persons", usingJsonBody(""" { "personType": ${personType???}, @@ -61,7 +61,7 @@ public class CreatePartner extends UseCase { "partnerNumber": ${partnerNumber}, "partnerRel": { "anchorUuid": ${Person: Hostsharing eG}, - "holderUuid": ${Person: %{tradeName???%{givenName???} %{familyName???}}}, + "holderUuid": ${Person: %{%{tradeName???}???%{givenName???} %{familyName???}}}, "contactUuid": ${Contact: %{contactCaption}} }, "details": { @@ -72,4 +72,14 @@ public class CreatePartner extends UseCase { """)) .expecting(HttpStatus.CREATED).expecting(ContentType.JSON); } + + @Override + protected void verify() { + verify( + "Verify the New Partner Relation", + () -> httpGet("/api/hs/office/relations?relationType=PARTNER&personData=" + uriEncoded("%{%{tradeName???}???%{givenName???} %{familyName???}}")) + .expecting(OK).expecting(JSON).expectArrayElements(1), + path("[0].contact.caption").contains("%{contactCaption}") + ); + } }