Compare commits
No commits in common. "5605e8a8c1cd3bd5f6bc1b1594879a789db94c3a" and "876b3c526e1500bce2f038df9f6234badffe3bd7" have entirely different histories.
5605e8a8c1
...
876b3c526e
@ -1,47 +0,0 @@
|
|||||||
package net.hostsharing.hsadminng.reflection;
|
|
||||||
|
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
|
|
||||||
import java.lang.annotation.Annotation;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import static java.util.Optional.empty;
|
|
||||||
|
|
||||||
@UtilityClass
|
|
||||||
public class AnnotationFinder {
|
|
||||||
|
|
||||||
public static <T extends Annotation> Optional<T> findCallerAnnotation(
|
|
||||||
final Class<T> annotationClassToFind,
|
|
||||||
final Class<? extends Annotation> annotationClassToStopLookup
|
|
||||||
) {
|
|
||||||
for (var element : Thread.currentThread().getStackTrace()) {
|
|
||||||
try {
|
|
||||||
final var clazz = Class.forName(element.getClassName());
|
|
||||||
final var method = getMethodFromStackElement(clazz, element);
|
|
||||||
|
|
||||||
// Check if the method is annotated with the desired annotation
|
|
||||||
if (method != null) {
|
|
||||||
if (method.isAnnotationPresent(annotationClassToFind)) {
|
|
||||||
return Optional.of(method.getAnnotation(annotationClassToFind));
|
|
||||||
} else if (method.isAnnotationPresent(annotationClassToStopLookup)) {
|
|
||||||
return empty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (final ClassNotFoundException | NoSuchMethodException e) {
|
|
||||||
throw new RuntimeException(e); // FIXME: when does this happen?
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Method getMethodFromStackElement(Class<?> clazz, StackTraceElement element)
|
|
||||||
throws NoSuchMethodException {
|
|
||||||
for (var method : clazz.getDeclaredMethods()) {
|
|
||||||
if (method.getName().equals(element.getMethodName())) {
|
|
||||||
return method;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,9 +3,6 @@ package net.hostsharing.hsadminng.hs.office.usecases;
|
|||||||
import net.hostsharing.hsadminng.HsadminNgApplication;
|
import net.hostsharing.hsadminng.HsadminNgApplication;
|
||||||
import net.hostsharing.hsadminng.hs.office.usecases.debitor.CreateExternalDebitorForPartner;
|
import net.hostsharing.hsadminng.hs.office.usecases.debitor.CreateExternalDebitorForPartner;
|
||||||
import net.hostsharing.hsadminng.hs.office.usecases.debitor.CreateSelfDebitorForPartner;
|
import net.hostsharing.hsadminng.hs.office.usecases.debitor.CreateSelfDebitorForPartner;
|
||||||
import net.hostsharing.hsadminng.hs.office.usecases.debitor.CreateSepaMandataForDebitor;
|
|
||||||
import net.hostsharing.hsadminng.hs.office.usecases.debitor.DeleteSepaMandataForDebitor;
|
|
||||||
import net.hostsharing.hsadminng.hs.office.usecases.debitor.InvalidateSepaMandateForDebitor;
|
|
||||||
import net.hostsharing.hsadminng.hs.office.usecases.membership.CreateMembership;
|
import net.hostsharing.hsadminng.hs.office.usecases.membership.CreateMembership;
|
||||||
import net.hostsharing.hsadminng.hs.office.usecases.partner.CreatePartner;
|
import net.hostsharing.hsadminng.hs.office.usecases.partner.CreatePartner;
|
||||||
import net.hostsharing.hsadminng.hs.office.usecases.debitor.DeleteDebitor;
|
import net.hostsharing.hsadminng.hs.office.usecases.debitor.DeleteDebitor;
|
||||||
@ -30,7 +27,7 @@ class HsOfficeUseCasesTest extends UseCaseTest {
|
|||||||
@Order(1010)
|
@Order(1010)
|
||||||
@Produces(explicitly = "Partner: Test AG", implicitly = "Person: Test AG")
|
@Produces(explicitly = "Partner: Test AG", implicitly = "Person: Test AG")
|
||||||
void shouldCreatePartner() {
|
void shouldCreatePartner() {
|
||||||
new CreatePartner(this)
|
new CreatePartner(this, "Partner: Test AG")
|
||||||
.given("partnerNumber", 31010)
|
.given("partnerNumber", 31010)
|
||||||
.given("personType", "LEGAL_PERSON")
|
.given("personType", "LEGAL_PERSON")
|
||||||
.given("tradeName", "Test AG")
|
.given("tradeName", "Test AG")
|
||||||
@ -51,7 +48,6 @@ class HsOfficeUseCasesTest extends UseCaseTest {
|
|||||||
@Test
|
@Test
|
||||||
@Order(2010)
|
@Order(2010)
|
||||||
@Requires("Partner: Test AG")
|
@Requires("Partner: Test AG")
|
||||||
@Produces("Debitor: Test AG - main debitor")
|
|
||||||
void shouldCreateSelfDebitorForPartner() {
|
void shouldCreateSelfDebitorForPartner() {
|
||||||
new CreateSelfDebitorForPartner(this, "Debitor: Test AG - main debitor")
|
new CreateSelfDebitorForPartner(this, "Debitor: Test AG - main debitor")
|
||||||
.given("partnerPersonUuid", "%{Person: Test AG}")
|
.given("partnerPersonUuid", "%{Person: Test AG}")
|
||||||
@ -73,7 +69,7 @@ class HsOfficeUseCasesTest extends UseCaseTest {
|
|||||||
@Requires("Person: Test AG")
|
@Requires("Person: Test AG")
|
||||||
@Produces("Debitor: Billing GmbH")
|
@Produces("Debitor: Billing GmbH")
|
||||||
void shouldCreateExternalDebitorForPartner() {
|
void shouldCreateExternalDebitorForPartner() {
|
||||||
new CreateExternalDebitorForPartner(this)
|
new CreateExternalDebitorForPartner(this, "Debitor: Billing GmbH")
|
||||||
.given("partnerPersonUuid", "%{Person: Test AG}")
|
.given("partnerPersonUuid", "%{Person: Test AG}")
|
||||||
.given("billingContactCaption", "Billing GmbH - billing department")
|
.given("billingContactCaption", "Billing GmbH - billing department")
|
||||||
.given("billingContactEmailAddress", "billing@test-ag.example.org")
|
.given("billingContactEmailAddress", "billing@test-ag.example.org")
|
||||||
@ -98,39 +94,6 @@ class HsOfficeUseCasesTest extends UseCaseTest {
|
|||||||
.doRun();
|
.doRun();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
@Order(3100)
|
|
||||||
@Requires("Debitor: Test AG - main debitor")
|
|
||||||
@Produces("SEPA-Mandate: Test AG")
|
|
||||||
void shouldCreateSepaMandateForDebitor() {
|
|
||||||
new CreateSepaMandataForDebitor(this)
|
|
||||||
.given("debitor", "Test AG")
|
|
||||||
.given("memberNumberSuffix", "00")
|
|
||||||
.given("validFrom", "2024-10-15")
|
|
||||||
.given("membershipFeeBillable", "true")
|
|
||||||
.doRun()
|
|
||||||
.keep();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@Order(3108)
|
|
||||||
@Requires("SEPA-Mandate: Test AG")
|
|
||||||
void shouldInvalidateSepaMandateForDebitor() {
|
|
||||||
new InvalidateSepaMandateForDebitor(this)
|
|
||||||
.given("sepaMandateUuid", "%{SEPA-Mandate: Test AG}")
|
|
||||||
.given("validUntil", "2025-09-30")
|
|
||||||
.doRun();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@Order(3109)
|
|
||||||
@Requires("SEPA-Mandate: Test AG")
|
|
||||||
void shouldDeleteSepaMandateForDebitor() {
|
|
||||||
new DeleteSepaMandataForDebitor(this)
|
|
||||||
.given("sepaMandateUuid", "%{SEPA-Mandate: Test AG}")
|
|
||||||
.doRun();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(3000)
|
@Order(3000)
|
||||||
@Requires("Partner: Test AG")
|
@Requires("Partner: Test AG")
|
||||||
|
@ -4,11 +4,7 @@ import io.restassured.RestAssured;
|
|||||||
import io.restassured.http.ContentType;
|
import io.restassured.http.ContentType;
|
||||||
import io.restassured.response.Response;
|
import io.restassured.response.Response;
|
||||||
import io.restassured.response.ValidatableResponse;
|
import io.restassured.response.ValidatableResponse;
|
||||||
import net.hostsharing.hsadminng.reflection.AnnotationFinder;
|
|
||||||
import org.apache.commons.collections4.map.LinkedMap;
|
import org.apache.commons.collections4.map.LinkedMap;
|
||||||
import org.hibernate.AssertionFailure;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
|
||||||
@ -18,10 +14,7 @@ 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.Assertions.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.startsWith;
|
import static org.hamcrest.Matchers.startsWith;
|
||||||
import static org.junit.platform.commons.util.StringUtils.isBlank;
|
|
||||||
import static org.junit.platform.commons.util.StringUtils.isNotBlank;
|
|
||||||
|
|
||||||
public abstract class UseCase<T extends UseCase<?>> {
|
public abstract class UseCase<T extends UseCase<?>> {
|
||||||
|
|
||||||
@ -32,7 +25,7 @@ public abstract class UseCase<T extends UseCase<?>> {
|
|||||||
private String nextTitle; // FIXME: ugly
|
private String nextTitle; // FIXME: ugly
|
||||||
|
|
||||||
public UseCase(final UseCaseTest testSuite) {
|
public UseCase(final UseCaseTest testSuite) {
|
||||||
this(testSuite, getResultAliasFromProducesAnnotationInCallStack());
|
this(testSuite, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UseCase(final UseCaseTest testSuite, final String resultAlias) {
|
public UseCase(final UseCaseTest testSuite, final String resultAlias) {
|
||||||
@ -94,18 +87,6 @@ public abstract class UseCase<T extends UseCase<?>> {
|
|||||||
return new HttpResponse(HttpMethod.POST, uriPath, body, response);
|
return new HttpResponse(HttpMethod.POST, uriPath, body, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final HttpResponse httpPatch(final String uriPath, final JsonTemplate bodyJsonTemplate) {
|
|
||||||
final var body = bodyJsonTemplate.resolvePlaceholders();
|
|
||||||
final var uri = "http://localhost" + uriPath;
|
|
||||||
final var response = RestAssured.given()
|
|
||||||
.header("current-subject", UseCaseTest.RUN_AS_USER)
|
|
||||||
.contentType(ContentType.JSON)
|
|
||||||
.body(body)
|
|
||||||
.port(testSuite.port)
|
|
||||||
.when().patch(uri);
|
|
||||||
return new HttpResponse(HttpMethod.PATCH, uriPath, body, response);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final HttpResponse httpDelete(final String uriPath) {
|
public final HttpResponse httpDelete(final String uriPath) {
|
||||||
final var response = RestAssured.given()
|
final var response = RestAssured.given()
|
||||||
.header("current-subject", UseCaseTest.RUN_AS_USER)
|
.header("current-subject", UseCaseTest.RUN_AS_USER)
|
||||||
@ -118,7 +99,7 @@ public abstract class UseCase<T extends UseCase<?>> {
|
|||||||
return UseCaseTest.getAlias(alias).uuid();
|
return UseCaseTest.getAlias(alias).uuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class JsonTemplate {
|
static class JsonTemplate {
|
||||||
|
|
||||||
private final String template;
|
private final String template;
|
||||||
|
|
||||||
@ -179,10 +160,8 @@ public abstract class UseCase<T extends UseCase<?>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void keep() {
|
public void keep() {
|
||||||
final var alias = nextTitle != null ? nextTitle : resultAlias;
|
|
||||||
assertThat(alias).as("cannot keep result, no alias found").isNotNull();
|
|
||||||
UseCaseTest.putAlias(
|
UseCaseTest.putAlias(
|
||||||
alias,
|
nextTitle != null ? nextTitle : resultAlias,
|
||||||
new UseCaseTest.Alias<>(UseCase.this.getClass(), locationUuid));
|
new UseCaseTest.Alias<>(UseCase.this.getClass(), locationUuid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -195,19 +174,4 @@ public abstract class UseCase<T extends UseCase<?>> {
|
|||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
return (T) this;
|
return (T) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static @Nullable String getResultAliasFromProducesAnnotationInCallStack() {
|
|
||||||
return AnnotationFinder.findCallerAnnotation(Produces.class, Test.class)
|
|
||||||
.map(produces -> oneOf(produces.value(), produces.explicitly()))
|
|
||||||
.orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String oneOf(final String one, final String another) {
|
|
||||||
if (isNotBlank(one) && isBlank(another)) {
|
|
||||||
return one;
|
|
||||||
} else if ( isBlank(one) && isNotBlank(another)) {
|
|
||||||
return another;
|
|
||||||
}
|
|
||||||
throw new AssertionFailure("exactly one value required, but got '" + one + "' and '" + another + "'");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import net.hostsharing.hsadminng.lambda.Reducer;
|
|||||||
import net.hostsharing.hsadminng.rbac.context.ContextBasedTest;
|
import net.hostsharing.hsadminng.rbac.context.ContextBasedTest;
|
||||||
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
|
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
|
||||||
import org.apache.commons.collections4.SetUtils;
|
import org.apache.commons.collections4.SetUtils;
|
||||||
|
import org.hibernate.AssertionFailure;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Order;
|
import org.junit.jupiter.api.Order;
|
||||||
@ -18,12 +19,12 @@ import org.springframework.boot.test.web.server.LocalServerPort;
|
|||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -34,7 +35,6 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
public abstract class UseCaseTest extends ContextBasedTest {
|
public abstract class UseCaseTest extends ContextBasedTest {
|
||||||
|
|
||||||
final static String RUN_AS_USER = "superuser-alex@hostsharing.net"; // TODO.test: use global:AGENT when implemented
|
final static String RUN_AS_USER = "superuser-alex@hostsharing.net"; // TODO.test: use global:AGENT when implemented
|
||||||
//String producesAlias;
|
|
||||||
|
|
||||||
// @Getter
|
// @Getter
|
||||||
// public static TestInfo currentTestInfo;
|
// public static TestInfo currentTestInfo;
|
||||||
@ -60,7 +60,7 @@ public abstract class UseCaseTest extends ContextBasedTest {
|
|||||||
@BeforeEach
|
@BeforeEach
|
||||||
void init(final TestInfo testInfo) {
|
void init(final TestInfo testInfo) {
|
||||||
createHostsharingPerson();
|
createHostsharingPerson();
|
||||||
testInfo.getTestMethod().ifPresent(this::callRequiredProducers);
|
callRequiredProducers(testInfo);
|
||||||
createTestLogMarkdownFile(testInfo);
|
createTestLogMarkdownFile(testInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,37 +102,36 @@ public abstract class UseCaseTest extends ContextBasedTest {
|
|||||||
log("## Testcase " + testMethodName.replaceAll("([a-z])([A-Z]+)", "$1 $2"));
|
log("## Testcase " + testMethodName.replaceAll("([a-z])([A-Z]+)", "$1 $2"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
private void callRequiredProducers(final TestInfo testInfo) throws IllegalAccessException, InvocationTargetException {
|
||||||
private void callRequiredProducers(final Method currentTestMethod) {
|
final var testMethodRequired = testInfo.getTestMethod()
|
||||||
final var testMethodRequired = Optional.of(currentTestMethod)
|
|
||||||
.map(m -> m.getAnnotation(Requires.class))
|
.map(m -> m.getAnnotation(Requires.class))
|
||||||
.map(Requires::value)
|
.map(Requires::value)
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
if (testMethodRequired != null) {
|
if (testMethodRequired != null) {
|
||||||
for (Method potentialProducerMethod : getClass().getDeclaredMethods()) {
|
for (Method testMethod : getClass().getDeclaredMethods()) {
|
||||||
final var producesAnnot = potentialProducerMethod.getAnnotation(Produces.class);
|
final var producesAnnot = testMethod.getAnnotation(Produces.class);
|
||||||
if (producesAnnot != null) {
|
if (producesAnnot != null) {
|
||||||
final var testMethodProduces = allOf(
|
final var testMethodProduces = allOf(producesAnnot.value(), producesAnnot.explicitly(), producesAnnot.implicitly());
|
||||||
producesAnnot.value(),
|
|
||||||
producesAnnot.explicitly(),
|
|
||||||
producesAnnot.implicitly());
|
|
||||||
// @formatter:off
|
|
||||||
if ( // that method can produce something required
|
if ( // that method can produce something required
|
||||||
testMethodProduces.contains(testMethodRequired) &&
|
testMethodProduces.contains(testMethodRequired) &&
|
||||||
|
|
||||||
// and it does not produce anything we already have (would cause errors)
|
// and it does not produce anything we already have (would cause errors)
|
||||||
SetUtils.intersection(testMethodProduces, knowVariables().keySet()).isEmpty()
|
SetUtils.intersection(testMethodProduces, knowVariables().keySet()).isEmpty())
|
||||||
) {
|
|
||||||
// then we recursively produce the pre-requisites of the producer method
|
|
||||||
callRequiredProducers(potentialProducerMethod);
|
|
||||||
|
|
||||||
// and finally we call the producer method
|
// then we call the producer method
|
||||||
potentialProducerMethod.invoke(this);
|
testMethod.invoke(this);
|
||||||
}
|
|
||||||
// @formatter:on
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 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) {
|
||||||
@ -147,6 +146,15 @@ public abstract class UseCaseTest extends ContextBasedTest {
|
|||||||
return all;
|
return all;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String oneOf(final String one, final String another) {
|
||||||
|
if (one != null && another == null) {
|
||||||
|
return one;
|
||||||
|
} else if (one == null && another != null) {
|
||||||
|
return another;
|
||||||
|
}
|
||||||
|
throw new AssertionFailure("excactly one value required");
|
||||||
|
}
|
||||||
|
|
||||||
static boolean containsAlias(final String alias) {
|
static boolean containsAlias(final String alias) {
|
||||||
return aliases.containsKey(alias);
|
return aliases.containsKey(alias);
|
||||||
}
|
}
|
||||||
@ -167,6 +175,10 @@ public abstract class UseCaseTest extends ContextBasedTest {
|
|||||||
properties.put(name, (value instanceof String string) ? resolve(string) : value);
|
properties.put(name, (value instanceof String string) ? resolve(string) : value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static LinkedHashMap<String, Object> properties() {
|
||||||
|
return new LinkedHashMap<>(properties);
|
||||||
|
}
|
||||||
|
|
||||||
static Map<String, Object> knowVariables() {
|
static Map<String, Object> knowVariables() {
|
||||||
final var map = new LinkedHashMap<String, Object>();
|
final var map = new LinkedHashMap<String, Object>();
|
||||||
UseCaseTest.aliases.forEach((key, value) -> map.put(key, value.uuid()));
|
UseCaseTest.aliases.forEach((key, value) -> map.put(key, value.uuid()));
|
||||||
|
@ -9,8 +9,8 @@ import static org.springframework.http.HttpStatus.CREATED;
|
|||||||
|
|
||||||
public class CreateExternalDebitorForPartner extends UseCase<CreateExternalDebitorForPartner> {
|
public class CreateExternalDebitorForPartner extends UseCase<CreateExternalDebitorForPartner> {
|
||||||
|
|
||||||
public CreateExternalDebitorForPartner(final UseCaseTest testSuite) {
|
public CreateExternalDebitorForPartner(final UseCaseTest testSuite, final String resultAlias) {
|
||||||
super(testSuite);
|
super(testSuite, resultAlias);
|
||||||
|
|
||||||
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")
|
||||||
|
@ -1,39 +0,0 @@
|
|||||||
package net.hostsharing.hsadminng.hs.office.usecases.debitor;
|
|
||||||
|
|
||||||
import net.hostsharing.hsadminng.hs.office.usecases.UseCase;
|
|
||||||
import net.hostsharing.hsadminng.hs.office.usecases.UseCaseTest;
|
|
||||||
|
|
||||||
import static io.restassured.http.ContentType.JSON;
|
|
||||||
import static org.springframework.http.HttpStatus.CREATED;
|
|
||||||
|
|
||||||
public class CreateSepaMandataForDebitor extends UseCase<CreateSepaMandataForDebitor> {
|
|
||||||
|
|
||||||
public CreateSepaMandataForDebitor(final UseCaseTest testSuite) {
|
|
||||||
super(testSuite);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected HttpResponse run() {
|
|
||||||
keep("BankAccount: Test AG - debit bank account", () ->
|
|
||||||
httpPost("/api/hs/office/bankaccounts", usingJsonBody("""
|
|
||||||
{
|
|
||||||
"holder": "Test AG - debit bank account",
|
|
||||||
"iban": "DE02701500000000594937",
|
|
||||||
"bic": "SSKMDEMM"
|
|
||||||
}
|
|
||||||
"""))
|
|
||||||
.expecting(CREATED).expecting(JSON)
|
|
||||||
);
|
|
||||||
|
|
||||||
return httpPost("/api/hs/office/sepamandates", usingJsonBody("""
|
|
||||||
{
|
|
||||||
"debitorUuid": ${Debitor: Test AG - main debitor},
|
|
||||||
"bankAccountUuid": ${BankAccount: Test AG - debit bank account},
|
|
||||||
"reference": "Test AG - main debitor",
|
|
||||||
"agreement": "2022-10-12",
|
|
||||||
"validFrom": "2022-10-13"
|
|
||||||
}
|
|
||||||
"""))
|
|
||||||
.expecting(CREATED).expecting(JSON);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
package net.hostsharing.hsadminng.hs.office.usecases.debitor;
|
|
||||||
|
|
||||||
import net.hostsharing.hsadminng.hs.office.usecases.UseCase;
|
|
||||||
import net.hostsharing.hsadminng.hs.office.usecases.UseCaseTest;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
|
|
||||||
|
|
||||||
public class DeleteSepaMandataForDebitor extends UseCase<DeleteSepaMandataForDebitor> {
|
|
||||||
|
|
||||||
public DeleteSepaMandataForDebitor(final UseCaseTest testSuite) {
|
|
||||||
super(testSuite);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected HttpResponse run() {
|
|
||||||
httpDelete("/api/hs/office/sepamandates/" + uuid("SEPA-Mandate: Test AG"))
|
|
||||||
.expecting(HttpStatus.NO_CONTENT);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
package net.hostsharing.hsadminng.hs.office.usecases.debitor;
|
|
||||||
|
|
||||||
import net.hostsharing.hsadminng.hs.office.usecases.UseCase;
|
|
||||||
import net.hostsharing.hsadminng.hs.office.usecases.UseCaseTest;
|
|
||||||
|
|
||||||
import static io.restassured.http.ContentType.JSON;
|
|
||||||
import static org.springframework.http.HttpStatus.OK;
|
|
||||||
|
|
||||||
public class InvalidateSepaMandateForDebitor extends UseCase<InvalidateSepaMandateForDebitor> {
|
|
||||||
|
|
||||||
public InvalidateSepaMandateForDebitor(final UseCaseTest testSuite) {
|
|
||||||
super(testSuite);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected HttpResponse run() {
|
|
||||||
|
|
||||||
return httpPatch("/api/hs/office/sepamandates/" + uuid("SEPA-Mandate: Test AG"), usingJsonBody("""
|
|
||||||
{
|
|
||||||
"validUntil": ${validUntil}
|
|
||||||
}
|
|
||||||
"""))
|
|
||||||
.expecting(OK).expecting(JSON);
|
|
||||||
}
|
|
||||||
}
|
|
@ -11,10 +11,6 @@ public class CreatePartner extends UseCase<CreatePartner> {
|
|||||||
super(testSuite, resultAlias);
|
super(testSuite, resultAlias);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CreatePartner(final UseCaseTest testSuite) {
|
|
||||||
super(testSuite);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected HttpResponse run() {
|
protected HttpResponse run() {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user