explicitly fetch Test AG in CreateExternalDebitorForPartner

This commit is contained in:
Michael Hoennig 2024-10-30 09:46:42 +01:00
parent 47ba0cadb6
commit 619e5f288c
3 changed files with 17 additions and 3 deletions

View File

@ -132,7 +132,7 @@ class HsOfficeScenarioTests extends ScenarioTest {
@Produces("Debitor: Billing GmbH")
void shouldCreateExternalDebitorForPartner() {
new CreateExternalDebitorForPartner(this)
.given("partnerPersonUuid", "%{Person: Test AG}")
.given("partnerPersonTradeName", "Test AG")
.given("billingContactCaption", "Billing GmbH - billing department")
.given("billingContactEmailAddress", "billing@test-ag.example.org")
.given("debitorNumberSuffix", "01")

View File

@ -30,7 +30,8 @@ public class TestReport {
final var testMethodOrder = testInfo.getTestMethod().map(m -> m.getAnnotation(Order.class).value()).orElseThrow();
assertThat(new File("doc/scenarios/").isDirectory() || new File("doc/scenarios/").mkdirs()).as("mkdir doc/scenarios/").isTrue();
markdownReport = new PrintWriter(new FileWriter("doc/scenarios/" + testMethodOrder + "-" + testMethodName + ".md"));
print("## Scenario: " + testMethodName.replaceAll("([a-z])([A-Z]+)", "$1 $2"));
print("## Scenario #" + testInfo.getTestMethod().map(TestReport::orderNumber).orElseThrow() + ": " +
testMethodName.replaceAll("([a-z])([A-Z]+)", "$1 $2"));
}
@SneakyThrows
@ -59,6 +60,10 @@ public class TestReport {
markdownReport.close();
}
private static Object orderNumber(final Method method) {
return method.getAnnotation(Order.class).value();
}
private String appendUUIDKey(String multilineText) {
final var lines = multilineText.split("\\r?\\n");
final var result = new StringBuilder();

View File

@ -6,6 +6,7 @@ import net.hostsharing.hsadminng.hs.office.scenarios.person.CreatePerson;
import static io.restassured.http.ContentType.JSON;
import static org.springframework.http.HttpStatus.CREATED;
import static org.springframework.http.HttpStatus.OK;
public class CreateExternalDebitorForPartner extends UseCase<CreateExternalDebitorForPartner> {
@ -20,6 +21,14 @@ public class CreateExternalDebitorForPartner extends UseCase<CreateExternalDebit
@Override
protected HttpResponse run() {
obtain("Person: %{partnerPersonTradeName}", () ->
httpGet("/api/hs/office/persons?name=" + uriEncoded("%{partnerPersonTradeName}"))
.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."
);
obtain("BankAccount: Billing GmbH - refund bank account", () ->
httpPost("/api/hs/office/bankaccounts", usingJsonBody("""
{
@ -46,7 +55,7 @@ public class CreateExternalDebitorForPartner extends UseCase<CreateExternalDebit
return httpPost("/api/hs/office/debitors", usingJsonBody("""
{
"debitorRel": {
"anchorUuid": ${partnerPersonUuid},
"anchorUuid": ${Person: %{partnerPersonTradeName}},
"holderUuid": ${Person: Billing GmbH},
"contactUuid": ${Contact: Billing GmbH - Test AG billing}
},