explicitly fetch Test AG in AddRepresentativeToPartner

This commit is contained in:
Michael Hoennig 2024-10-29 17:56:31 +01:00
parent 6b30d0f6f9
commit 31f5bcc5d8
3 changed files with 11 additions and 3 deletions

View File

@ -61,7 +61,7 @@ class HsOfficeScenarioTests extends ScenarioTest {
@Produces("Representative: Tracy Trust for Test AG") @Produces("Representative: Tracy Trust for Test AG")
void shouldAddRepresentativeToPartner() { void shouldAddRepresentativeToPartner() {
new AddRepresentativeToPartner(this) new AddRepresentativeToPartner(this)
.given("partnerPersonUuid", "%{Person: Test AG}") .given("partnerPersonTradeName", "Test AG")
.given("representativeFamilyName", "Trust") .given("representativeFamilyName", "Trust")
.given("representativeGivenName", "Tracy") .given("representativeGivenName", "Tracy")
.given("representativePostalAddress", """ .given("representativePostalAddress", """

View File

@ -39,7 +39,7 @@ public class TestReport {
final var outputWithCommentsForUuids = appendUUIDKey(output); final var outputWithCommentsForUuids = appendUUIDKey(output);
// for tests executed due to @Requires/@Produces there is no markdownFile yet // for tests executed due to @Requires/@Produces there is no markdownFile yet
if (silent == 0) { if (markdownReport != null && silent == 0) {
markdownReport.print(outputWithCommentsForUuids); markdownReport.print(outputWithCommentsForUuids);
} }

View File

@ -7,6 +7,7 @@ import org.springframework.http.HttpStatus;
import static io.restassured.http.ContentType.JSON; import static io.restassured.http.ContentType.JSON;
import static org.springframework.http.HttpStatus.CREATED; import static org.springframework.http.HttpStatus.CREATED;
import static org.springframework.http.HttpStatus.OK;
public class AddRepresentativeToPartner extends UseCase<AddRepresentativeToPartner> { public class AddRepresentativeToPartner extends UseCase<AddRepresentativeToPartner> {
@ -16,6 +17,13 @@ public class AddRepresentativeToPartner extends UseCase<AddRepresentativeToPartn
@Override @Override
protected HttpResponse run() { protected HttpResponse run() {
keep("Person: %{partnerPersonTradeName}", () ->
httpGet("/api/hs/office/persons?name=" + uriEncoded("%{partnerPersonTradeName}"))
.expecting(OK).expecting(JSON),
response -> response.expectArrayElements(1).getFromBody("[0].uuid")
);
keep("Person: %{representativeGivenName} %{representativeFamilyName}", () -> keep("Person: %{representativeGivenName} %{representativeFamilyName}", () ->
httpPost("/api/hs/office/persons", usingJsonBody(""" httpPost("/api/hs/office/persons", usingJsonBody("""
{ {
@ -49,7 +57,7 @@ public class AddRepresentativeToPartner extends UseCase<AddRepresentativeToPartn
return httpPost("/api/hs/office/relations", usingJsonBody(""" return httpPost("/api/hs/office/relations", usingJsonBody("""
{ {
"type": "REPRESENTATIVE", "type": "REPRESENTATIVE",
"anchorUuid": ${partnerPersonUuid}, "anchorUuid": ${Person: %{partnerPersonTradeName}},
"holderUuid": ${Person: %{representativeGivenName} %{representativeFamilyName}}, "holderUuid": ${Person: %{representativeGivenName} %{representativeFamilyName}},
"contactUuid": ${Contact: %{representativeGivenName} %{representativeFamilyName}} "contactUuid": ${Contact: %{representativeGivenName} %{representativeFamilyName}}
} }