Compare commits
2 Commits
8342aedff4
...
9146b79b14
Author | SHA1 | Date | |
---|---|---|---|
|
9146b79b14 | ||
|
691c7efc82 |
@ -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<T extends UseCase<?>> {
|
||||
return new PathAssertion(path);
|
||||
}
|
||||
|
||||
protected void validate(
|
||||
protected void verify(
|
||||
final String title,
|
||||
final Supplier<UseCase.HttpResponse> http,
|
||||
final Consumer<UseCase.HttpResponse> assertion) {
|
||||
@ -208,7 +209,7 @@ public abstract class UseCase<T extends UseCase<?>> {
|
||||
}
|
||||
|
||||
public String uriEncoded(final String text) {
|
||||
return encode(ScenarioTest.resolve(text));
|
||||
return encode(ScenarioTest.resolve(text), StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
public static class JsonTemplate {
|
||||
|
@ -41,7 +41,7 @@ public class AddPhoneNumberToContactData extends UseCase<AddPhoneNumberToContact
|
||||
|
||||
@Override
|
||||
protected void verify() {
|
||||
validate(
|
||||
verify(
|
||||
"Verify if the New Phone Number Got Added",
|
||||
() -> httpGet("/api/hs/office/relations?relationType=PARTNER&personData=" + uriEncoded("%{partnerName}"))
|
||||
.expecting(OK).expecting(JSON).expectArrayElements(1),
|
||||
|
@ -40,7 +40,7 @@ public class RemovePhoneNumberFromContactData extends UseCase<RemovePhoneNumberF
|
||||
|
||||
@Override
|
||||
protected void verify() {
|
||||
validate(
|
||||
verify(
|
||||
"Verify if the New Phone Number Got Added",
|
||||
() -> httpGet("/api/hs/office/relations?relationType=PARTNER&personData=" + uriEncoded("%{partnerName}"))
|
||||
.expecting(OK).expecting(JSON).expectArrayElements(1),
|
||||
|
@ -54,7 +54,7 @@ public class ReplaceContactData extends UseCase<ReplaceContactData> {
|
||||
|
||||
@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),
|
||||
|
@ -65,4 +65,14 @@ public class AddRepresentativeToPartner extends UseCase<AddRepresentativeToPartn
|
||||
"""))
|
||||
.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}")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -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?
|
||||
);
|
||||
|
||||
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<CreatePartner> {
|
||||
"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<CreatePartner> {
|
||||
"""))
|
||||
.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}")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user