Upgrade to SpringBoot 3.4.1 and dependencies #147
@ -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<HsOfficeDebitorEntity>,
|
||||
)
|
||||
""")
|
||||
@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<HsOfficeDebitorEntity>,
|
||||
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);
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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<HsOfficeMembershipEn
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "partneruuid")
|
||||
private HsOfficePartnerEntity partner;
|
||||
private HsOfficePartnerRbacEntity partner;
|
||||
|
||||
@Column(name = "membernumbersuffix", length = 2)
|
||||
@Pattern(regexp = TWO_DECIMAL_DIGITS)
|
||||
|
@ -42,7 +42,7 @@ public class HsOfficePartnerController implements HsOfficePartnersApi {
|
||||
private StrictMapper mapper;
|
||||
|
||||
@Autowired
|
||||
private HsOfficePartnerRepository partnerRepo;
|
||||
private HsOfficePartnerRbacRepository partnerRepo;
|
||||
|
||||
@Autowired
|
||||
private HsOfficeRelationRealRepository relationRepo;
|
||||
@ -168,16 +168,16 @@ public class HsOfficePartnerController implements HsOfficePartnersApi {
|
||||
return ResponseEntity.ok(mapped);
|
||||
}
|
||||
|
||||
private void optionallyCreateExPartnerRelation(final HsOfficePartnerEntity saved, final HsOfficeRelationRealEntity previousPartnerRel) {
|
||||
private void optionallyCreateExPartnerRelation(final HsOfficePartnerRbacEntity saved, final HsOfficeRelationRealEntity previousPartnerRel) {
|
||||
if (!saved.getPartnerRel().getUuid().equals(previousPartnerRel.getUuid())) {
|
||||
// TODO.impl: we also need to use the new partner-person as the anchor
|
||||
relationRepo.save(previousPartnerRel.toBuilder().uuid(null).type(EX_PARTNER).build());
|
||||
}
|
||||
}
|
||||
|
||||
private HsOfficePartnerEntity createPartnerEntity(final HsOfficePartnerInsertResource body) {
|
||||
final var entityToSave = new HsOfficePartnerEntity();
|
||||
entityToSave.setPartnerNumber(cropTag(HsOfficePartnerEntity.PARTNER_NUMBER_TAG, body.getPartnerNumber()));
|
||||
private HsOfficePartnerRbacEntity createPartnerEntity(final HsOfficePartnerInsertResource body) {
|
||||
final var entityToSave = new HsOfficePartnerRbacEntity();
|
||||
entityToSave.setPartnerNumber(cropTag(HsOfficePartnerRbacEntity.PARTNER_NUMBER_TAG, body.getPartnerNumber()));
|
||||
entityToSave.setPartnerRel(persistPartnerRel(body.getPartnerRel()));
|
||||
entityToSave.setDetails(mapper.map(body.getDetails(), HsOfficePartnerDetailsEntity.class));
|
||||
return entityToSave;
|
||||
@ -201,7 +201,7 @@ public class HsOfficePartnerController implements HsOfficePartnersApi {
|
||||
}
|
||||
}
|
||||
|
||||
final BiConsumer<HsOfficePartnerEntity, HsOfficePartnerResource> ENTITY_TO_RESOURCE_POSTMAPPER = (entity, resource) -> {
|
||||
final BiConsumer<HsOfficePartnerRbacEntity, HsOfficePartnerResource> ENTITY_TO_RESOURCE_POSTMAPPER = (entity, resource) -> {
|
||||
resource.setPartnerNumber(entity.getTaggedPartnerNumber());
|
||||
};
|
||||
}
|
||||
|
@ -9,10 +9,10 @@ import jakarta.persistence.EntityManager;
|
||||
|
||||
class HsOfficePartnerEntityPatcher implements EntityPatcher<HsOfficePartnerPatchResource> {
|
||||
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;
|
||||
}
|
||||
|
@ -43,12 +43,12 @@ import static net.hostsharing.hsadminng.repr.Stringify.stringify;
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@DisplayAs("Partner")
|
||||
public class HsOfficePartnerEntity implements Stringifyable, BaseEntity<HsOfficePartnerEntity> {
|
||||
public class HsOfficePartnerRbacEntity implements Stringifyable, BaseEntity<HsOfficePartnerRbacEntity> {
|
||||
|
||||
public static final String PARTNER_NUMBER_TAG = "P-";
|
||||
|
||||
private static Stringify<HsOfficePartnerEntity> stringify = stringify(HsOfficePartnerEntity.class, "partner")
|
||||
.withIdProp(HsOfficePartnerEntity::toShortString)
|
||||
private static Stringify<HsOfficePartnerRbacEntity> 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<HsOffice
|
||||
private HsOfficePartnerDetailsEntity details;
|
||||
|
||||
@Override
|
||||
public HsOfficePartnerEntity load() {
|
||||
public HsOfficePartnerRbacEntity load() {
|
||||
BaseEntity.super.load();
|
||||
partnerRel.load();
|
||||
if (details != null) {
|
||||
@ -103,7 +103,7 @@ public class HsOfficePartnerEntity implements Stringifyable, BaseEntity<HsOffice
|
||||
}
|
||||
|
||||
public static RbacSpec rbac() {
|
||||
return rbacViewFor("partner", HsOfficePartnerEntity.class)
|
||||
return rbacViewFor("partner", HsOfficePartnerRbacEntity.class)
|
||||
.withIdentityView(SQL.projection("'P-' || partnerNumber"))
|
||||
.withUpdatableColumns("partnerRelUuid")
|
||||
.toRole(GLOBAL, ADMIN).grantPermission(INSERT)
|
@ -8,27 +8,14 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface HsOfficePartnerRepository extends Repository<HsOfficePartnerEntity, UUID> {
|
||||
public interface HsOfficePartnerRbacRepository extends Repository<HsOfficePartnerRbacEntity, UUID> {
|
||||
|
||||
@Timed("app.office.partners.repo.findByUuid")
|
||||
Optional<HsOfficePartnerEntity> findByUuid(UUID id);
|
||||
Optional<HsOfficePartnerRbacEntity> findByUuid(UUID id);
|
||||
|
||||
@Timed("app.office.partners.repo.findAll")
|
||||
List<HsOfficePartnerEntity> findAll(); // TODO.refa: move to a repo in test sources
|
||||
List<HsOfficePartnerRbacEntity> 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<HsOfficePartnerEnt
|
||||
or partnerPerson.familyname like (cast(:name as text) || '%') escape ''
|
||||
""", nativeQuery = true)
|
||||
@Timed("app.office.partners.repo.findPartnerByOptionalNameLike")
|
||||
List<HsOfficePartnerEntity> findPartnerByOptionalNameLike(String name);
|
||||
List<HsOfficePartnerRbacEntity> findPartnerByOptionalNameLike(String name);
|
||||
|
||||
@Timed("app.office.partners.repo.findPartnerByPartnerNumber")
|
||||
Optional<HsOfficePartnerEntity> findPartnerByPartnerNumber(Integer partnerNumber);
|
||||
Optional<HsOfficePartnerRbacEntity> 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();
|
@ -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<Integer, HsOfficeContactRealEntity> contacts = new WriteOnceMap<>();
|
||||
static Map<Integer, HsOfficePersonRealEntity> persons = new WriteOnceMap<>();
|
||||
static Map<Integer, HsOfficePartnerEntity> partners = new WriteOnceMap<>();
|
||||
static Map<Integer, HsOfficePartnerRbacEntity> partners = new WriteOnceMap<>();
|
||||
static Map<Integer, HsOfficeDebitorEntity> debitors = new WriteOnceMap<>();
|
||||
static Map<Integer, HsOfficeMembershipEntity> 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)
|
||||
|
@ -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))
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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()));
|
||||
|
||||
|
@ -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()
|
||||
);
|
||||
|
@ -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
|
||||
|
@ -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<HsOfficePartnerEntity> actualResult, final String... partnerNames) {
|
||||
void exactlyThesePartnersAreReturned(final List<HsOfficePartnerRbacEntity> actualResult, final String... partnerNames) {
|
||||
assertThat(actualResult)
|
||||
.extracting(HsOfficePartnerEntity::toString)
|
||||
.extracting(HsOfficePartnerRbacEntity::toString)
|
||||
.containsExactlyInAnyOrder(partnerNames);
|
||||
}
|
||||
|
||||
void allThesePartnersAreReturned(final List<HsOfficePartnerEntity> actualResult, final String... partnerNames) {
|
||||
void allThesePartnersAreReturned(final List<HsOfficePartnerRbacEntity> 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) {
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user