Compare commits
2 Commits
a1e04508ed
...
4babea24a1
Author | SHA1 | Date | |
---|---|---|---|
|
4babea24a1 | ||
|
d525763fd9 |
@ -1,9 +1,11 @@
|
||||
package net.hostsharing.hsadminng.hs.office.usecases;
|
||||
|
||||
import net.hostsharing.hsadminng.HsadminNgApplication;
|
||||
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.membership.CreateMembership;
|
||||
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.partner.DeletePartner;
|
||||
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
@ -43,7 +45,7 @@ class HsOfficeUseCasesTest extends UseCaseTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2000)
|
||||
@Order(2010)
|
||||
void shouldCreateSelfDebitorForPartner() {
|
||||
new CreateSelfDebitorForPartner(this, "Debitor: Test AG - main debitor")
|
||||
.given("partnerPersonUuid", "%{Person: Test AG}")
|
||||
@ -60,6 +62,33 @@ class HsOfficeUseCasesTest extends UseCaseTest {
|
||||
.keep();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2011)
|
||||
void shouldCreateExternalDebitorForPartner() {
|
||||
new CreateExternalDebitorForPartner(this, "Debitor: Billing GmbH")
|
||||
.given("partnerPersonUuid", "%{Person: Test AG}")
|
||||
.given("billingContactCaption", "Billing GmbH - billing department")
|
||||
.given("billingContactEmailAddress", "billing@test-ag.example.org")
|
||||
.given("debitorNumberSuffix", "01")
|
||||
.given("billable", true)
|
||||
.given("vatId", "VAT123456")
|
||||
.given("vatCountryCode", "DE")
|
||||
.given("vatBusiness", true)
|
||||
.given("vatReverseCharge", false)
|
||||
.given("defaultPrefix", "tsx")
|
||||
.doRun()
|
||||
.keep();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2020)
|
||||
void shouldDeleteDebitor() {
|
||||
new DeleteDebitor(this)
|
||||
.given("partnerNumber", 31020)
|
||||
.given("debitorSuffix", "02")
|
||||
.doRun();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3000)
|
||||
void shouldCreateMembershipForPartner() {
|
||||
|
@ -9,6 +9,7 @@ import net.hostsharing.hsadminng.rbac.context.ContextBasedTest;
|
||||
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.TestInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.web.server.LocalServerPort;
|
||||
@ -67,7 +68,8 @@ public abstract class UseCaseTest extends ContextBasedTest {
|
||||
);
|
||||
|
||||
final var testMethodName = testInfo.getTestMethod().map(Method::getName).orElseThrow();
|
||||
markdownFile = new PrintWriter(new FileWriter(testMethodName + ".md"));
|
||||
final var testMethodOrder = testInfo.getTestMethod().map(m -> m.getAnnotation(Order.class).value()).orElseThrow();
|
||||
markdownFile = new PrintWriter(new FileWriter( testMethodOrder + "-" + testMethodName + ".md"));
|
||||
log("## Testcase " + testMethodName.replaceAll("([a-z])([A-Z]+)", "$1 $2"));
|
||||
currentTestInfo = testInfo; // FIXME: remove?
|
||||
}
|
||||
|
@ -0,0 +1,57 @@
|
||||
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 net.hostsharing.hsadminng.hs.office.usecases.person.CreatePerson;
|
||||
|
||||
import static io.restassured.http.ContentType.JSON;
|
||||
import static org.springframework.http.HttpStatus.CREATED;
|
||||
|
||||
public class CreateExternalDebitorForPartner extends UseCase<CreateExternalDebitorForPartner> {
|
||||
|
||||
public CreateExternalDebitorForPartner(final UseCaseTest testSuite, final String resultAlias) {
|
||||
super(testSuite, resultAlias);
|
||||
|
||||
requires("Person: Test AG");
|
||||
requires("Person: Billing GmbH", alias -> new CreatePerson(testSuite, alias)
|
||||
.given("personType", "LEGAL_PERSON")
|
||||
.given("tradeName", "Billing GmbH")
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected HttpResponse run() {
|
||||
|
||||
keep("Contact: Billing GmbH - Test AG billing", () ->
|
||||
httpPost("/api/hs/office/contacts", usingJsonBody("""
|
||||
{
|
||||
"caption": "Billing GmbH, billing for Test AG",
|
||||
"emailAddresses": {
|
||||
"main": "test-ag@billing-GmbH.example.com"
|
||||
}
|
||||
}
|
||||
"""))
|
||||
.expecting(CREATED).expecting(JSON)
|
||||
);
|
||||
|
||||
return httpPost("/api/hs/office/debitors", usingJsonBody("""
|
||||
{
|
||||
"debitorRel": {
|
||||
"type": "DEBITOR", // FIXME: should be defaulted to DEBITOR
|
||||
"anchorUuid": ${partnerPersonUuid},
|
||||
"holderUuid": ${Person: Billing GmbH},
|
||||
"contactUuid": ${Contact: Billing GmbH - Test AG billing}
|
||||
},
|
||||
"debitorNumberSuffix": ${debitorNumberSuffix},
|
||||
"billable": ${billable},
|
||||
"vatId": ${vatId},
|
||||
"vatCountryCode": ${vatCountryCode},
|
||||
"vatBusiness": ${vatBusiness},
|
||||
"vatReverseCharge": ${vatReverseCharge},
|
||||
"refundBankAccountUuid": ${BankAccount: Test AG - refund bank account},
|
||||
"defaultPrefix": ${defaultPrefix}
|
||||
}
|
||||
"""))
|
||||
.expecting(CREATED).expecting(JSON);
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
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 DeleteDebitor extends UseCase<DeleteDebitor> {
|
||||
|
||||
public DeleteDebitor(final UseCaseTest testSuite) {
|
||||
super(testSuite);
|
||||
|
||||
requires("Debitor: Test AG - delete debitor", alias -> new CreateSelfDebitorForPartner(testSuite, alias)
|
||||
.given("partnerPersonUuid", "%{Person: Test AG}")
|
||||
.given("billingContactCaption", "Test AG - billing department")
|
||||
.given("billingContactEmailAddress", "billing@test-ag.example.org")
|
||||
.given("debitorNumberSuffix", "%{debitorSuffix}")
|
||||
.given("billable", true)
|
||||
.given("vatId", "VAT123456")
|
||||
.given("vatCountryCode", "DE")
|
||||
.given("vatBusiness", true)
|
||||
.given("vatReverseCharge", false)
|
||||
.given("defaultPrefix", "tsy"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected HttpResponse run() {
|
||||
httpDelete("/api/hs/office/debitors/" + uuid("Debitor: Test AG - delete debitor"))
|
||||
.expecting(HttpStatus.NO_CONTENT);
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package net.hostsharing.hsadminng.hs.office.usecases.person;
|
||||
|
||||
import io.restassured.http.ContentType;
|
||||
import net.hostsharing.hsadminng.hs.office.usecases.UseCase;
|
||||
import net.hostsharing.hsadminng.hs.office.usecases.UseCaseTest;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
public class CreatePerson extends UseCase<CreatePerson> {
|
||||
|
||||
public CreatePerson(final UseCaseTest testSuite, final String resultAlias) {
|
||||
super(testSuite, resultAlias);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected HttpResponse run() {
|
||||
|
||||
return httpPost("/api/hs/office/persons", usingJsonBody("""
|
||||
{
|
||||
"personType": ${personType},
|
||||
"tradeName": ${tradeName}
|
||||
}
|
||||
"""))
|
||||
.expecting(HttpStatus.CREATED).expecting(ContentType.JSON);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user