Compare commits

..

No commits in common. "9146b79b14cdd47de9d64714cda3bfc48554d977" and "8342aedff4da5bd6e90d476cd02c51ca6d39da16" have entirely different histories.

6 changed files with 7 additions and 28 deletions

View File

@ -20,7 +20,6 @@ import java.net.http.HttpClient;
import java.net.http.HttpRequest; import java.net.http.HttpRequest;
import java.net.http.HttpRequest.BodyPublishers; import java.net.http.HttpRequest.BodyPublishers;
import java.net.http.HttpResponse.BodyHandlers; import java.net.http.HttpResponse.BodyHandlers;
import java.nio.charset.StandardCharsets;
import java.time.Duration; import java.time.Duration;
import java.util.Arrays; import java.util.Arrays;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@ -193,7 +192,7 @@ public abstract class UseCase<T extends UseCase<?>> {
return new PathAssertion(path); return new PathAssertion(path);
} }
protected void verify( protected void validate(
final String title, final String title,
final Supplier<UseCase.HttpResponse> http, final Supplier<UseCase.HttpResponse> http,
final Consumer<UseCase.HttpResponse> assertion) { final Consumer<UseCase.HttpResponse> assertion) {
@ -209,7 +208,7 @@ public abstract class UseCase<T extends UseCase<?>> {
} }
public String uriEncoded(final String text) { public String uriEncoded(final String text) {
return encode(ScenarioTest.resolve(text), StandardCharsets.UTF_8); return encode(ScenarioTest.resolve(text));
} }
public static class JsonTemplate { public static class JsonTemplate {

View File

@ -41,7 +41,7 @@ public class AddPhoneNumberToContactData extends UseCase<AddPhoneNumberToContact
@Override @Override
protected void verify() { protected void verify() {
verify( validate(
"Verify if the New Phone Number Got Added", "Verify if the New Phone Number Got Added",
() -> httpGet("/api/hs/office/relations?relationType=PARTNER&personData=" + uriEncoded("%{partnerName}")) () -> httpGet("/api/hs/office/relations?relationType=PARTNER&personData=" + uriEncoded("%{partnerName}"))
.expecting(OK).expecting(JSON).expectArrayElements(1), .expecting(OK).expecting(JSON).expectArrayElements(1),

View File

@ -40,7 +40,7 @@ public class RemovePhoneNumberFromContactData extends UseCase<RemovePhoneNumberF
@Override @Override
protected void verify() { protected void verify() {
verify( validate(
"Verify if the New Phone Number Got Added", "Verify if the New Phone Number Got Added",
() -> httpGet("/api/hs/office/relations?relationType=PARTNER&personData=" + uriEncoded("%{partnerName}")) () -> httpGet("/api/hs/office/relations?relationType=PARTNER&personData=" + uriEncoded("%{partnerName}"))
.expecting(OK).expecting(JSON).expectArrayElements(1), .expecting(OK).expecting(JSON).expectArrayElements(1),

View File

@ -54,7 +54,7 @@ public class ReplaceContactData extends UseCase<ReplaceContactData> {
@Override @Override
protected void verify() { protected void verify() {
verify( validate(
"Verify if the Contact-Relation Got Replaced in the Partner-Relation", "Verify if the Contact-Relation Got Replaced in the Partner-Relation",
() -> httpGet("/api/hs/office/relations?relationType=PARTNER&personData=" + uriEncoded("%{partnerName}")) () -> httpGet("/api/hs/office/relations?relationType=PARTNER&personData=" + uriEncoded("%{partnerName}"))
.expecting(OK).expecting(JSON).expectArrayElements(1), .expecting(OK).expecting(JSON).expectArrayElements(1),

View File

@ -65,14 +65,4 @@ public class AddRepresentativeToPartner extends UseCase<AddRepresentativeToPartn
""")) """))
.expecting(CREATED).expecting(JSON); .expecting(CREATED).expecting(JSON);
} }
@Override
protected void verify() {
verify(
"Verify the New REPRESENTATIVE Relation",
() -> httpGet("/api/hs/office/relations?relationType=REPRESENTATIVE&personData=" + uriEncoded("%{representativeFamilyName}"))
.expecting(OK).expecting(JSON).expectArrayElements(1),
path("[0].contact.caption").contains("%{representativeGivenName} %{representativeFamilyName}")
);
}
} }

View File

@ -28,7 +28,7 @@ public class CreatePartner extends UseCase<CreatePartner> {
"Even in production data we expect this query to return just a single result." // TODO.impl: add constraint? "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(""" httpPost("/api/hs/office/persons", usingJsonBody("""
{ {
"personType": ${personType???}, "personType": ${personType???},
@ -61,7 +61,7 @@ public class CreatePartner extends UseCase<CreatePartner> {
"partnerNumber": ${partnerNumber}, "partnerNumber": ${partnerNumber},
"partnerRel": { "partnerRel": {
"anchorUuid": ${Person: Hostsharing eG}, "anchorUuid": ${Person: Hostsharing eG},
"holderUuid": ${Person: %{%{tradeName???}???%{givenName???} %{familyName???}}}, "holderUuid": ${Person: %{tradeName???%{givenName???} %{familyName???}}},
"contactUuid": ${Contact: %{contactCaption}} "contactUuid": ${Contact: %{contactCaption}}
}, },
"details": { "details": {
@ -72,14 +72,4 @@ public class CreatePartner extends UseCase<CreatePartner> {
""")) """))
.expecting(HttpStatus.CREATED).expecting(ContentType.JSON); .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}")
);
}
} }