get rid of requires method

This commit is contained in:
Michael Hoennig 2024-10-22 15:23:38 +02:00
parent 794d2f46dc
commit 876b3c526e
6 changed files with 17 additions and 18 deletions

View File

@ -99,7 +99,10 @@ class HsOfficeUseCasesTest extends UseCaseTest {
@Requires("Partner: Test AG") @Requires("Partner: Test AG")
void shouldCreateMembershipForPartner() { void shouldCreateMembershipForPartner() {
new CreateMembership(this) new CreateMembership(this)
.given("partnerName", "Test AG")
.given("memberNumberSuffix", "00")
.given("validFrom", "2024-10-15")
.given("membershipFeeBillable", "true")
.doRun(); .doRun();
} }
} }

View File

@ -14,7 +14,6 @@ import java.util.UUID;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.Supplier; import java.util.function.Supplier;
import static org.assertj.core.api.Assumptions.assumeThat;
import static org.hamcrest.Matchers.startsWith; import static org.hamcrest.Matchers.startsWith;
public abstract class UseCase<T extends UseCase<?>> { public abstract class UseCase<T extends UseCase<?>> {
@ -44,13 +43,6 @@ public abstract class UseCase<T extends UseCase<?>> {
} }
} }
public void requires(final String alias) {
assumeThat(UseCaseTest.containsAlias(alias))
.as("skipping because alias '" + alias + "' not found, @Produces(...) missing?")
.isTrue();
log("depends on [" + alias + "](" + UseCaseTest.getAlias(alias).useCase().getSimpleName() + ".md)");
}
public final HttpResponse doRun() { public final HttpResponse doRun() {
log("### Given Properties\n"); log("### Given Properties\n");
log(""" log("""

View File

@ -123,6 +123,15 @@ public abstract class UseCaseTest extends ContextBasedTest {
} }
} }
} }
// public void requires(final String alias) {
// assumeThat(UseCaseTest.containsAlias(alias))
// .as("skipping because alias '" + alias + "' not found, @Produces(...) missing?")
// .isTrue();
// log("depends on [" + alias + "](" + UseCaseTest.getAlias(alias).useCase().getSimpleName() + ".md)");
// }
} }
private Set<String> allOf(final String value, final String explicitly, final String[] implicitly) { private Set<String> allOf(final String value, final String explicitly, final String[] implicitly) {

View File

@ -12,7 +12,6 @@ public class CreateExternalDebitorForPartner extends UseCase<CreateExternalDebit
public CreateExternalDebitorForPartner(final UseCaseTest testSuite, final String resultAlias) { public CreateExternalDebitorForPartner(final UseCaseTest testSuite, final String resultAlias) {
super(testSuite, resultAlias); super(testSuite, resultAlias);
requires("Person: Test AG");
requires("Person: Billing GmbH", alias -> new CreatePerson(testSuite, alias) requires("Person: Billing GmbH", alias -> new CreatePerson(testSuite, alias)
.given("personType", "LEGAL_PERSON") .given("personType", "LEGAL_PERSON")
.given("tradeName", "Billing GmbH") .given("tradeName", "Billing GmbH")

View File

@ -10,8 +10,6 @@ public class CreateSelfDebitorForPartner extends UseCase<CreateSelfDebitorForPar
public CreateSelfDebitorForPartner(final UseCaseTest testSuite, final String resultAlias) { public CreateSelfDebitorForPartner(final UseCaseTest testSuite, final String resultAlias) {
super(testSuite, resultAlias); super(testSuite, resultAlias);
requires("Person: Test AG");
} }
@Override @Override

View File

@ -9,19 +9,17 @@ public class CreateMembership extends UseCase<CreateMembership> {
public CreateMembership(final UseCaseTest testSuite) { public CreateMembership(final UseCaseTest testSuite) {
super(testSuite); super(testSuite);
requires("Partner: Test AG");
} }
@Override @Override
protected HttpResponse run() { protected HttpResponse run() {
keep("Membership: Test AG 00", () -> keep("Membership: %{partnerName} 00", () ->
httpPost("/api/hs/office/memberships", usingJsonBody(""" httpPost("/api/hs/office/memberships", usingJsonBody("""
{ {
"partnerUuid": ${Partner: Test AG}, "partnerUuid": ${Partner: Test AG},
"memberNumberSuffix": "00", "memberNumberSuffix": ${memberNumberSuffix},
"validFrom": "2024-10-15", "validFrom": ${validFrom},
"membershipFeeBillable": "true" "membershipFeeBillable": ${membershipFeeBillable}
} }
""")) """))
.expecting(HttpStatus.CREATED).expecting(ContentType.JSON) .expecting(HttpStatus.CREATED).expecting(ContentType.JSON)