query partner instead of re-using the @Required uuid

This commit is contained in:
Michael Hoennig 2024-11-13 10:03:33 +01:00
parent 9feef02a17
commit a8de7029e9

View File

@ -1,8 +1,8 @@
package net.hostsharing.hsadminng.hs.office.scenarios.membership; package net.hostsharing.hsadminng.hs.office.scenarios.membership;
import io.restassured.http.ContentType; import io.restassured.http.ContentType;
import net.hostsharing.hsadminng.hs.office.scenarios.UseCase;
import net.hostsharing.hsadminng.hs.office.scenarios.ScenarioTest; import net.hostsharing.hsadminng.hs.office.scenarios.ScenarioTest;
import net.hostsharing.hsadminng.hs.office.scenarios.UseCase;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import static io.restassured.http.ContentType.JSON; import static io.restassured.http.ContentType.JSON;
@ -16,11 +16,17 @@ public class CreateMembership extends UseCase<CreateMembership> {
@Override @Override
protected HttpResponse run() { protected HttpResponse run() {
// FIXME: httpGet "partner.uuid": ${Partner: Test AG}
obtain("Partner: %{partnerName}", () ->
httpGet("/api/hs/office/partners?name=&{partnerName}")
.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 httpPost("/api/hs/office/memberships", usingJsonBody(""" return httpPost("/api/hs/office/memberships", usingJsonBody("""
{ {
"partner.uuid": ${Partner: P-31010 - Test AG}, "partner.uuid": ${Partner: %{partnerName}},
"memberNumberSuffix": ${memberNumberSuffix}, "memberNumberSuffix": ${memberNumberSuffix},
"status": "ACTIVE", "status": "ACTIVE",
"validFrom": ${validFrom}, "validFrom": ${validFrom},