1
0

add HsOfficeBankAccount*

This commit is contained in:
Michael Hoennig
2022-10-04 19:09:37 +02:00
parent c3195662dd
commit a93143ff00
19 changed files with 1301 additions and 4 deletions

View File

@@ -69,6 +69,16 @@ public class ArchitectureTest {
.should().onlyBeAccessed().byClassesThat()
.resideInAnyPackage("..hs.office.(*)..");
// TODO.test: rule to check if all packages have rules
// TODO.test: rules for contact, person, ...
@ArchTest
@SuppressWarnings("unused")
public static final ArchRule HsOfficeBankAccountPackageRule = classes()
.that().resideInAPackage("..hs.office.bankaccount..")
.should().onlyBeAccessed().byClassesThat()
.resideInAnyPackage("..hs.office.bankaccount..", "..hs.office.debitor..");
@ArchTest
@SuppressWarnings("unused")
public static final ArchRule HsOfficePartnerPackageRule = classes()
@@ -76,6 +86,7 @@ public class ArchitectureTest {
.should().onlyBeAccessed().byClassesThat()
.resideInAnyPackage("..hs.office.partner..", "..hs.office.debitor..");
@ArchTest
@SuppressWarnings("unused")
public static final ArchRule acceptsAnnotationOnMethodsRule = methods()

View File

@@ -0,0 +1,357 @@
package net.hostsharing.hsadminng.hs.office.bankaccount;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import net.hostsharing.hsadminng.Accepts;
import net.hostsharing.hsadminng.HsadminNgApplication;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.test.JpaAttempt;
import org.apache.commons.lang3.RandomStringUtils;
import org.json.JSONException;
import org.junit.jupiter.api.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import static net.hostsharing.test.IsValidUuidMatcher.isUuidValid;
import static net.hostsharing.test.JsonMatcher.lenientlyEquals;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.startsWith;
@SpringBootTest(
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
classes = { HsadminNgApplication.class, JpaAttempt.class }
)
@Transactional
class HsOfficeBankAccountControllerAcceptanceTest {
@LocalServerPort
private Integer port;
@Autowired
Context context;
@Autowired
Context contextMock;
@Autowired
HsOfficeBankAccountRepository bankAccountRepo;
@Autowired
JpaAttempt jpaAttempt;
Set<UUID> tempBankAccountUuids = new HashSet<>();
@Nested
@Accepts({ "bankaccount:F(Find)" })
class ListBankAccounts {
@Test
void globalAdmin_withoutAssumedRoles_canViewAllBankAaccounts_ifNoCriteriaGiven() throws JSONException {
RestAssured // @formatter:off
.given()
.header("current-user", "superuser-alex@hostsharing.net")
.port(port)
.when()
.get("http://localhost/api/hs/office/bankaccounts")
.then().log().all().assertThat()
.statusCode(200)
.contentType("application/json")
.body("", lenientlyEquals("""
[
{
"holder": "Anita Bessler",
"iban": "DE02300606010002474689",
"bic": "DAAEDEDD"
},
{
"holder": "First GmbH",
"iban": "DE02120300000000202051",
"bic": "BYLADEM1001"
},
{
"holder": "Fourth e.G.",
"iban": "DE02200505501015871393",
"bic": "HASPDEHH"
},
{
"holder": "Mel Bessler",
"iban": "DE02100100100006820101",
"bic": "PBNKDEFF"
},
{
"holder": "Paul Winkler",
"iban": "DE02600501010002034304",
"bic": "SOLADEST600"
},
{
"holder": "Peter Smith",
"iban": "DE02500105170137075030",
"bic": "INGDDEFF"
},
{
"holder": "Second e.K.",
"iban": "DE02100500000054540402",
"bic": "BELADEBE"
},
{
"holder": "Third OHG",
"iban": "DE02300209000106531065",
"bic": "CMCIDEDD"
}
]
"""
));
// @formatter:on
}
}
@Nested
@Accepts({ "bankaccount:C(Create)" })
class AddBankAccount {
@Test
void globalAdmin_withoutAssumedRole_canAddBankAccount() {
context.define("superuser-alex@hostsharing.net");
final var location = RestAssured // @formatter:off
.given()
.header("current-user", "superuser-alex@hostsharing.net")
.contentType(ContentType.JSON)
.body("""
{
"holder": "new test holder",
"iban": "DE88100900001234567892",
"bic": "BEVODEBB"
}
""")
.port(port)
.when()
.post("http://localhost/api/hs/office/bankaccounts")
.then().assertThat()
.statusCode(201)
.contentType(ContentType.JSON)
.body("uuid", isUuidValid())
.body("holder", is("new test holder"))
.body("iban", is("DE88100900001234567892"))
.body("bic", is("BEVODEBB"))
.header("Location", startsWith("http://localhost"))
.extract().header("Location"); // @formatter:on
// finally, the new bankaccount can be accessed under the generated UUID
final var newUserUuid = toCleanup(UUID.fromString(
location.substring(location.lastIndexOf('/') + 1)));
assertThat(newUserUuid).isNotNull();
}
}
@Nested
@Accepts({ "bankaccount:R(Read)" })
class GetBankAccount {
@Test
void globalAdmin_withoutAssumedRole_canGetArbitraryBankAccount() {
context.define("superuser-alex@hostsharing.net");
final var givenBankAccountUuid = bankAccountRepo.findByOptionalHolderLike("first").get(0).getUuid();
RestAssured // @formatter:off
.given()
.header("current-user", "superuser-alex@hostsharing.net")
.port(port)
.when()
.get("http://localhost/api/hs/office/bankaccounts/" + givenBankAccountUuid)
.then().log().body().assertThat()
.statusCode(200)
.contentType("application/json")
.body("", lenientlyEquals("""
{
"holder": "First GmbH"
}
""")); // @formatter:on
}
@Test
@Accepts({ "bankaccount:X(Access Control)" })
void normalUser_canNotGetUnrelatedBankAccount() {
context.define("superuser-alex@hostsharing.net");
final var givenBankAccountUuid = bankAccountRepo.findByOptionalHolderLike("first").get(0).getUuid();
RestAssured // @formatter:off
.given()
.header("current-user", "selfregistered-user-drew@hostsharing.org")
.port(port)
.when()
.get("http://localhost/api/hs/office/bankaccounts/" + givenBankAccountUuid)
.then().log().body().assertThat()
.statusCode(404); // @formatter:on
}
@Test
@Accepts({ "bankaccount:X(Access Control)" })
@Disabled("TODO: not implemented yet")
void bankaccountAdminUser_canGetRelatedBankAccount() {
context.define("superuser-alex@hostsharing.net");
final var givenBankAccountUuid = bankAccountRepo.findByOptionalHolderLike("first").get(0).getUuid();
RestAssured // @formatter:off
.given()
.header("current-user", "bankaccount-admin@firstbankaccount.example.com")
.port(port)
.when()
.get("http://localhost/api/hs/office/bankaccounts/" + givenBankAccountUuid)
.then().log().body().assertThat()
.statusCode(200)
.contentType("application/json")
.body("", lenientlyEquals("""
{
"label": "first bankaccount",
"emailAddresses": "bankaccount-admin@firstbankaccount.example.com",
"phoneNumbers": "+49 123 1234567"
}
""")); // @formatter:on
}
}
@Nested
class PatchBankAccount {
@Test
void patchIsNotImplemented() {
context.define("superuser-alex@hostsharing.net");
final var givenBankAccount = givenSomeTemporaryBankAccountCreatedBy("selfregistered-test-user@hostsharing.org");
final var location = RestAssured // @formatter:off
.given()
.header("current-user", "superuser-alex@hostsharing.net")
.contentType(ContentType.JSON)
.body("""
{
"holder": "patched holder",
"iban": "DE02701500000000594937",
"bic": "SSKMDEMM"
}
""")
.port(port)
.when()
.patch("http://localhost/api/hs/office/bankaccounts/" + givenBankAccount.getUuid())
.then().assertThat()
.statusCode(405);
// @formatter:on
// and the bankaccount is unchanged
context.define("superuser-alex@hostsharing.net");
assertThat(bankAccountRepo.findByUuid(givenBankAccount.getUuid())).isPresent().get()
.matches(person -> {
assertThat(person.getHolder()).isEqualTo(givenBankAccount.getHolder());
assertThat(person.getIban()).isEqualTo(givenBankAccount.getIban());
assertThat(person.getBic()).isEqualTo(givenBankAccount.getBic());
return true;
});
}
}
@Nested
@Accepts({ "bankaccount:D(Delete)" })
class DeleteBankAccount {
@Test
void globalAdmin_withoutAssumedRole_canDeleteArbitraryBankAccount() {
context.define("superuser-alex@hostsharing.net");
final var givenBankAccount = givenSomeTemporaryBankAccountCreatedBy("selfregistered-test-user@hostsharing.org");
RestAssured // @formatter:off
.given()
.header("current-user", "superuser-alex@hostsharing.net")
.port(port)
.when()
.delete("http://localhost/api/hs/office/bankaccounts/" + givenBankAccount.getUuid())
.then().log().body().assertThat()
.statusCode(204); // @formatter:on
// then the given bankaccount is gone
assertThat(bankAccountRepo.findByUuid(givenBankAccount.getUuid())).isEmpty();
}
@Test
@Accepts({ "bankaccount:X(Access Control)" })
void bankaccountOwner_canDeleteRelatedBankAaccount() {
final var givenBankAccount = givenSomeTemporaryBankAccountCreatedBy("selfregistered-test-user@hostsharing.org");
RestAssured // @formatter:off
.given()
.header("current-user", "selfregistered-test-user@hostsharing.org")
.port(port)
.when()
.delete("http://localhost/api/hs/office/bankaccounts/" + givenBankAccount.getUuid())
.then().log().body().assertThat()
.statusCode(204); // @formatter:on
// then the given bankaccount is still there
assertThat(bankAccountRepo.findByUuid(givenBankAccount.getUuid())).isEmpty();
}
@Test
@Accepts({ "bankaccount:X(Access Control)" })
void normalUser_canNotDeleteUnrelatedBankAccount() {
context.define("superuser-alex@hostsharing.net");
final var givenBankAccount = givenSomeTemporaryBankAccountCreatedBy("selfregistered-test-user@hostsharing.org");
RestAssured // @formatter:off
.given()
.header("current-user", "selfregistered-user-drew@hostsharing.org")
.port(port)
.when()
.delete("http://localhost/api/hs/office/bankaccounts/" + givenBankAccount.getUuid())
.then().log().body().assertThat()
.statusCode(404); // unrelated user cannot even view the bankaccount
// @formatter:on
// then the given bankaccount is still there
assertThat(bankAccountRepo.findByUuid(givenBankAccount.getUuid())).isNotEmpty();
}
}
private HsOfficeBankAccountEntity givenSomeTemporaryBankAccountCreatedBy(final String creatingUser) {
return jpaAttempt.transacted(() -> {
context.define(creatingUser);
final var newBankAccount = HsOfficeBankAccountEntity.builder()
.uuid(UUID.randomUUID())
.holder("temp acc #" + RandomStringUtils.randomAlphabetic(3))
.iban("DE93500105179473626226")
.bic("INGDDEFFXXX")
.build();
toCleanup(newBankAccount.getUuid());
return bankAccountRepo.save(newBankAccount);
}).assertSuccessful().returnedValue();
}
private UUID toCleanup(final UUID tempBankAccountUuid) {
tempBankAccountUuids.add(tempBankAccountUuid);
return tempBankAccountUuid;
}
@BeforeEach
@AfterEach
void cleanup() {
tempBankAccountUuids.forEach(uuid -> {
jpaAttempt.transacted(() -> {
context.define("superuser-alex@hostsharing.net", null);
System.out.println("DELETING temporary bankaccount: " + uuid);
final var count = bankAccountRepo.deleteByUuid(uuid);
System.out.println("DELETED temporary bankaccount: " + uuid + (count > 0 ? " successful" : " failed"));
}).assertSuccessful();
});
}
}

View File

@@ -0,0 +1,35 @@
package net.hostsharing.hsadminng.hs.office.bankaccount;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
class HsOfficeBankAccountEntityUnitTest {
@Test
void toStringReturnsNullForNullBankAccount() {
final HsOfficeBankAccountEntity givenBankAccount = null;
assertThat("" + givenBankAccount).isEqualTo("null");
}
@Test
void toStringReturnsAllProperties() {
final var givenBankAccount = HsOfficeBankAccountEntity.builder()
.holder("given holder")
.iban("DE02370502990000684712")
.bic("COKSDE33")
.build();
assertThat("" + givenBankAccount).isEqualTo("bankAccount(holder='given holder', iban='DE02370502990000684712', bic='COKSDE33')");
}
@Test
void toShotStringReturnsHolder() {
final var givenBankAccount = HsOfficeBankAccountEntity.builder()
.holder("given holder")
.iban("DE02370502990000684712")
.bic("COKSDE33")
.build();
assertThat(givenBankAccount.toShortString()).isEqualTo("given holder");
}
}

View File

@@ -0,0 +1,323 @@
package net.hostsharing.hsadminng.hs.office.bankaccount;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.context.ContextBasedTest;
import net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantRepository;
import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleRepository;
import net.hostsharing.test.Array;
import net.hostsharing.test.JpaAttempt;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.modelmapper.internal.bytebuddy.utility.RandomString;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.test.annotation.DirtiesContext;
import org.testcontainers.junit.jupiter.Container;
import javax.persistence.EntityManager;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.function.Supplier;
import static net.hostsharing.hsadminng.hs.office.bankaccount.TestHsOfficeBankAccount.hsOfficeBankAccount;
import static net.hostsharing.hsadminng.rbac.rbacgrant.RawRbacGrantEntity.grantDisplaysOf;
import static net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleEntity.roleNamesOf;
import static net.hostsharing.test.JpaAttempt.attempt;
import static org.assertj.core.api.Assertions.assertThat;
@DataJpaTest
@ComponentScan(basePackageClasses = { HsOfficeBankAccountRepository.class, Context.class, JpaAttempt.class })
@DirtiesContext
class HsOfficeBankAccountRepositoryIntegrationTest extends ContextBasedTest {
@Autowired
HsOfficeBankAccountRepository bankaccountRepo;
@Autowired
RawRbacRoleRepository rawRoleRepo;
@Autowired
RawRbacGrantRepository rawGrantRepo;
@Autowired
EntityManager em;
@Autowired
JpaAttempt jpaAttempt;
@MockBean
HttpServletRequest request;
@Container
Container postgres;
@Nested
class CreateBankAccount {
@Test
public void globalAdmin_withoutAssumedRole_canCreateNewBankAccount() {
// given
context("superuser-alex@hostsharing.net");
final var count = bankaccountRepo.count();
// when
final var result = attempt(em, () -> bankaccountRepo.save(
hsOfficeBankAccount("some temp acc A", "DE37500105177419788228", "")));
// then
result.assertSuccessful();
assertThat(result.returnedValue()).isNotNull().extracting(HsOfficeBankAccountEntity::getUuid).isNotNull();
assertThatBankAccountIsPersisted(result.returnedValue());
assertThat(bankaccountRepo.count()).isEqualTo(count + 1);
}
@Test
public void arbitraryUser_canCreateNewBankAccount() {
// given
context("selfregistered-user-drew@hostsharing.org");
final var count = bankaccountRepo.count();
// when
final var result = attempt(em, () -> bankaccountRepo.save(
hsOfficeBankAccount("some temp acc B", "DE49500105174516484892", "INGDDEFFXXX")));
// then
result.assertSuccessful();
assertThat(result.returnedValue()).isNotNull().extracting(HsOfficeBankAccountEntity::getUuid).isNotNull();
assertThatBankAccountIsPersisted(result.returnedValue());
assertThat(bankaccountRepo.count()).isEqualTo(count + 1);
}
@Test
public void createsAndGrantsRoles() {
// given
context("selfregistered-user-drew@hostsharing.org");
final var initialRoleNames = roleNamesOf(rawRoleRepo.findAll());
final var initialGrantNames = grantDisplaysOf(rawGrantRepo.findAll());
// when
attempt(em, () -> bankaccountRepo.save(
hsOfficeBankAccount("some temp acc C", "DE25500105176934832579", "INGDDEFFXXX"))
).assumeSuccessful();
// then
final var roles = rawRoleRepo.findAll();
assertThat(roleNamesOf(roles)).containsExactlyInAnyOrder(Array.from(
initialRoleNames,
"hs_office_bankaccount#sometempaccC.owner",
"hs_office_bankaccount#sometempaccC.tenant"
));
assertThat(grantDisplaysOf(rawGrantRepo.findAll())).containsExactlyInAnyOrder(Array.from(
initialGrantNames,
"{ grant role hs_office_bankaccount#sometempaccC.owner to role global#global.admin by system and assume }",
"{ grant perm delete on hs_office_bankaccount#sometempaccC to role hs_office_bankaccount#sometempaccC.owner by system and assume }",
"{ grant role hs_office_bankaccount#sometempaccC.tenant to role hs_office_bankaccount#sometempaccC.owner by system and assume }",
"{ grant perm view on hs_office_bankaccount#sometempaccC to role hs_office_bankaccount#sometempaccC.tenant by system and assume }",
"{ grant role hs_office_bankaccount#sometempaccC.owner to user selfregistered-user-drew@hostsharing.org by global#global.admin and assume }"
));
}
private void assertThatBankAccountIsPersisted(final HsOfficeBankAccountEntity saved) {
final var found = bankaccountRepo.findByUuid(saved.getUuid());
assertThat(found).isNotEmpty().get().usingRecursiveComparison().isEqualTo(saved);
}
}
@Nested
class FindAllBankAccounts {
@Test
public void globalAdmin_withoutAssumedRole_canViewAllBankAccounts() {
// given
context("superuser-alex@hostsharing.net");
// when
final var result = bankaccountRepo.findByOptionalHolderLike(null);
// then
allTheseBankAccountsAreReturned(
result,
"Anita Bessler",
"First GmbH",
"Fourth e.G.",
"Mel Bessler",
"Paul Winkler",
"Peter Smith",
"Second e.K.",
"Third OHG");
}
@Test
public void arbitraryUser_canViewOnlyItsOwnBankAccount() {
// given:
final var givenBankAccount = givenSomeTemporaryBankAccount("selfregistered-user-drew@hostsharing.org");
// when:
context("selfregistered-user-drew@hostsharing.org");
final var result = bankaccountRepo.findByOptionalHolderLike(null);
// then:
exactlyTheseBankAccountsAreReturned(result, givenBankAccount.getHolder());
}
}
@Nested
class FindByLabelLike {
@Test
public void globalAdmin_withoutAssumedRole_canViewAllBankAccounts() {
// given
context("superuser-alex@hostsharing.net", null);
// when
final var result = bankaccountRepo.findByOptionalHolderLike(null);
// then
exactlyTheseBankAccountsAreReturned(
result,
"Anita Bessler",
"First GmbH",
"Fourth e.G.",
"Mel Bessler",
"Paul Winkler",
"Peter Smith",
"Second e.K.",
"Third OHG");
}
@Test
public void arbitraryUser_withoutAssumedRole_canViewOnlyItsOwnBankAccount() {
// given:
final var givenBankAccount = givenSomeTemporaryBankAccount("selfregistered-user-drew@hostsharing.org");
// when:
context("selfregistered-user-drew@hostsharing.org");
final var result = bankaccountRepo.findByOptionalHolderLike(givenBankAccount.getHolder());
// then:
exactlyTheseBankAccountsAreReturned(result, givenBankAccount.getHolder());
}
}
@Nested
class DeleteByUuid {
@Test
public void globalAdmin_withoutAssumedRole_canDeleteAnyBankAccount() {
// given
context("superuser-alex@hostsharing.net", null);
final var givenBankAccount = givenSomeTemporaryBankAccount("selfregistered-user-drew@hostsharing.org");
// when
final var result = jpaAttempt.transacted(() -> {
context("superuser-alex@hostsharing.net", null);
bankaccountRepo.deleteByUuid(givenBankAccount.getUuid());
});
// then
result.assertSuccessful();
assertThat(jpaAttempt.transacted(() -> {
context("superuser-alex@hostsharing.net", null);
return bankaccountRepo.findByOptionalHolderLike(givenBankAccount.getHolder());
}).assertSuccessful().returnedValue()).hasSize(0);
}
@Test
public void arbitraryUser_withoutAssumedRole_canDeleteABankAccountCreatedByItself() {
// given
final var givenBankAccount = givenSomeTemporaryBankAccount("selfregistered-user-drew@hostsharing.org");
// when
final var result = jpaAttempt.transacted(() -> {
context("selfregistered-user-drew@hostsharing.org", null);
bankaccountRepo.deleteByUuid(givenBankAccount.getUuid());
});
// then
result.assertSuccessful();
assertThat(jpaAttempt.transacted(() -> {
context("superuser-alex@hostsharing.net", null);
return bankaccountRepo.findByOptionalHolderLike(givenBankAccount.getHolder());
}).assertSuccessful().returnedValue()).hasSize(0);
}
@Test
public void deletingABankAccountAlsoDeletesRelatedRolesAndGrants() {
// given
context("selfregistered-user-drew@hostsharing.org", null);
final var initialRoleNames = roleNamesOf(rawRoleRepo.findAll());
final var initialGrantNames = grantDisplaysOf(rawGrantRepo.findAll());
final var givenBankAccount = givenSomeTemporaryBankAccount("selfregistered-user-drew@hostsharing.org");
assertThat(rawRoleRepo.findAll().size()).as("unexpected number of roles created")
.isEqualTo(initialRoleNames.size() + 2);
assertThat(rawGrantRepo.findAll().size()).as("unexpected number of grants created")
.isEqualTo(initialGrantNames.size() + 5);
// when
final var result = jpaAttempt.transacted(() -> {
context("selfregistered-user-drew@hostsharing.org", null);
return bankaccountRepo.deleteByUuid(givenBankAccount.getUuid());
});
// then
result.assertSuccessful();
assertThat(result.returnedValue()).isEqualTo(1);
assertThat(roleNamesOf(rawRoleRepo.findAll())).containsExactlyInAnyOrder(Array.from(
initialRoleNames
));
assertThat(grantDisplaysOf(rawGrantRepo.findAll())).containsExactlyInAnyOrder(Array.from(
initialGrantNames
));
}
}
private HsOfficeBankAccountEntity givenSomeTemporaryBankAccount(
final String createdByUser,
Supplier<HsOfficeBankAccountEntity> entitySupplier) {
return jpaAttempt.transacted(() -> {
context(createdByUser);
return bankaccountRepo.save(entitySupplier.get());
}).assertSuccessful().returnedValue();
}
@BeforeEach
@AfterEach
void cleanup() {
context("superuser-alex@hostsharing.net", null);
final var result = bankaccountRepo.findByOptionalHolderLike("some temp acc");
result.forEach(tempPerson -> {
System.out.println("DELETING temporary bankaccount: " + tempPerson.getHolder());
bankaccountRepo.deleteByUuid(tempPerson.getUuid());
});
}
private HsOfficeBankAccountEntity givenSomeTemporaryBankAccount(final String createdByUser) {
final var random = RandomString.make(3);
return givenSomeTemporaryBankAccount(createdByUser, () ->
hsOfficeBankAccount(
"some temp acc #" + random,
"DE41500105177739718697",
"INGDDEFFXXX"
));
}
void exactlyTheseBankAccountsAreReturned(
final List<HsOfficeBankAccountEntity> actualResult,
final String... bankaccountLabels) {
assertThat(actualResult)
.extracting(HsOfficeBankAccountEntity::getHolder)
.containsExactlyInAnyOrder(bankaccountLabels);
}
void allTheseBankAccountsAreReturned(
final List<HsOfficeBankAccountEntity> actualResult,
final String... bankaccountLabels) {
assertThat(actualResult)
.extracting(HsOfficeBankAccountEntity::getHolder)
.contains(bankaccountLabels);
}
}

View File

@@ -0,0 +1,18 @@
package net.hostsharing.hsadminng.hs.office.bankaccount;
import java.util.UUID;
public class TestHsOfficeBankAccount {
public static final HsOfficeBankAccountEntity someBankAccount =
hsOfficeBankAccount("some bankaccount", "DE67500105173931168623", "INGDDEFFXXX");
static public HsOfficeBankAccountEntity hsOfficeBankAccount(final String holder, final String iban, final String bic) {
return HsOfficeBankAccountEntity.builder()
.uuid(UUID.randomUUID())
.holder(holder)
.iban(iban)
.bic(bic)
.build();
}
}