diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntity.java index 374e2939..32d9038f 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntity.java @@ -7,7 +7,7 @@ import lombok.NoArgsConstructor; import lombok.Setter; import net.hostsharing.hsadminng.errors.DisplayAs; import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountEntity; -import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity; +import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRbacEntity; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelation; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRbacEntity; @@ -96,7 +96,7 @@ public class HsOfficeDebitorEntity implements BaseEntity, ) """) @NotFound(action = NotFoundAction.IGNORE) // TODO.impl: map a simplified raw-PartnerEntity, just for the partner-number - private HsOfficePartnerEntity partner; + private HsOfficePartnerRbacEntity partner; @Column(name = "debitornumbersuffix", length = 2) @Pattern(regexp = TWO_DECIMAL_DIGITS) @@ -145,7 +145,7 @@ public class HsOfficeDebitorEntity implements BaseEntity, public String getTaggedDebitorNumber() { return ofNullable(partner) .filter(partner -> debitorNumberSuffix != null) - .map(HsOfficePartnerEntity::getPartnerNumber) + .map(HsOfficePartnerRbacEntity::getPartnerNumber) .map(partnerNumber -> DEBITOR_NUMBER_TAG + partnerNumber + debitorNumberSuffix) .orElse(null); } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipController.java index 778d12b9..0d1b9110 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipController.java @@ -6,8 +6,8 @@ import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeMembersh import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeMembershipInsertResource; import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeMembershipPatchResource; import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeMembershipResource; -import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity; -import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRepository; +import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRbacEntity; +import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRbacRepository; import net.hostsharing.hsadminng.mapper.StrictMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; @@ -33,7 +33,7 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi { private StrictMapper mapper; @Autowired - private HsOfficePartnerRepository partnerRepo; + private HsOfficePartnerRbacRepository partnerRepo; @Autowired private HsOfficeMembershipRepository membershipRepo; @@ -52,7 +52,7 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi { final var entities = partnerNumber != null ? membershipRepo.findMembershipsByPartnerNumber( - cropTag(HsOfficePartnerEntity.PARTNER_NUMBER_TAG, partnerNumber)) + cropTag(HsOfficePartnerRbacEntity.PARTNER_NUMBER_TAG, partnerNumber)) : partnerUuid != null ? membershipRepo.findMembershipsByPartnerUuid(partnerUuid) : membershipRepo.findAll(); diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipEntity.java index a1741926..08c7ae93 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipEntity.java @@ -10,7 +10,7 @@ import lombok.Setter; import net.hostsharing.hsadminng.errors.DisplayAs; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRbacEntity; import net.hostsharing.hsadminng.persistence.BaseEntity; -import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity; +import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRbacEntity; import net.hostsharing.hsadminng.rbac.generator.RbacSpec; import net.hostsharing.hsadminng.rbac.generator.RbacSpec.SQL; import net.hostsharing.hsadminng.rbac.role.WithRoleId; @@ -85,7 +85,7 @@ public class HsOfficeMembershipEntity implements BaseEntity ENTITY_TO_RESOURCE_POSTMAPPER = (entity, resource) -> { + final BiConsumer ENTITY_TO_RESOURCE_POSTMAPPER = (entity, resource) -> { resource.setPartnerNumber(entity.getTaggedPartnerNumber()); }; } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntityPatcher.java b/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntityPatcher.java index b01ccc6b..ecf8adc9 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntityPatcher.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntityPatcher.java @@ -9,10 +9,10 @@ import jakarta.persistence.EntityManager; class HsOfficePartnerEntityPatcher implements EntityPatcher { private final EntityManager em; - private final HsOfficePartnerEntity entity; + private final HsOfficePartnerRbacEntity entity; HsOfficePartnerEntityPatcher( final EntityManager em, - final HsOfficePartnerEntity entity) { + final HsOfficePartnerRbacEntity entity) { this.em = em; this.entity = entity; } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRbacEntity.java similarity index 92% rename from src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntity.java rename to src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRbacEntity.java index 3575b24b..35f9c4c6 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRbacEntity.java @@ -43,12 +43,12 @@ import static net.hostsharing.hsadminng.repr.Stringify.stringify; @NoArgsConstructor @AllArgsConstructor @DisplayAs("Partner") -public class HsOfficePartnerEntity implements Stringifyable, BaseEntity { +public class HsOfficePartnerRbacEntity implements Stringifyable, BaseEntity { public static final String PARTNER_NUMBER_TAG = "P-"; - private static Stringify stringify = stringify(HsOfficePartnerEntity.class, "partner") - .withIdProp(HsOfficePartnerEntity::toShortString) + private static Stringify stringify = stringify(HsOfficePartnerRbacEntity.class, "partner") + .withIdProp(HsOfficePartnerRbacEntity::toShortString) .withProp(p -> ofNullable(p.getPartnerRel()) .map(HsOfficeRelation::getHolder) .map(HsOfficePerson::toShortString) @@ -79,7 +79,7 @@ public class HsOfficePartnerEntity implements Stringifyable, BaseEntity { +public interface HsOfficePartnerRbacRepository extends Repository { @Timed("app.office.partners.repo.findByUuid") - Optional findByUuid(UUID id); + Optional findByUuid(UUID id); @Timed("app.office.partners.repo.findAll") - List findAll(); // TODO.refa: move to a repo in test sources + List findAll(); // TODO.refa: move to a repo in test sources -// @Query(""" -// SELECT partner FROM HsOfficePartnerEntity partner -// JOIN HsOfficeRelationRealEntity rel ON rel.uuid = partner.partnerRel.uuid -// JOIN HsOfficeContactRealEntity contact ON contact.uuid = rel.contact.uuid -// JOIN HsOfficePersonRealEntity person ON person.uuid = rel.holder.uuid -// LEFT JOIN HsOfficePartnerDetailsEntity details ON partner.details.uuid = details.uuid -// WHERE :name is null -// OR (details IS NOT NULL AND details.birthName like concat(cast(:name as text), '%')) -// OR contact.caption like concat(cast(:name as text), '%') -// OR person.tradeName like concat(cast(:name as text), '%') -// OR person.givenName like concat(cast(:name as text), '%') -// OR person.familyName like concat(cast(:name as text), '%') -// """) @Query(value = """ select partner.uuid, partner.detailsuuid, partner.partnernumber, partner.partnerreluuid, partner.version from hs_office.partner_rv partner @@ -44,13 +31,13 @@ public interface HsOfficePartnerRepository extends Repository findPartnerByOptionalNameLike(String name); + List findPartnerByOptionalNameLike(String name); @Timed("app.office.partners.repo.findPartnerByPartnerNumber") - Optional findPartnerByPartnerNumber(Integer partnerNumber); + Optional findPartnerByPartnerNumber(Integer partnerNumber); @Timed("app.office.partners.repo.save") - HsOfficePartnerEntity save(final HsOfficePartnerEntity entity); + HsOfficePartnerRbacEntity save(final HsOfficePartnerRbacEntity entity); @Timed("app.office.partners.repo.count") long count(); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java b/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java index da89e268..35547e1d 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java @@ -10,7 +10,7 @@ import net.hostsharing.hsadminng.hs.office.debitor.HsOfficeDebitorEntity; import net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipEntity; import net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipStatus; import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerDetailsEntity; -import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity; +import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRbacEntity; import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealEntity; import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelation; @@ -84,7 +84,7 @@ public abstract class BaseOfficeDataImport extends CsvDataImport { static Map contacts = new WriteOnceMap<>(); static Map persons = new WriteOnceMap<>(); - static Map partners = new WriteOnceMap<>(); + static Map partners = new WriteOnceMap<>(); static Map debitors = new WriteOnceMap<>(); static Map memberships = new WriteOnceMap<>(); @@ -743,7 +743,7 @@ public abstract class BaseOfficeDataImport extends CsvDataImport { null // is set during contacts import depending on assigned roles ); - final var partner = HsOfficePartnerEntity.builder() + final var partner = HsOfficePartnerRbacEntity.builder() .partnerNumber(rec.getInteger("member_id")) .details(HsOfficePartnerDetailsEntity.builder().build()) .partnerRel(partnerRel) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerRestTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerRestTest.java index 3e657a30..1e2cfa63 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerRestTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionControllerRestTest.java @@ -4,7 +4,7 @@ import net.hostsharing.hsadminng.config.JsonObjectMapperConfiguration; import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipEntity; import net.hostsharing.hsadminng.hs.office.membership.HsOfficeMembershipRepository; -import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity; +import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRbacEntity; import net.hostsharing.hsadminng.mapper.StrictMapper; import net.hostsharing.hsadminng.persistence.EntityManagerWrapper; import net.hostsharing.hsadminng.rbac.test.JsonBuilder; @@ -67,7 +67,7 @@ class HsOfficeCoopAssetsTransactionControllerRestTest { private static final String ORIGIN_MEMBER_NUMBER = "M-1111100"; public final HsOfficeMembershipEntity ORIGIN_TARGET_MEMBER_ENTITY = HsOfficeMembershipEntity.builder() .uuid(ORIGIN_MEMBERSHIP_UUID) - .partner(HsOfficePartnerEntity.builder() + .partner(HsOfficePartnerRbacEntity.builder() .partnerNumber(partnerNumberOf(ORIGIN_MEMBER_NUMBER)) .build()) .memberNumberSuffix(suffixOf(ORIGIN_MEMBER_NUMBER)) @@ -77,7 +77,7 @@ class HsOfficeCoopAssetsTransactionControllerRestTest { private static final String AVAILABLE_TARGET_MEMBER_NUMBER = "M-1234500"; public final HsOfficeMembershipEntity AVAILABLE_MEMBER_ENTITY = HsOfficeMembershipEntity.builder() .uuid(AVAILABLE_TARGET_MEMBERSHIP_UUID) - .partner(HsOfficePartnerEntity.builder() + .partner(HsOfficePartnerRbacEntity.builder() .partnerNumber(partnerNumberOf(AVAILABLE_TARGET_MEMBER_NUMBER)) .build()) .memberNumberSuffix(suffixOf(AVAILABLE_TARGET_MEMBER_NUMBER)) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorControllerAcceptanceTest.java index 84d6b280..98be1755 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorControllerAcceptanceTest.java @@ -6,7 +6,7 @@ import net.hostsharing.hsadminng.HsadminNgApplication; import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountRepository; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealRepository; -import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRepository; +import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRbacRepository; import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealRepository; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealRepository; @@ -58,7 +58,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu HsOfficeDebitorRepository debitorRepo; @Autowired - HsOfficePartnerRepository partnerRepo; + HsOfficePartnerRbacRepository partnerRepo; @Autowired HsOfficeContactRealRepository contactRealRepo; diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntityUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntityUnitTest.java index 57351efe..023fcc6b 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntityUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorEntityUnitTest.java @@ -1,7 +1,7 @@ package net.hostsharing.hsadminng.hs.office.debitor; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealEntity; -import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity; +import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRbacEntity; import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealEntity; import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity; @@ -30,7 +30,7 @@ class HsOfficeDebitorEntityUnitTest { .debitorNumberSuffix("67") .debitorRel(givenDebitorRel) .defaultPrefix("som") - .partner(HsOfficePartnerEntity.builder() + .partner(HsOfficePartnerRbacEntity.builder() .partnerNumber(12345) .build()) .build(); @@ -45,7 +45,7 @@ class HsOfficeDebitorEntityUnitTest { final var given = HsOfficeDebitorEntity.builder() .debitorRel(givenDebitorRel) .debitorNumberSuffix("67") - .partner(HsOfficePartnerEntity.builder() + .partner(HsOfficePartnerRbacEntity.builder() .partnerNumber(12345) .build()) .build(); @@ -60,7 +60,7 @@ class HsOfficeDebitorEntityUnitTest { final var given = HsOfficeDebitorEntity.builder() .debitorRel(givenDebitorRel) .debitorNumberSuffix("67") - .partner(HsOfficePartnerEntity.builder() + .partner(HsOfficePartnerRbacEntity.builder() .partnerNumber(12345) .build()) .build(); @@ -88,7 +88,7 @@ class HsOfficeDebitorEntityUnitTest { final var given = HsOfficeDebitorEntity.builder() .debitorRel(givenDebitorRel) .debitorNumberSuffix("67") - .partner(HsOfficePartnerEntity.builder().build()) + .partner(HsOfficePartnerRbacEntity.builder().build()) .build(); final var result = given.getTaggedDebitorNumber(); @@ -101,7 +101,7 @@ class HsOfficeDebitorEntityUnitTest { final var given = HsOfficeDebitorEntity.builder() .debitorRel(givenDebitorRel) .debitorNumberSuffix(null) - .partner(HsOfficePartnerEntity.builder() + .partner(HsOfficePartnerRbacEntity.builder() .partnerNumber(12345) .build()) .build(); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepositoryIntegrationTest.java index c461a8ba..c3537f74 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepositoryIntegrationTest.java @@ -3,7 +3,7 @@ package net.hostsharing.hsadminng.hs.office.debitor; import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.hs.office.bankaccount.HsOfficeBankAccountRepository; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealRepository; -import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRepository; +import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRbacRepository; import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealRepository; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelation; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity; @@ -48,7 +48,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean HsOfficeDebitorRepository debitorRepo; @Autowired - HsOfficePartnerRepository partnerRepo; + HsOfficePartnerRbacRepository partnerRepo; @Autowired HsOfficeContactRealRepository contactRealRepo; diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipControllerAcceptanceTest.java index 3c67b2cd..ed7a8925 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipControllerAcceptanceTest.java @@ -5,7 +5,7 @@ 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.partner.HsOfficePartnerRepository; +import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRbacRepository; import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup; import net.hostsharing.hsadminng.rbac.test.JpaAttempt; import net.hostsharing.hsadminng.config.DisableSecurityConfig; @@ -54,7 +54,7 @@ class HsOfficeMembershipControllerAcceptanceTest extends ContextBasedTestWithCle HsOfficeMembershipRepository membershipRepo; @Autowired - HsOfficePartnerRepository partnerRepo; + HsOfficePartnerRbacRepository partnerRepo; @Autowired JpaAttempt jpaAttempt; diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipControllerRestTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipControllerRestTest.java index 216b0298..54ffbd85 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipControllerRestTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipControllerRestTest.java @@ -2,8 +2,8 @@ package net.hostsharing.hsadminng.hs.office.membership; import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.hs.office.coopassets.HsOfficeCoopAssetsTransactionRepository; -import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity; -import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRepository; +import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRbacEntity; +import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRbacRepository; import net.hostsharing.hsadminng.mapper.StrictMapper; import net.hostsharing.hsadminng.persistence.EntityManagerWrapper; import net.hostsharing.hsadminng.config.DisableSecurityConfig; @@ -39,7 +39,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @ActiveProfiles("test") public class HsOfficeMembershipControllerRestTest { - private static final HsOfficePartnerEntity PARTNER_12345 = HsOfficePartnerEntity.builder() + private static final HsOfficePartnerRbacEntity PARTNER_12345 = HsOfficePartnerRbacEntity.builder() .partnerNumber(12345) .build(); public static final HsOfficeMembershipEntity MEMBERSHIP_1234501 = HsOfficeMembershipEntity.builder() @@ -77,7 +77,7 @@ public class HsOfficeMembershipControllerRestTest { HsOfficeCoopAssetsTransactionRepository coopAssetsTransactionRepo; @MockitoBean - HsOfficePartnerRepository partnerRepo; + HsOfficePartnerRbacRepository partnerRepo; @MockitoBean HsOfficeMembershipRepository membershipRepo; @@ -256,7 +256,7 @@ public class HsOfficeMembershipControllerRestTest { // given final var givenPartnerUuid = UUID.randomUUID(); - when(em.find(HsOfficePartnerEntity.class, givenPartnerUuid)).thenReturn(null); + when(em.find(HsOfficePartnerRbacEntity.class, givenPartnerUuid)).thenReturn(null); // when mockMvc.perform(MockMvcRequestBuilders diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipEntityUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipEntityUnitTest.java index 6d2b13be..49219290 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipEntityUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipEntityUnitTest.java @@ -1,7 +1,7 @@ package net.hostsharing.hsadminng.hs.office.membership; import io.hypersistence.utils.hibernate.type.range.Range; -import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerEntity; +import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRbacEntity; import net.hostsharing.hsadminng.rbac.generator.RbacViewMermaidFlowchartGenerator; import org.junit.jupiter.api.Test; @@ -57,7 +57,7 @@ class HsOfficeMembershipEntityUnitTest { @Test void getMemberNumberWithoutPartnerNumberButWithSuffix() { - givenMembership.setPartner(HsOfficePartnerEntity.builder().build()); + givenMembership.setPartner(HsOfficePartnerRbacEntity.builder().build()); final var result = givenMembership.getMemberNumber(); assertThat(result).isEqualTo(null); } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepositoryIntegrationTest.java index 13c5396a..04be5edd 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepositoryIntegrationTest.java @@ -3,7 +3,7 @@ package net.hostsharing.hsadminng.hs.office.membership; import io.hypersistence.utils.hibernate.type.range.Range; import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.hs.office.debitor.HsOfficeDebitorRepository; -import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRepository; +import net.hostsharing.hsadminng.hs.office.partner.HsOfficePartnerRbacRepository; import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup; import net.hostsharing.hsadminng.rbac.grant.RawRbacGrantRepository; import net.hostsharing.hsadminng.rbac.role.RawRbacRoleRepository; @@ -37,7 +37,7 @@ class HsOfficeMembershipRepositoryIntegrationTest extends ContextBasedTestWithCl HsOfficeMembershipRepository membershipRepo; @Autowired - HsOfficePartnerRepository partnerRepo; + HsOfficePartnerRbacRepository partnerRepo; @Autowired HsOfficeDebitorRepository debitorRepo; diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerAcceptanceTest.java index 54a4baf2..8bfc7009 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerAcceptanceTest.java @@ -42,7 +42,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu private Integer port; @Autowired - HsOfficePartnerRepository partnerRepo; + HsOfficePartnerRbacRepository partnerRepo; @Autowired HsOfficeRelationRealRepository relationRepo; @@ -541,12 +541,12 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu return partnerRel; }).assertSuccessful().returnedValue(); } - private HsOfficePartnerEntity givenSomeTemporaryPartnerBessler(final Integer partnerNumber) { + private HsOfficePartnerRbacEntity givenSomeTemporaryPartnerBessler(final Integer partnerNumber) { return jpaAttempt.transacted(() -> { context.define("superuser-alex@hostsharing.net"); final var partnerRel = em.merge(givenSomeTemporaryPartnerRel("Erben Bessler", "fourth contact")); - final var newPartner = HsOfficePartnerEntity.builder() + final var newPartner = HsOfficePartnerRbacEntity.builder() .partnerRel(partnerRel) .partnerNumber(partnerNumber) .details(HsOfficePartnerDetailsEntity.builder() @@ -561,7 +561,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu @AfterEach void cleanup() { - cleanupAllNew(HsOfficePartnerEntity.class); + cleanupAllNew(HsOfficePartnerRbacEntity.class); // TODO: should not be necessary anymore, once it's deleted via after delete trigger cleanupAllNew(HsOfficeRelationRealEntity.class); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerRestTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerRestTest.java index 13a81cdb..1ed5389b 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerRestTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerRestTest.java @@ -54,7 +54,7 @@ class HsOfficePartnerControllerRestTest { Context contextMock; @MockitoBean - HsOfficePartnerRepository partnerRepo; + HsOfficePartnerRbacRepository partnerRepo; @MockitoBean HsOfficeRelationRealRepository relationRepo; @@ -75,7 +75,7 @@ class HsOfficePartnerControllerRestTest { HsOfficeContactRbacEntity contactMock; @Mock - HsOfficePartnerEntity partnerMock; + HsOfficePartnerRbacEntity partnerMock; @BeforeEach void init() { @@ -174,7 +174,7 @@ class HsOfficePartnerControllerRestTest { @Test void respondWithPartner_ifPartnerNumberIsAvailable() throws Exception { // given - when(partnerRepo.findPartnerByPartnerNumber(12345)).thenReturn(Optional.of(HsOfficePartnerEntity.builder() + when(partnerRepo.findPartnerByPartnerNumber(12345)).thenReturn(Optional.of(HsOfficePartnerRbacEntity.builder() .partnerNumber(12345) .build())); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntityPatcherUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntityPatcherUnitTest.java index 102b54e5..b38c41ae 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntityPatcherUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntityPatcherUnitTest.java @@ -24,7 +24,7 @@ import static org.mockito.Mockito.lenient; @ExtendWith(MockitoExtension.class) class HsOfficePartnerEntityPatcherUnitTest extends PatchUnitTestBase< HsOfficePartnerPatchResource, - HsOfficePartnerEntity + HsOfficePartnerRbacEntity > { private static final UUID INITIAL_PARTNER_UUID = UUID.randomUUID(); @@ -53,8 +53,8 @@ class HsOfficePartnerEntityPatcherUnitTest extends PatchUnitTestBase< } @Override - protected HsOfficePartnerEntity newInitialEntity() { - final var entity = HsOfficePartnerEntity.builder() + protected HsOfficePartnerRbacEntity newInitialEntity() { + final var entity = HsOfficePartnerRbacEntity.builder() .uuid(INITIAL_PARTNER_UUID) .partnerNumber(12345) .partnerRel(HsOfficeRelationRealEntity.builder() @@ -72,7 +72,7 @@ class HsOfficePartnerEntityPatcherUnitTest extends PatchUnitTestBase< } @Override - protected HsOfficePartnerEntityPatcher createPatcher(final HsOfficePartnerEntity partner) { + protected HsOfficePartnerEntityPatcher createPatcher(final HsOfficePartnerRbacEntity partner) { return new HsOfficePartnerEntityPatcher(em, partner); } @@ -83,7 +83,7 @@ class HsOfficePartnerEntityPatcherUnitTest extends PatchUnitTestBase< "partnerRel", HsOfficePartnerPatchResource::setPartnerRelUuid, PATCHED_PARTNER_ROLE_UUID, - HsOfficePartnerEntity::setPartnerRel, + HsOfficePartnerRbacEntity::setPartnerRel, newPartnerRel(PATCHED_PARTNER_ROLE_UUID)) .notNullable() ); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntityUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntityUnitTest.java index 93ca0315..79c24ec7 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntityUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerEntityUnitTest.java @@ -12,7 +12,7 @@ import static org.assertj.core.api.Assertions.assertThat; class HsOfficePartnerEntityUnitTest { - private final HsOfficePartnerEntity givenPartner = HsOfficePartnerEntity.builder() + private final HsOfficePartnerRbacEntity givenPartner = HsOfficePartnerRbacEntity.builder() .partnerNumber(12345) .partnerRel(HsOfficeRelationRealEntity.builder() .anchor(HsOfficePersonRealEntity.builder() @@ -42,7 +42,7 @@ class HsOfficePartnerEntityUnitTest { @Test void definesRbac() { - final var rbacFlowchart = new RbacViewMermaidFlowchartGenerator(HsOfficePartnerEntity.rbac()).toString(); + final var rbacFlowchart = new RbacViewMermaidFlowchartGenerator(HsOfficePartnerRbacEntity.rbac()).toString(); assertThat(rbacFlowchart).isEqualTo(""" %%{init:{'flowchart':{'htmlLabels':false}}}%% flowchart TB diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRepositoryIntegrationTest.java index b625bfb9..07f5e810 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRepositoryIntegrationTest.java @@ -41,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat; class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithCleanup { @Autowired - HsOfficePartnerRepository partnerRepo; + HsOfficePartnerRbacRepository partnerRepo; @Autowired HsOfficeRelationRealRepository relationRepo; @@ -82,7 +82,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean // when final var result = attempt(em, () -> { - final var newPartner = HsOfficePartnerEntity.builder() + final var newPartner = HsOfficePartnerRbacEntity.builder() .partnerNumber(20031) .partnerRel(partnerRel) .details(HsOfficePartnerDetailsEntity.builder().build()) @@ -92,7 +92,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean // then result.assertSuccessful(); - assertThat(result.returnedValue()).isNotNull().extracting(HsOfficePartnerEntity::getUuid).isNotNull(); + assertThat(result.returnedValue()).isNotNull().extracting(HsOfficePartnerRbacEntity::getUuid).isNotNull(); assertThatPartnerIsPersisted(result.returnedValue()); assertThat(partnerRepo.count()).isEqualTo(count + 1); } @@ -122,7 +122,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean .build(); relationRepo.save(newRelation); - final var newPartner = HsOfficePartnerEntity.builder() + final var newPartner = HsOfficePartnerRbacEntity.builder() .partnerNumber(20032) .partnerRel(newRelation) .details(HsOfficePartnerDetailsEntity.builder().build()) @@ -180,7 +180,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean null))); } - private void assertThatPartnerIsPersisted(final HsOfficePartnerEntity saved) { + private void assertThatPartnerIsPersisted(final HsOfficePartnerRbacEntity saved) { final var found = partnerRepo.findByUuid(saved.getUuid()); assertThat(found).isNotEmpty().get().extracting(Object::toString).isEqualTo(saved.toString()); } @@ -325,13 +325,13 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean result.assertSuccessful(); } - private void assertThatPartnerActuallyInDatabase(final HsOfficePartnerEntity saved) { + private void assertThatPartnerActuallyInDatabase(final HsOfficePartnerRbacEntity saved) { final var found = partnerRepo.findByUuid(saved.getUuid()); - assertThat(found).isNotEmpty().get().isNotSameAs(saved).extracting(HsOfficePartnerEntity::toString).isEqualTo(saved.toString()); + assertThat(found).isNotEmpty().get().isNotSameAs(saved).extracting(HsOfficePartnerRbacEntity::toString).isEqualTo(saved.toString()); } private void assertThatPartnerIsVisibleForUserWithRole( - final HsOfficePartnerEntity entity, + final HsOfficePartnerRbacEntity entity, final String assumedRoles) { jpaAttempt.transacted(() -> { context("superuser-alex@hostsharing.net", assumedRoles); @@ -340,7 +340,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean } private void assertThatPartnerIsNotVisibleForUserWithRole( - final HsOfficePartnerEntity entity, + final HsOfficePartnerRbacEntity entity, final String assumedRoles) { jpaAttempt.transacted(() -> { context("superuser-alex@hostsharing.net", assumedRoles); @@ -442,13 +442,13 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean "[creating partner test-data , hs_office.partner, INSERT, 10010]"); } - private HsOfficePartnerEntity givenSomeTemporaryHostsharingPartner( + private HsOfficePartnerRbacEntity givenSomeTemporaryHostsharingPartner( final Integer partnerNumber, final String person, final String contact) { return jpaAttempt.transacted(() -> { context("superuser-alex@hostsharing.net"); final var partnerRel = givenSomeTemporaryHostsharingPartnerRel(person, contact); - final var newPartner = HsOfficePartnerEntity.builder() + final var newPartner = HsOfficePartnerRbacEntity.builder() .partnerNumber(partnerNumber) .partnerRel(partnerRel) .details(HsOfficePartnerDetailsEntity.builder().build()) @@ -476,21 +476,21 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean return partnerRel; } - void exactlyThesePartnersAreReturned(final List actualResult, final String... partnerNames) { + void exactlyThesePartnersAreReturned(final List actualResult, final String... partnerNames) { assertThat(actualResult) - .extracting(HsOfficePartnerEntity::toString) + .extracting(HsOfficePartnerRbacEntity::toString) .containsExactlyInAnyOrder(partnerNames); } - void allThesePartnersAreReturned(final List actualResult, final String... partnerNames) { + void allThesePartnersAreReturned(final List actualResult, final String... partnerNames) { assertThat(actualResult) - .extracting(HsOfficePartnerEntity::toString) + .extracting(HsOfficePartnerRbacEntity::toString) .contains(partnerNames); } @AfterEach void cleanup() { - cleanupAllNew(HsOfficePartnerEntity.class); + cleanupAllNew(HsOfficePartnerRbacEntity.class); } private String[] distinct(final String[] strings) { diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/TestHsOfficePartner.java b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/TestHsOfficePartner.java index 02358e28..560ab443 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/TestHsOfficePartner.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/TestHsOfficePartner.java @@ -9,10 +9,10 @@ import static net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType.LEGA public class TestHsOfficePartner { - public static final HsOfficePartnerEntity TEST_PARTNER = hsOfficePartnerWithLegalPerson("Test Ltd."); + public static final HsOfficePartnerRbacEntity TEST_PARTNER = hsOfficePartnerWithLegalPerson("Test Ltd."); - static public HsOfficePartnerEntity hsOfficePartnerWithLegalPerson(final String tradeName) { - return HsOfficePartnerEntity.builder() + static public HsOfficePartnerRbacEntity hsOfficePartnerWithLegalPerson(final String tradeName) { + return HsOfficePartnerRbacEntity.builder() .partnerNumber(10001) .partnerRel( HsOfficeRelationRealEntity.builder()