rbac-optimization #80
@ -105,6 +105,13 @@ public class HsOfficeCoopAssetsTransactionEntity implements Stringifyable, RbacO
|
|||||||
@OneToOne(mappedBy = "adjustedAssetTx")
|
@OneToOne(mappedBy = "adjustedAssetTx")
|
||||||
private HsOfficeCoopAssetsTransactionEntity adjustmentAssetTx;
|
private HsOfficeCoopAssetsTransactionEntity adjustmentAssetTx;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HsOfficeCoopAssetsTransactionEntity load() {
|
||||||
|
RbacObject.super.load();
|
||||||
|
membership.load();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public String getTaggedMemberNumber() {
|
public String getTaggedMemberNumber() {
|
||||||
return ofNullable(membership).map(HsOfficeMembershipEntity::toShortString).orElse("M-???????");
|
return ofNullable(membership).map(HsOfficeMembershipEntity::toShortString).orElse("M-???????");
|
||||||
}
|
}
|
||||||
|
@ -102,6 +102,13 @@ public class HsOfficeCoopSharesTransactionEntity implements Stringifyable, RbacO
|
|||||||
@OneToOne(mappedBy = "adjustedShareTx")
|
@OneToOne(mappedBy = "adjustedShareTx")
|
||||||
private HsOfficeCoopSharesTransactionEntity adjustmentShareTx;
|
private HsOfficeCoopSharesTransactionEntity adjustmentShareTx;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HsOfficeCoopSharesTransactionEntity load() {
|
||||||
|
RbacObject.super.load();
|
||||||
|
membership.load();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return stringify.apply(this);
|
return stringify.apply(this);
|
||||||
|
@ -92,7 +92,7 @@ public class HsOfficeDebitorEntity implements RbacObject<HsOfficeDebitorEntity>,
|
|||||||
WHERE pRel.holderUuid = dRel.anchorUuid
|
WHERE pRel.holderUuid = dRel.anchorUuid
|
||||||
)
|
)
|
||||||
""")
|
""")
|
||||||
@NotFound(action = NotFoundAction.IGNORE)
|
@NotFound(action = NotFoundAction.IGNORE) // TODO.impl: map a simplified raw-PartnerEntity, just for the partner-number
|
||||||
private HsOfficePartnerEntity partner;
|
private HsOfficePartnerEntity partner;
|
||||||
|
|
||||||
@Column(name = "debitornumbersuffix", length = 2)
|
@Column(name = "debitornumbersuffix", length = 2)
|
||||||
@ -120,6 +120,7 @@ public class HsOfficeDebitorEntity implements RbacObject<HsOfficeDebitorEntity>,
|
|||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "refundbankaccountuuid")
|
@JoinColumn(name = "refundbankaccountuuid")
|
||||||
|
@NotFound(action = NotFoundAction.IGNORE)
|
||||||
private HsOfficeBankAccountEntity refundBankAccount;
|
private HsOfficeBankAccountEntity refundBankAccount;
|
||||||
|
|
||||||
@Column(name = "defaultprefix", columnDefinition = "char(3) not null")
|
@Column(name = "defaultprefix", columnDefinition = "char(3) not null")
|
||||||
@ -128,7 +129,9 @@ public class HsOfficeDebitorEntity implements RbacObject<HsOfficeDebitorEntity>,
|
|||||||
@Override
|
@Override
|
||||||
public HsOfficeDebitorEntity load() {
|
public HsOfficeDebitorEntity load() {
|
||||||
RbacObject.super.load();
|
RbacObject.super.load();
|
||||||
partner.load();
|
if (partner != null) {
|
||||||
|
partner.load();
|
||||||
|
}
|
||||||
debitorRel.load();
|
debitorRel.load();
|
||||||
if (refundBankAccount != null) {
|
if (refundBankAccount != null) {
|
||||||
refundBankAccount.load();
|
refundBankAccount.load();
|
||||||
|
@ -62,7 +62,7 @@ class HsOfficeCoopAssetsTransactionRepositoryIntegrationTest extends ContextBase
|
|||||||
// given
|
// given
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
final var count = coopAssetsTransactionRepo.count();
|
final var count = coopAssetsTransactionRepo.count();
|
||||||
final var givenMembership = membershipRepo.findMembershipByMemberNumber(1000101);
|
final var givenMembership = membershipRepo.findMembershipByMemberNumber(1000101).load();
|
||||||
|
|
||||||
// when
|
// when
|
||||||
final var result = attempt(em, () -> {
|
final var result = attempt(em, () -> {
|
||||||
|
@ -61,7 +61,7 @@ class HsOfficeCoopSharesTransactionRepositoryIntegrationTest extends ContextBase
|
|||||||
// given
|
// given
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
final var count = coopSharesTransactionRepo.count();
|
final var count = coopSharesTransactionRepo.count();
|
||||||
final var givenMembership = membershipRepo.findMembershipByMemberNumber(1000101);
|
final var givenMembership = membershipRepo.findMembershipByMemberNumber(1000101).load();
|
||||||
|
|
||||||
// when
|
// when
|
||||||
final var result = attempt(em, () -> {
|
final var result = attempt(em, () -> {
|
||||||
|
@ -720,7 +720,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu
|
|||||||
private HsOfficeDebitorEntity givenSomeTemporaryDebitor() {
|
private HsOfficeDebitorEntity givenSomeTemporaryDebitor() {
|
||||||
return jpaAttempt.transacted(() -> {
|
return jpaAttempt.transacted(() -> {
|
||||||
context.define("superuser-alex@hostsharing.net");
|
context.define("superuser-alex@hostsharing.net");
|
||||||
final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("Fourth").get(0);
|
final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("Fourth").get(0).load();
|
||||||
final var givenContact = contactRepo.findContactByOptionalCaptionLike("fourth contact").get(0);
|
final var givenContact = contactRepo.findContactByOptionalCaptionLike("fourth contact").get(0);
|
||||||
final var newDebitor = HsOfficeDebitorEntity.builder()
|
final var newDebitor = HsOfficeDebitorEntity.builder()
|
||||||
.debitorNumberSuffix(nextDebitorSuffix())
|
.debitorNumberSuffix(nextDebitorSuffix())
|
||||||
|
@ -14,6 +14,7 @@ import net.hostsharing.hsadminng.rbac.rbacrole.RawRbacRoleRepository;
|
|||||||
import net.hostsharing.hsadminng.mapper.Array;
|
import net.hostsharing.hsadminng.mapper.Array;
|
||||||
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
|
import net.hostsharing.hsadminng.rbac.test.JpaAttempt;
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
|
import org.hibernate.exception.GenericJDBCException;
|
||||||
import org.junit.jupiter.api.Disabled;
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.jupiter.api.Nested;
|
import org.junit.jupiter.api.Nested;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@ -23,7 +24,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.orm.jpa.JpaObjectRetrievalFailureException;
|
|
||||||
import org.springframework.orm.jpa.JpaSystemException;
|
import org.springframework.orm.jpa.JpaSystemException;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@ -83,12 +83,14 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
// given
|
// given
|
||||||
context("superuser-alex@hostsharing.net");
|
context("superuser-alex@hostsharing.net");
|
||||||
final var count = debitorRepo.count();
|
final var count = debitorRepo.count();
|
||||||
|
final var givenPartner = partnerRepo.findPartnerByPartnerNumber(10001);
|
||||||
final var givenPartnerPerson = one(personRepo.findPersonByOptionalNameLike("First GmbH"));
|
final var givenPartnerPerson = one(personRepo.findPersonByOptionalNameLike("First GmbH"));
|
||||||
final var givenContact = one(contactRepo.findContactByOptionalCaptionLike("first contact"));
|
final var givenContact = one(contactRepo.findContactByOptionalCaptionLike("first contact"));
|
||||||
|
|
||||||
// when
|
// when
|
||||||
final var result = attempt(em, () -> {
|
final var result = attempt(em, () -> {
|
||||||
final var newDebitor = HsOfficeDebitorEntity.builder()
|
final var newDebitor = HsOfficeDebitorEntity.builder()
|
||||||
|
.partner(givenPartner)
|
||||||
.debitorNumberSuffix("21")
|
.debitorNumberSuffix("21")
|
||||||
.debitorRel(HsOfficeRelationEntity.builder()
|
.debitorRel(HsOfficeRelationEntity.builder()
|
||||||
.type(HsOfficeRelationType.DEBITOR)
|
.type(HsOfficeRelationType.DEBITOR)
|
||||||
@ -472,7 +474,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
result.assertExceptionWithRootCauseMessage(
|
result.assertExceptionWithRootCauseMessage(
|
||||||
JpaObjectRetrievalFailureException.class,
|
GenericJDBCException.class,
|
||||||
// this technical error message gets translated to a [403] error at the controller level
|
// this technical error message gets translated to a [403] error at the controller level
|
||||||
"Unable to find net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountEntity with id ");
|
"Unable to find net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountEntity with id ");
|
||||||
}
|
}
|
||||||
@ -613,6 +615,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean
|
|||||||
final var givenBankAccount =
|
final var givenBankAccount =
|
||||||
bankAccountHolder != null ? one(bankAccountRepo.findByOptionalHolderLike(bankAccountHolder)) : null;
|
bankAccountHolder != null ? one(bankAccountRepo.findByOptionalHolderLike(bankAccountHolder)) : null;
|
||||||
final var newDebitor = HsOfficeDebitorEntity.builder()
|
final var newDebitor = HsOfficeDebitorEntity.builder()
|
||||||
|
.partner(givenPartner)
|
||||||
.debitorNumberSuffix("20")
|
.debitorNumberSuffix("20")
|
||||||
.debitorRel(HsOfficeRelationEntity.builder()
|
.debitorRel(HsOfficeRelationEntity.builder()
|
||||||
.type(HsOfficeRelationType.DEBITOR)
|
.type(HsOfficeRelationType.DEBITOR)
|
||||||
|
Loading…
Reference in New Issue
Block a user