1
0

hs-office-coopassets, no get API endpoints yet

This commit is contained in:
Michael Hoennig
2022-10-21 17:12:55 +02:00
parent 5ada0dae35
commit a39cf73cf0
18 changed files with 1314 additions and 1 deletions

View File

@@ -36,6 +36,7 @@ public class ArchitectureTest {
"..hs.office.relationship",
"..hs.office.contact",
"..hs.office.sepamandate",
"..hs.office.coopassets",
"..hs.office.coopshares",
"..hs.office.membership",
"..errors",
@@ -156,7 +157,14 @@ public class ArchitectureTest {
public static final ArchRule hsOfficeMembershipPackageRule = classes()
.that().resideInAPackage("..hs.office.membership..")
.should().onlyBeAccessed().byClassesThat()
.resideInAnyPackage("..hs.office.membership..", "..hs.office.coopshares..");
.resideInAnyPackage("..hs.office.membership..", "..hs.office.coopassets..", "..hs.office.coopshares..");
@ArchTest
@SuppressWarnings("unused")
public static final ArchRule hsOfficeCoopAssetsPackageRule = classes()
.that().resideInAPackage("..hs.office.coopassets..")
.should().onlyBeAccessed().byClassesThat()
.resideInAnyPackage("..hs.office.coopassets..");
@ArchTest
@SuppressWarnings("unused")

View File

@@ -0,0 +1,242 @@
package net.hostsharing.hsadminng.hs.office.coopassets;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import net.hostsharing.hsadminng.HsadminNgApplication;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.hs.office.coopassets.HsOfficeCoopAssetsTransactionRepository;
import net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipRepository;
import net.hostsharing.test.Accepts;
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.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 javax.persistence.EntityManager;
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.hasSize;
import static org.hamcrest.Matchers.startsWith;
@SpringBootTest(
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
classes = { HsadminNgApplication.class, JpaAttempt.class }
)
@Transactional
class HsOfficeCoopAssetsTransactionControllerAcceptanceTest {
@LocalServerPort
private Integer port;
@Autowired
Context context;
@Autowired
HsOfficeMembershipRepository membershipRepo;
@Autowired
JpaAttempt jpaAttempt;
@Autowired
EntityManager em;
@Nested
@Accepts({ "CoopAssetsTransaction:F(Find)" })
class ListCoopAssetsTransactions {
@Test
void globalAdmin_canViewAllCoopAssetsTransactions() {
RestAssured // @formatter:off
.given()
.header("current-user", "superuser-alex@hostsharing.net")
.port(port)
.when()
.get("http://localhost/api/hs/office/coopassetstransactions")
.then().log().all().assertThat()
.statusCode(200)
.contentType("application/json")
.body("", hasSize(9)); // @formatter:on
}
@Test
void globalAdmin_canFindCoopAssetsTransactionsByMemberNumber() {
context.define("superuser-alex@hostsharing.net");
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(null, 10002)
.get(0);
RestAssured // @formatter:off
.given()
.header("current-user", "superuser-alex@hostsharing.net")
.port(port)
.when()
.get("http://localhost/api/hs/office/coopassetstransactions?membershipUuid="+givenMembership.getUuid())
.then().log().all().assertThat()
.statusCode(200)
.contentType("application/json")
.body("", lenientlyEquals("""
[
{
"transactionType": "DEPOSIT",
"assetValue": 320.00,
"valueDate": "2010-03-15",
"reference": "ref 10002-1",
"comment": "initial deposit"
},
{
"transactionType": "DISBURSAL",
"assetValue": -128.00,
"valueDate": "2021-09-01",
"reference": "ref 10002-2",
"comment": "partial disbursal"
},
{
"transactionType": "ADJUSTMENT",
"assetValue": 128.00,
"valueDate": "2022-10-20",
"reference": "ref 10002-3",
"comment": "some adjustment"
}
]
""")); // @formatter:on
}
@Test
void globalAdmin_canFindCoopAssetsTransactionsByMemberNumberAndDateRange() {
context.define("superuser-alex@hostsharing.net");
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(null, 10002)
.get(0);
RestAssured // @formatter:off
.given()
.header("current-user", "superuser-alex@hostsharing.net")
.port(port)
.when()
.get("http://localhost/api/hs/office/coopassetstransactions?membershipUuid="
+ givenMembership.getUuid() + "&fromValueDate=2020-01-01&toValueDate=2021-12-31")
.then().log().all().assertThat()
.statusCode(200)
.contentType("application/json")
.body("", lenientlyEquals("""
[
{
"transactionType": "DISBURSAL",
"assetValue": -128.00,
"valueDate": "2021-09-01",
"reference": "ref 10002-2",
"comment": "partial disbursal"
}
]
""")); // @formatter:on
}
}
@Nested
@Accepts({ "CoopAssetsTransaction:C(Create)" })
class AddCoopAssetsTransaction {
@Test
void globalAdmin_canAddCoopAssetsTransaction() {
context.define("superuser-alex@hostsharing.net");
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(null, 10001)
.get(0);
final var location = RestAssured // @formatter:off
.given()
.header("current-user", "superuser-alex@hostsharing.net")
.contentType(ContentType.JSON)
.body("""
{
"membershipUuid": "%s",
"transactionType": "DEPOSIT",
"assetValue": 1024.00,
"valueDate": "2022-10-13",
"reference": "temp ref A",
"comment": "just some test coop assets transaction"
}
""".formatted(givenMembership.getUuid()))
.port(port)
.when()
.post("http://localhost/api/hs/office/coopassetstransactions")
.then().log().all().assertThat()
.statusCode(201)
.contentType(ContentType.JSON)
.body("uuid", isUuidValid())
.body("", lenientlyEquals("""
{
"transactionType": "DEPOSIT",
"assetValue": 1024.00,
"valueDate": "2022-10-13",
"reference": "temp ref A",
"comment": "just some test coop assets transaction"
}
"""))
.header("Location", startsWith("http://localhost"))
.extract().header("Location"); // @formatter:on
// finally, the new coopAssetsTransaction can be accessed under the generated UUID
final var newUserUuid = UUID.fromString(
location.substring(location.lastIndexOf('/') + 1));
assertThat(newUserUuid).isNotNull();
}
@Test
void globalAdmin_canNotCancelMoreAssetsThanCurrentlySubscribed() {
context.define("superuser-alex@hostsharing.net");
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(null, 10001)
.get(0);
final var location = RestAssured // @formatter:off
.given()
.header("current-user", "superuser-alex@hostsharing.net")
.contentType(ContentType.JSON)
.body("""
{
"membershipUuid": "%s",
"transactionType": "DISBURSAL",
"assetValue": -10240.00,
"valueDate": "2022-10-13",
"reference": "temp ref X",
"comment": "just some test coop assets transaction"
}
""".formatted(givenMembership.getUuid()))
.port(port)
.when()
.post("http://localhost/api/hs/office/coopassetstransactions")
.then().log().all().assertThat()
.statusCode(400)
.contentType(ContentType.JSON)
.body("", lenientlyEquals("""
{
"status": 400,
"error": "Bad Request",
"message": "ERROR: [400] coop assets transaction would result in a negative balance of assets"
}
""")); // @formatter:on
}
}
@BeforeEach
@AfterEach
void cleanup() {
jpaAttempt.transacted(() -> {
context.define("superuser-alex@hostsharing.net", null);
// HsOfficeCoopAssetsTransactionEntity respectively hs_office_coopassetstransaction_rv
// cannot be deleted at all, but the underlying table record can be deleted.
em.createNativeQuery("delete from hs_office_coopassetstransaction where reference like 'temp %'")
.executeUpdate();
}).assertSuccessful();
}
}

View File

@@ -0,0 +1,126 @@
package net.hostsharing.hsadminng.hs.office.coopassets;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.test.JsonBuilder;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import java.util.UUID;
import java.util.function.Function;
import static net.hostsharing.test.JsonBuilder.jsonObject;
import static org.hamcrest.Matchers.is;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@WebMvcTest(HsOfficeCoopAssetsTransactionController.class)
class HsOfficeCoopAssetsTransactionControllerRestTest {
@Autowired
MockMvc mockMvc;
@MockBean
Context contextMock;
@MockBean
HsOfficeCoopAssetsTransactionRepository coopAssetsTransactionRepo;
static final String VALID_INSERT_REQUEST_BODY = """
{
"membershipUuid": "%s",
"transactionType": "DEPOSIT",
"assetValue": 128.00,
"valueDate": "2022-10-13",
"reference": "valid reference",
"comment": "valid comment"
}
""".formatted(UUID.randomUUID());
enum BadRequestTestCases {
MEMBERSHIP_UUID_MISSING(
requestBody -> requestBody.without("membershipUuid"),
"[membershipUuid must not be null but is \"null\"]"),
TRANSACTION_TYPE_MISSING(
requestBody -> requestBody.without("transactionType"),
"[transactionType must not be null but is \"null\"]"),
VALUE_DATE_MISSING(
requestBody -> requestBody.without("valueDate"),
"[valueDate must not be null but is \"null\"]"),
ASSETS_VALUE_FOR_DEPOSIT_MUST_BE_POSITIVE(
requestBody -> requestBody
.with("transactionType", "DEPOSIT")
.with("assetValue", -64.00),
"[for DEPOSIT, assetValue must be positive but is \"-64.00\"]"),
//TODO: other transaction types
ASSETS_VALUE_FOR_DISBURSAL_MUST_BE_NEGATIVE(
requestBody -> requestBody
.with("transactionType", "DISBURSAL")
.with("assetValue", 64.00),
"[for DISBURSAL, assetValue must be negative but is \"64.00\"]"),
//TODO: other transaction types
ASSETS_VALUE_MUST_NOT_BE_NULL(
requestBody -> requestBody
.with("transactionType", "ADJUSTMENT")
.with("assetValue", 0.00),
"[assetValue must not be 0 but is \"0.00\"]"),
REFERENCE_MISSING(
requestBody -> requestBody.without("reference"),
"[reference must not be null but is \"null\"]"),
REFERENCE_TOO_SHORT(
requestBody -> requestBody.with("reference", "12345"),
"[reference size must be between 6 and 48 but is \"12345\"]"),
REFERENCE_TOO_LONG(
requestBody -> requestBody.with("reference", "0123456789012345678901234567890123456789012345678"),
"[reference size must be between 6 and 48 but is \"0123456789012345678901234567890123456789012345678\"]");
private final Function<JsonBuilder, JsonBuilder> givenBodyTransformation;
private final String expectedErrorMessage;
BadRequestTestCases(
final Function<JsonBuilder, JsonBuilder> givenBodyTransformation,
final String expectedErrorMessage) {
this.givenBodyTransformation = givenBodyTransformation;
this.expectedErrorMessage = expectedErrorMessage;
}
String givenRequestBody() {
return givenBodyTransformation.apply(jsonObject(VALID_INSERT_REQUEST_BODY)).toString();
}
}
@ParameterizedTest
@EnumSource(BadRequestTestCases.class)
void respondWithBadRequest(final BadRequestTestCases testCase) throws Exception {
// when
mockMvc.perform(MockMvcRequestBuilders
.post("/api/hs/office/coopassetstransactions")
.header("current-user", "superuser-alex@hostsharing.net")
.contentType(MediaType.APPLICATION_JSON)
.content(testCase.givenRequestBody())
.accept(MediaType.APPLICATION_JSON))
// then
.andExpect(status().is4xxClientError())
.andExpect(jsonPath("status", is(400)))
.andExpect(jsonPath("error", is("Bad Request")))
.andExpect(jsonPath("message", is(testCase.expectedErrorMessage)));
}
}

View File

@@ -0,0 +1,34 @@
package net.hostsharing.hsadminng.hs.office.coopassets;
import org.junit.jupiter.api.Test;
import java.math.BigDecimal;
import java.time.LocalDate;
import static net.hostsharing.hsadminng.hs.office.membership.TestHsMembership.testMembership;
import static org.assertj.core.api.Assertions.assertThat;
class HsOfficeCoopAssetsTransactionEntityTest {
final HsOfficeCoopAssetsTransactionEntity givenCoopAssetTransaction = HsOfficeCoopAssetsTransactionEntity.builder()
.membership(testMembership)
.reference("some-ref")
.valueDate(LocalDate.parse("2020-01-01"))
.transactionType(HsOfficeCoopAssetsTransactionType.DEPOSIT)
.assetValue(new BigDecimal("128.00"))
.build();
@Test
void toStringContainsAlmostAllPropertiesAccount() {
final var result = givenCoopAssetTransaction.toString();
assertThat(result).isEqualTo("CoopAssetsTransaction(300001, 2020-01-01, DEPOSIT, 128.00, some-ref)");
}
@Test
void toShortStringContainsOnlyMemberNumberAndSharesCountOnly() {
final var result = givenCoopAssetTransaction.toShortString();
assertThat(result).isEqualTo("300001+128.00");
}
}

View File

@@ -0,0 +1,269 @@
package net.hostsharing.hsadminng.hs.office.coopassets;
import net.hostsharing.hsadminng.context.Context;
import net.hostsharing.hsadminng.context.ContextBasedTest;
import net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipRepository;
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.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.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
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 = { HsOfficeCoopAssetsTransactionRepository.class, Context.class, JpaAttempt.class })
@DirtiesContext
class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBasedTest {
@Autowired
HsOfficeCoopAssetsTransactionRepository coopAssetsTransactionRepo;
@Autowired
HsOfficeMembershipRepository membershipRepo;
@Autowired
RawRbacRoleRepository rawRoleRepo;
@Autowired
RawRbacGrantRepository rawGrantRepo;
@Autowired
EntityManager em;
@Autowired
JpaAttempt jpaAttempt;
@MockBean
HttpServletRequest request;
@Nested
class CreateCoopAssetsTransaction {
@Test
public void globalAdmin_canCreateNewCoopAssetTransaction() {
// given
context("superuser-alex@hostsharing.net");
final var count = coopAssetsTransactionRepo.count();
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(null, 10001)
.get(0);
// when
final var result = attempt(em, () -> {
final var newCoopAssetsTransaction = HsOfficeCoopAssetsTransactionEntity.builder()
.uuid(UUID.randomUUID())
.membership(givenMembership)
.transactionType(HsOfficeCoopAssetsTransactionType.DEPOSIT)
.assetValue(new BigDecimal("128.00"))
.valueDate(LocalDate.parse("2022-10-18"))
.reference("temp ref A")
.build();
return coopAssetsTransactionRepo.save(newCoopAssetsTransaction);
});
// then
result.assertSuccessful();
assertThat(result.returnedValue()).isNotNull().extracting(HsOfficeCoopAssetsTransactionEntity::getUuid).isNotNull();
assertThatCoopAssetsTransactionIsPersisted(result.returnedValue());
assertThat(coopAssetsTransactionRepo.count()).isEqualTo(count + 1);
}
@Test
public void createsAndGrantsRoles() {
// given
context("superuser-alex@hostsharing.net");
final var initialRoleNames = roleNamesOf(rawRoleRepo.findAll());
final var initialGrantNames = grantDisplaysOf(rawGrantRepo.findAll()).stream()
.map(s -> s.replace("FirstGmbH-firstcontact", "..."))
.map(s -> s.replace("hs_office_", ""))
.toList();
// when
attempt(em, () -> {
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(
null,
10001).get(0);
final var newCoopAssetsTransaction = HsOfficeCoopAssetsTransactionEntity.builder()
.uuid(UUID.randomUUID())
.membership(givenMembership)
.transactionType(HsOfficeCoopAssetsTransactionType.DEPOSIT)
.assetValue(new BigDecimal("128.00"))
.valueDate(LocalDate.parse("2022-10-18"))
.reference("temp ref B")
.build();
return coopAssetsTransactionRepo.save(newCoopAssetsTransaction);
});
// then
final var all = rawRoleRepo.findAll();
assertThat(roleNamesOf(all)).containsExactlyInAnyOrder(Array.from(initialRoleNames)); // no new roles created
assertThat(grantDisplaysOf(rawGrantRepo.findAll()))
.map(s -> s.replace("FirstGmbH-firstcontact", "..."))
.map(s -> s.replace("hs_office_", ""))
.containsExactlyInAnyOrder(Array.fromFormatted(
initialGrantNames,
"{ grant perm view on coopassetstransaction#temprefB to role membership#10001....tenant by system and assume }",
null));
}
private void assertThatCoopAssetsTransactionIsPersisted(final HsOfficeCoopAssetsTransactionEntity saved) {
final var found = coopAssetsTransactionRepo.findByUuid(saved.getUuid());
assertThat(found).isNotEmpty().get().usingRecursiveComparison().isEqualTo(saved);
}
}
@Nested
class FindAllCoopAssetsTransactions {
@Test
public void globalAdmin_anViewAllCoopAssetsTransactions() {
// given
context("superuser-alex@hostsharing.net");
// when
final var result = coopAssetsTransactionRepo.findCoopAssetsTransactionByOptionalMembershipUuidAndDateRange(
null,
null,
null);
// then
allTheseCoopAssetsTransactionsAreReturned(
result,
"CoopAssetsTransaction(10001, 2010-03-15, DEPOSIT, 320.00, ref 10001-1)",
"CoopAssetsTransaction(10001, 2021-09-01, DISBURSAL, -128.00, ref 10001-2)",
"CoopAssetsTransaction(10001, 2022-10-20, ADJUSTMENT, 128.00, ref 10001-3)",
"CoopAssetsTransaction(10002, 2010-03-15, DEPOSIT, 320.00, ref 10002-1)",
"CoopAssetsTransaction(10002, 2021-09-01, DISBURSAL, -128.00, ref 10002-2)",
"CoopAssetsTransaction(10002, 2022-10-20, ADJUSTMENT, 128.00, ref 10002-3)",
"CoopAssetsTransaction(10003, 2010-03-15, DEPOSIT, 320.00, ref 10003-1)",
"CoopAssetsTransaction(10003, 2021-09-01, DISBURSAL, -128.00, ref 10003-2)",
"CoopAssetsTransaction(10003, 2022-10-20, ADJUSTMENT, 128.00, ref 10003-3)");
}
@Test
public void globalAdmin_canViewCoopAssetsTransactions_filteredByMembershipUuid() {
// given
context("superuser-alex@hostsharing.net");
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(null, 10002)
.get(0);
// when
final var result = coopAssetsTransactionRepo.findCoopAssetsTransactionByOptionalMembershipUuidAndDateRange(
givenMembership.getUuid(),
null,
null);
// then
allTheseCoopAssetsTransactionsAreReturned(
result,
"CoopAssetsTransaction(10002, 2010-03-15, DEPOSIT, 320.00, ref 10002-1)",
"CoopAssetsTransaction(10002, 2021-09-01, DISBURSAL, -128.00, ref 10002-2)",
"CoopAssetsTransaction(10002, 2022-10-20, ADJUSTMENT, 128.00, ref 10002-3)");
}
@Test
public void globalAdmin_canViewCoopAssetsTransactions_filteredByMembershipUuidAndValueDateRange() {
// given
context("superuser-alex@hostsharing.net");
final var givenMembership = membershipRepo.findMembershipsByOptionalPartnerUuidAndOptionalMemberNumber(null, 10002)
.get(0);
// when
final var result = coopAssetsTransactionRepo.findCoopAssetsTransactionByOptionalMembershipUuidAndDateRange(
givenMembership.getUuid(),
LocalDate.parse("2021-09-01"),
LocalDate.parse("2021-09-01"));
// then
allTheseCoopAssetsTransactionsAreReturned(
result,
"CoopAssetsTransaction(10002, 2021-09-01, DISBURSAL, -128.00, ref 10002-2)");
}
@Test
public void normalUser_canViewOnlyRelatedCoopAssetsTransactions() {
// given:
context("superuser-alex@hostsharing.net", "hs_office_partner#FirstGmbH-firstcontact.admin");
// "hs_office_person#FirstGmbH.admin",
// when:
final var result = coopAssetsTransactionRepo.findCoopAssetsTransactionByOptionalMembershipUuidAndDateRange(
null,
null,
null);
// then:
exactlyTheseCoopAssetsTransactionsAreReturned(
result,
"CoopAssetsTransaction(10001, 2010-03-15, DEPOSIT, 320.00, ref 10001-1)",
"CoopAssetsTransaction(10001, 2021-09-01, DISBURSAL, -128.00, ref 10001-2)",
"CoopAssetsTransaction(10001, 2022-10-20, ADJUSTMENT, 128.00, ref 10001-3)");
}
}
@Test
public void auditJournalLogIsAvailable() {
// given
final var query = em.createNativeQuery("""
select c.currenttask, j.targettable, j.targetop
from tx_journal j
join tx_context c on j.contextId = c.contextId
where targettable = 'hs_office_coopassetstransaction';
""");
// when
@SuppressWarnings("unchecked") final List<Object[]> customerLogEntries = query.getResultList();
// then
assertThat(customerLogEntries).map(Arrays::toString).contains(
"[creating coopAssetsTransaction test-data 10001, hs_office_coopassetstransaction, INSERT]",
"[creating coopAssetsTransaction test-data 10002, hs_office_coopassetstransaction, INSERT]");
}
@BeforeEach
@AfterEach
void cleanup() {
jpaAttempt.transacted(() -> {
context("superuser-alex@hostsharing.net", null);
em.createQuery("DELETE FROM HsOfficeCoopAssetsTransactionEntity WHERE reference like 'temp ref%'");
});
}
void exactlyTheseCoopAssetsTransactionsAreReturned(
final List<HsOfficeCoopAssetsTransactionEntity> actualResult,
final String... coopAssetsTransactionNames) {
assertThat(actualResult)
.extracting(coopAssetsTransactionEntity -> coopAssetsTransactionEntity.toString())
.containsExactlyInAnyOrder(coopAssetsTransactionNames);
}
void allTheseCoopAssetsTransactionsAreReturned(
final List<HsOfficeCoopAssetsTransactionEntity> actualResult,
final String... coopAssetsTransactionNames) {
assertThat(actualResult)
.extracting(coopAssetsTransactionEntity -> coopAssetsTransactionEntity.toString())
.contains(coopAssetsTransactionNames);
}
}