From b16c9f053a9209dcc37aa01dac10fb84a8d8bd8d Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Tue, 26 Nov 2024 22:51:04 +0100 Subject: [PATCH 01/13] add view for Znuny: ticket_customer_user --- .../9-hs-global/9120-integration-znuny.sql | 36 +++++++++++++++---- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/src/main/resources/db/changelog/9-hs-global/9120-integration-znuny.sql b/src/main/resources/db/changelog/9-hs-global/9120-integration-znuny.sql index 0247ec53..4fcc4b84 100644 --- a/src/main/resources/db/changelog/9-hs-global/9120-integration-znuny.sql +++ b/src/main/resources/db/changelog/9-hs-global/9120-integration-znuny.sql @@ -5,10 +5,11 @@ --changeset timotheus.pokorra:hs-global-integration-znuny endDelimiter:--// -- TODO.impl: also select column debitorNumber and do not filter anymore for '00' CREATE OR REPLACE VIEW hs_integration.contact AS - SELECT DISTINCT ON (uuid) + SELECT DISTINCT ON (contact_uuid) partner.partnernumber as partnernumber, debitor.defaultprefix as defaultprefix, - c.uuid as uuid, + partner.uuid as partner_uuid, + c.uuid as contact_uuid, (CASE WHEN per.salutation <> '' THEN per.salutation ELSE NULL END) as salutation, (CASE WHEN per.givenname <> '' THEN per.givenname ELSE NULL END) as givenname, (CASE WHEN per.familyname <> '' THEN per.familyname ELSE NULL END) as familyname, @@ -38,10 +39,11 @@ CREATE OR REPLACE VIEW hs_integration.contact AS JOIN hs_office.contact AS c ON c.uuid = pRel.contactuuid JOIN hs_office.person AS per ON per.uuid = pRel.holderuuid UNION - SELECT DISTINCT ON (uuid) + SELECT DISTINCT ON (contact_uuid) partner.partnernumber as partnernumber, debitor.defaultprefix as defaultprefix, - c.uuid as uuid, + partner.uuid as partner_uuid, + c.uuid as contact_uuid, (CASE WHEN per.salutation <> '' THEN per.salutation ELSE NULL END) as salutation, (CASE WHEN per.givenname <> '' THEN per.givenname ELSE NULL END) as givenname, (CASE WHEN per.familyname <> '' THEN per.familyname ELSE NULL END) as familyname, @@ -73,7 +75,7 @@ CREATE OR REPLACE VIEW hs_integration.contact AS JOIN hs_office.person AS per ON per.uuid = relation.holderuuid; CREATE OR REPLACE VIEW hs_integration.ticket_customer_user AS - SELECT c.uuid, + SELECT c.contact_uuid, max(c.partnernumber)::text as number, max(c.defaultprefix) as code, max(c.email) as login, @@ -96,7 +98,27 @@ CREATE OR REPLACE VIEW hs_integration.ticket_customer_user AS string_agg(CASE WHEN relation.mark IS NULL THEN relation.type::text ELSE CONCAT(relation.type::text, ':', relation.mark::text) END, '/'::text) AS comment, 1 AS valid FROM hs_integration.contact AS c - JOIN hs_office.relation AS relation ON c.uuid = relation.contactuuid + JOIN hs_office.relation AS relation ON c.contact_uuid = relation.contactuuid WHERE (c.defaultprefix != 'hsh' OR (c.partnernumber = 10000 AND c.email = 'hostmaster@hostsharing.net')) - GROUP BY c.uuid; + GROUP BY c.contact_uuid; + +CREATE OR REPLACE VIEW hs_integration.ticket_customer_company AS + SELECT + partner.partnernumber::text as number, + debitor.defaultprefix as code, + concat_ws('/'::text, to_char(lower(membership.validity), 'YYYY-MM-DD'::text), to_char(upper(membership.validity) - INTERVAL '1 days', 'YYYY-MM-DD'::text)) AS comment, + 1 AS valid + FROM hs_office.partner AS partner + JOIN hs_office.relation AS pRel + ON pRel.type = 'PARTNER' + AND pRel.uuid = partner.partnerRelUuid + JOIN hs_office.relation AS dRel + ON dRel.type = 'DEBITOR' + AND dRel.anchorUuid = pRel.holderUuid + JOIN hs_office.debitor AS debitor + ON debitor.debitorreluuid = dRel.uuid + AND debitor.debitornumbersuffix = '00' + LEFT OUTER JOIN hs_office.membership AS membership ON membership.partneruuid = partner.uuid + ORDER BY number; + --// \ No newline at end of file -- 2.39.5 From ef1502c7261c63d3c4d01de1b69bcb42c2a8e64a Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Thu, 28 Nov 2024 11:04:39 +0100 Subject: [PATCH 02/13] fix for matching asset transactions --- .../hs/migration/BaseOfficeDataImport.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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 3ab17692..e8e5090f 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java @@ -880,17 +880,20 @@ public abstract class BaseOfficeDataImport extends CsvDataImport { coopAssets.put(rec.getInteger("member_asset_id"), assetTransaction); }); - coopAssets.values().forEach(assetTransaction -> { + + coopAssets.entrySet().forEach(entry -> { + final var legacyId = entry.getKey(); + final var assetTransaction = entry.getValue(); if (assetTransaction.getTransactionType() == HsOfficeCoopAssetsTransactionType.REVERSAL) { - connectToRelatedRevertedAssetTx(assetTransaction); + connectToRelatedRevertedAssetTx(legacyId, assetTransaction); } if (assetTransaction.getTransactionType() == HsOfficeCoopAssetsTransactionType.TRANSFER) { - connectToRelatedAdoptionAssetTx(assetTransaction); + connectToRelatedAdoptionAssetTx(legacyId, assetTransaction); } }); } - private static void connectToRelatedRevertedAssetTx(final HsOfficeCoopAssetsTransactionEntity assetTransaction) { + private static void connectToRelatedRevertedAssetTx(final int legacyId, final HsOfficeCoopAssetsTransactionEntity assetTransaction) { final var negativeValue = assetTransaction.getAssetValue().negate(); final var revertedAssetTx = coopAssets.values().stream().filter(a -> a.getTransactionType() != HsOfficeCoopAssetsTransactionType.REVERSAL && @@ -903,10 +906,11 @@ public abstract class BaseOfficeDataImport extends CsvDataImport { //revertedAssetTx.setAssetReversalTx(assetTransaction); } - private static void connectToRelatedAdoptionAssetTx(final HsOfficeCoopAssetsTransactionEntity assetTransaction) { + private static void connectToRelatedAdoptionAssetTx(final int legacyId, final HsOfficeCoopAssetsTransactionEntity assetTransaction) { final var negativeValue = assetTransaction.getAssetValue().negate(); final var adoptionAssetTx = coopAssets.values().stream().filter(a -> a.getTransactionType() == HsOfficeCoopAssetsTransactionType.ADOPTION && + (!a.getValueDate().equals(LocalDate.of( 2014 , 12 , 31)) || a.getComment().contains(Integer.toString(assetTransaction.getMembership().getMemberNumber()/100))) && a.getMembership() != assetTransaction.getMembership() && a.getValueDate().equals(assetTransaction.getValueDate()) && a.getAssetValue().equals(negativeValue)) -- 2.39.5 From 2adfc490aded6d3d56e1492fad5221843990d788 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Tue, 3 Dec 2024 16:17:04 +0100 Subject: [PATCH 03/13] @Timed for relations, customers and persons, also refactored controller methods towards HTTP verbs --- .../office/contact/HsOfficeContactController.java | 12 +++++++++--- .../contact/HsOfficeContactRbacRepository.java | 8 +++++++- .../contact/HsOfficeContactRealRepository.java | 8 +++++++- .../hs/office/person/HsOfficePersonController.java | 12 +++++++++--- .../hs/office/person/HsOfficePersonRepository.java | 8 +++++++- .../office/relation/HsOfficeRelationController.java | 13 +++++++++---- .../relation/HsOfficeRelationRbacRepository.java | 7 +++++++ .../relation/HsOfficeRelationRealRepository.java | 7 +++++++ .../hs-office/hs-office-contacts-with-uuid.yaml | 2 +- .../hs-office/hs-office-contacts.yaml | 4 ++-- .../hs-office/hs-office-persons-with-uuid.yaml | 2 +- .../api-definition/hs-office/hs-office-persons.yaml | 4 ++-- .../hs-office/hs-office-relations-with-uuid.yaml | 2 +- .../hs-office/hs-office-relations.yaml | 4 ++-- src/main/resources/application.yml | 12 +++++++++++- .../HsOfficePersonControllerAcceptanceTest.java | 2 +- .../HsOfficeRelationControllerAcceptanceTest.java | 2 +- 17 files changed, 84 insertions(+), 25 deletions(-) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactController.java index 0f94e858..5c6a8a3a 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactController.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.office.contact; +import io.micrometer.core.annotation.Timed; import net.hostsharing.hsadminng.mapper.StandardMapper; import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeContactsApi; @@ -33,7 +34,8 @@ public class HsOfficeContactController implements HsOfficeContactsApi { @Override @Transactional(readOnly = true) - public ResponseEntity> listContacts( + @Timed("app.contacts.api.getListOfContacts") + public ResponseEntity> getListOfContacts( final String currentSubject, final String assumedRoles, final String caption) { @@ -47,7 +49,8 @@ public class HsOfficeContactController implements HsOfficeContactsApi { @Override @Transactional - public ResponseEntity addContact( + @Timed("app.contacts.api.postNewContact") + public ResponseEntity postNewContact( final String currentSubject, final String assumedRoles, final HsOfficeContactInsertResource body) { @@ -69,7 +72,8 @@ public class HsOfficeContactController implements HsOfficeContactsApi { @Override @Transactional(readOnly = true) - public ResponseEntity getContactByUuid( + @Timed("app.contacts.api.getSingleContactByUuid") + public ResponseEntity getSingleContactByUuid( final String currentSubject, final String assumedRoles, final UUID contactUuid) { @@ -85,6 +89,7 @@ public class HsOfficeContactController implements HsOfficeContactsApi { @Override @Transactional + @Timed("app.contacts.api.deleteContactByUuid") public ResponseEntity deleteContactByUuid( final String currentSubject, final String assumedRoles, @@ -101,6 +106,7 @@ public class HsOfficeContactController implements HsOfficeContactsApi { @Override @Transactional + @Timed("app.contacts.api.patchContact") public ResponseEntity patchContact( final String currentSubject, final String assumedRoles, diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactRbacRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactRbacRepository.java index e893bced..58f9ba61 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactRbacRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactRbacRepository.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.office.contact; +import io.micrometer.core.annotation.Timed; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; @@ -9,18 +10,23 @@ import java.util.UUID; public interface HsOfficeContactRbacRepository extends Repository { + @Timed("app.contacts.repo.findByUuid.rbac") Optional findByUuid(UUID id); @Query(""" SELECT c FROM HsOfficeContactRbacEntity c WHERE :caption is null OR c.caption like concat(cast(:caption as text), '%') - """) + """) + @Timed("app.contacts.repo.findContactByOptionalCaptionLike.rbac") List findContactByOptionalCaptionLike(String caption); + @Timed("app.contacts.repo.save.rbac") HsOfficeContactRbacEntity save(final HsOfficeContactRbacEntity entity); + @Timed("app.contacts.repo.deleteByUuid.rbac") int deleteByUuid(final UUID uuid); + @Timed("app.contacts.repo.count.rbac") long count(); } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactRealRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactRealRepository.java index b4099422..a42c2226 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactRealRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactRealRepository.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.office.contact; +import io.micrometer.core.annotation.Timed; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; @@ -9,18 +10,23 @@ import java.util.UUID; public interface HsOfficeContactRealRepository extends Repository { + @Timed("app.repo.contacts.findByUuid.real") Optional findByUuid(UUID id); @Query(""" SELECT c FROM HsOfficeContactRealEntity c WHERE :caption is null OR c.caption like concat(cast(:caption as text), '%') - """) + """) + @Timed("app.repo.contacts.findContactByOptionalCaptionLike.real") List findContactByOptionalCaptionLike(String caption); + @Timed("app.repo.contacts.save.real") HsOfficeContactRealEntity save(final HsOfficeContactRealEntity entity); + @Timed("app.repo.contacts.deleteByUuid.real") int deleteByUuid(final UUID uuid); + @Timed("app.repo.contacts.count.real") long count(); } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonController.java index ac746aab..d1c1c018 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonController.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.office.person; +import io.micrometer.core.annotation.Timed; import net.hostsharing.hsadminng.mapper.StandardMapper; import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficePersonsApi; @@ -30,7 +31,8 @@ public class HsOfficePersonController implements HsOfficePersonsApi { @Override @Transactional(readOnly = true) - public ResponseEntity> listPersons( + @Timed("app.persons.api.getListOfPersons") + public ResponseEntity> getListOfPersons( final String currentSubject, final String assumedRoles, final String caption) { @@ -44,7 +46,8 @@ public class HsOfficePersonController implements HsOfficePersonsApi { @Override @Transactional - public ResponseEntity addPerson( + @Timed("app.persons.api.postNewPerson") + public ResponseEntity postNewPerson( final String currentSubject, final String assumedRoles, final HsOfficePersonInsertResource body) { @@ -66,7 +69,8 @@ public class HsOfficePersonController implements HsOfficePersonsApi { @Override @Transactional(readOnly = true) - public ResponseEntity getPersonByUuid( + @Timed("app.persons.api.getSinglePersonByUuid") + public ResponseEntity getSinglePersonByUuid( final String currentSubject, final String assumedRoles, final UUID personUuid) { @@ -82,6 +86,7 @@ public class HsOfficePersonController implements HsOfficePersonsApi { @Override @Transactional + @Timed("app.persons.api.deletePersonByUuid") public ResponseEntity deletePersonByUuid( final String currentSubject, final String assumedRoles, @@ -98,6 +103,7 @@ public class HsOfficePersonController implements HsOfficePersonsApi { @Override @Transactional + @Timed("app.persons.api.patchPerson") public ResponseEntity patchPerson( final String currentSubject, final String assumedRoles, diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRepository.java index f7481339..41d195ce 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRepository.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.office.person; +import io.micrometer.core.annotation.Timed; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; @@ -9,6 +10,7 @@ import java.util.UUID; public interface HsOfficePersonRepository extends Repository { + @Timed("app.persons.repo.findByUuid.rbac") Optional findByUuid(UUID personUuid); @Query(""" @@ -17,12 +19,16 @@ public interface HsOfficePersonRepository extends Repository findPersonByOptionalNameLike(String name); + @Timed("app.persons.repo.save.rbac") HsOfficePersonEntity save(final HsOfficePersonEntity entity); + @Timed("app.persons.repo.deleteByUuid.rbac") int deleteByUuid(final UUID personUuid); + @Timed("app.persons.repo.count.rbac") long count(); } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationController.java index 29078bb3..5778d864 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationController.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.office.relation; +import io.micrometer.core.annotation.Timed; import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealRepository; import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeRelationsApi; @@ -21,7 +22,6 @@ import java.util.function.BiConsumer; @RestController - public class HsOfficeRelationController implements HsOfficeRelationsApi { @Autowired @@ -44,7 +44,8 @@ public class HsOfficeRelationController implements HsOfficeRelationsApi { @Override @Transactional(readOnly = true) - public ResponseEntity> listRelations( + @Timed("app.relations.api.getListOfRelations") + public ResponseEntity> getListOfRelations( final String currentSubject, final String assumedRoles, final UUID personUuid, @@ -66,7 +67,8 @@ public class HsOfficeRelationController implements HsOfficeRelationsApi { @Override @Transactional - public ResponseEntity addRelation( + @Timed("app.relations.api.postNewRelation") + public ResponseEntity postNewRelation( final String currentSubject, final String assumedRoles, final HsOfficeRelationInsertResource body) { @@ -100,7 +102,8 @@ public class HsOfficeRelationController implements HsOfficeRelationsApi { @Override @Transactional(readOnly = true) - public ResponseEntity getRelationByUuid( + @Timed("app.relations.api.getSingleRelationByUuid") + public ResponseEntity getSingleRelationByUuid( final String currentSubject, final String assumedRoles, final UUID relationUuid) { @@ -116,6 +119,7 @@ public class HsOfficeRelationController implements HsOfficeRelationsApi { @Override @Transactional + @Timed("apprelations.api..deleteRelationByUuid") public ResponseEntity deleteRelationByUuid( final String currentSubject, final String assumedRoles, @@ -132,6 +136,7 @@ public class HsOfficeRelationController implements HsOfficeRelationsApi { @Override @Transactional + @Timed("app.relations.api.patchRelation") public ResponseEntity patchRelation( final String currentSubject, final String assumedRoles, diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRbacRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRbacRepository.java index cce31305..23889745 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRbacRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRbacRepository.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.office.relation; +import io.micrometer.core.annotation.Timed; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; @@ -10,12 +11,14 @@ import java.util.UUID; public interface HsOfficeRelationRbacRepository extends Repository { + @Timed("app.relations.repo.findByUuid.rbac") Optional findByUuid(UUID id); @Query(value = """ SELECT p.* FROM hs_office.relation_rv AS p WHERE p.anchorUuid = :personUuid OR p.holderUuid = :personUuid """, nativeQuery = true) + @Timed("app.relations.repo.findRelationRelatedToPersonUuid.rbac") List findRelationRelatedToPersonUuid(@NotNull UUID personUuid); /** @@ -51,16 +54,20 @@ public interface HsOfficeRelationRbacRepository extends Repository findRelationRelatedToPersonUuidRelationTypePersonAndContactDataImpl( final UUID personUuid, final String relationType, final String personData, final String contactData); + @Timed("app.relations.repo.save.rbac") HsOfficeRelationRbacEntity save(final HsOfficeRelationRbacEntity entity); + @Timed("app.relations.repo.count.rbac") long count(); + @Timed("app.relations.repo.deleteByUuid.rbac") int deleteByUuid(UUID uuid); private static String toSqlLikeOperand(final String text) { diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRealRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRealRepository.java index 292f9034..bd1eac0c 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRealRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRealRepository.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.office.relation; +import io.micrometer.core.annotation.Timed; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; @@ -10,6 +11,7 @@ import java.util.UUID; public interface HsOfficeRelationRealRepository extends Repository { + @Timed("app.repo.relations.findByUuid.real") Optional findByUuid(UUID id); default List findRelationRelatedToPersonUuidAndRelationType(@NotNull UUID personUuid, HsOfficeRelationType relationType) { @@ -20,6 +22,7 @@ public interface HsOfficeRelationRealRepository extends Repository findRelationRelatedToPersonUuid(@NotNull UUID personUuid); @Query(value = """ @@ -27,11 +30,15 @@ public interface HsOfficeRelationRealRepository extends Repository findRelationRelatedToPersonUuidAndRelationTypeString(@NotNull UUID personUuid, String relationType); + @Timed("app.repo.relations.save.real") HsOfficeRelationRealEntity save(final HsOfficeRelationRealEntity entity); + @Timed("app.repo.relations.count.real") long count(); + @Timed("app.repo.relations.deleteByUuid.real") int deleteByUuid(UUID uuid); } diff --git a/src/main/resources/api-definition/hs-office/hs-office-contacts-with-uuid.yaml b/src/main/resources/api-definition/hs-office/hs-office-contacts-with-uuid.yaml index a6561e8d..9f808b25 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-contacts-with-uuid.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-contacts-with-uuid.yaml @@ -2,7 +2,7 @@ get: tags: - hs-office-contacts description: 'Fetch a single business contact by its uuid, if visible for the current subject.' - operationId: getContactByUuid + operationId: getSingleContactByUuid parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' diff --git a/src/main/resources/api-definition/hs-office/hs-office-contacts.yaml b/src/main/resources/api-definition/hs-office/hs-office-contacts.yaml index cc3f56af..f7412ddf 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-contacts.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-contacts.yaml @@ -3,7 +3,7 @@ get: description: Returns the list of (optionally filtered) contacts which are visible to the current subject or any of it's assumed roles. tags: - hs-office-contacts - operationId: listContacts + operationId: getListOfContacts parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' @@ -31,7 +31,7 @@ post: summary: Adds a new contact. tags: - hs-office-contacts - operationId: addContact + operationId: postNewContact parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' diff --git a/src/main/resources/api-definition/hs-office/hs-office-persons-with-uuid.yaml b/src/main/resources/api-definition/hs-office/hs-office-persons-with-uuid.yaml index fe63c509..a983e90f 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-persons-with-uuid.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-persons-with-uuid.yaml @@ -2,7 +2,7 @@ get: tags: - hs-office-persons description: 'Fetch a single business person by its uuid, if visible for the current subject.' - operationId: getPersonByUuid + operationId: getSinglePersonByUuid parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' diff --git a/src/main/resources/api-definition/hs-office/hs-office-persons.yaml b/src/main/resources/api-definition/hs-office/hs-office-persons.yaml index e761957c..b17f1a93 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-persons.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-persons.yaml @@ -3,7 +3,7 @@ get: description: Returns the list of (optionally filtered) persons which are visible to the current subject or any of it's assumed roles. tags: - hs-office-persons - operationId: listPersons + operationId: getListOfPersons parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' @@ -31,7 +31,7 @@ post: summary: Adds a new person. tags: - hs-office-persons - operationId: addPerson + operationId: postNewPerson parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' diff --git a/src/main/resources/api-definition/hs-office/hs-office-relations-with-uuid.yaml b/src/main/resources/api-definition/hs-office/hs-office-relations-with-uuid.yaml index 3dbe1391..b492f322 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-relations-with-uuid.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-relations-with-uuid.yaml @@ -2,7 +2,7 @@ get: tags: - hs-office-relations description: 'Fetch a single person relation by its uuid, if visible for the current subject.' - operationId: getRelationByUuid + operationId: getSingleRelationByUuid parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' diff --git a/src/main/resources/api-definition/hs-office/hs-office-relations.yaml b/src/main/resources/api-definition/hs-office/hs-office-relations.yaml index 77d9dda0..70218c00 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-relations.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-relations.yaml @@ -5,7 +5,7 @@ get: To match data, all given query parameters must be fulfilled ('and' / logical conjunction). tags: - hs-office-relations - operationId: listRelations + operationId: getListOfRelations parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' @@ -52,7 +52,7 @@ post: summary: Adds a new person relation. tags: - hs-office-relations - operationId: addRelation + operationId: postNewRelation parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 9cfd265f..27020234 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -9,9 +9,11 @@ management: web: exposure: include: info, health, metrics + observations: + annotations: + enabled: true spring: - datasource: driver-class-name: org.postgresql.Driver password: password @@ -33,3 +35,11 @@ liquibase: hsadminng: postgres: leakproof: + +metrics: + distribution: + percentiles-histogram: + http: + server: + requests: true + diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonControllerAcceptanceTest.java index 7ab55de0..d0228ad2 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonControllerAcceptanceTest.java @@ -52,7 +52,7 @@ class HsOfficePersonControllerAcceptanceTest extends ContextBasedTestWithCleanup EntityManager em; @Nested - class ListPersons { + class GetListOfPersons { @Test void globalAdmin_withoutAssumedRoles_canViewAllPersons_ifNoCriteriaGiven() { diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationControllerAcceptanceTest.java index b65ae95e..02a228f5 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationControllerAcceptanceTest.java @@ -54,7 +54,7 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean JpaAttempt jpaAttempt; @Nested - class ListRelations { + class GetListOfRelations { @Test void globalAdmin_withoutAssumedRoles_canViewAllRelationsOfGivenPersonAndType() { -- 2.39.5 From 0559c8de97e0e68ddf01b880d70abc9d9cb1b6c5 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 4 Dec 2024 09:15:42 +0100 Subject: [PATCH 04/13] @Timed for partners and debitors and Controller method name refactoring --- .../hs/office/debitor/HsOfficeDebitorController.java | 6 ++++++ .../hs/office/debitor/HsOfficeDebitorRepository.java | 9 ++++++++- .../hs/office/partner/HsOfficePartnerController.java | 12 +++++++++--- .../hs/office/partner/HsOfficePartnerRepository.java | 11 ++++++++++- .../hs-office/hs-office-partners-with-uuid.yaml | 2 +- .../api-definition/hs-office/hs-office-partners.yaml | 4 ++-- .../HsOfficePartnerControllerAcceptanceTest.java | 10 +++++----- .../partner/HsOfficePartnerControllerRestTest.java | 2 +- 8 files changed, 42 insertions(+), 14 deletions(-) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorController.java index 011db6a2..391f7a2d 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorController.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.office.debitor; +import io.micrometer.core.annotation.Timed; import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeDebitorsApi; import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeDebitorInsertResource; @@ -51,6 +52,7 @@ public class HsOfficeDebitorController implements HsOfficeDebitorsApi { @Override @Transactional(readOnly = true) + @Timed("app.debitors.api.getListOfDebitors") public ResponseEntity> getListOfDebitors( final String currentSubject, final String assumedRoles, @@ -68,6 +70,7 @@ public class HsOfficeDebitorController implements HsOfficeDebitorsApi { @Override @Transactional + @Timed("app.debitors.api.postNewDebitor") public ResponseEntity postNewDebitor( String currentSubject, String assumedRoles, @@ -115,6 +118,7 @@ public class HsOfficeDebitorController implements HsOfficeDebitorsApi { @Override @Transactional(readOnly = true) + @Timed("app.debitors.api.getSingleDebitorByUuid") public ResponseEntity getSingleDebitorByUuid( final String currentSubject, final String assumedRoles, @@ -131,6 +135,7 @@ public class HsOfficeDebitorController implements HsOfficeDebitorsApi { @Override @Transactional + @Timed("app.debitors.api.deleteDebitorByUuid") public ResponseEntity deleteDebitorByUuid( final String currentSubject, final String assumedRoles, @@ -147,6 +152,7 @@ public class HsOfficeDebitorController implements HsOfficeDebitorsApi { @Override @Transactional + @Timed("app.debitors.api.patchDebitor") public ResponseEntity patchDebitor( final String currentSubject, final String assumedRoles, diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepository.java index 30dabb59..3eb1835e 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepository.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.office.debitor; +import io.micrometer.core.annotation.Timed; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; @@ -9,6 +10,7 @@ import java.util.UUID; public interface HsOfficeDebitorRepository extends Repository { + @Timed("app.debitors.repo.findByUuid") Optional findByUuid(UUID id); @Query(""" @@ -19,7 +21,8 @@ public interface HsOfficeDebitorRepository extends Repository findDebitorByDebitorNumber(int partnerNumber, String debitorNumberSuffix); + @Timed("app.debitors.repo.findDebitorByDebitorNumber") + List findDebitorByDebitorNumber(int partnerNumber, String debitorNumberSuffix); default List findDebitorByDebitorNumber(int debitorNumber) { final var partnerNumber = debitorNumber / 100; @@ -46,11 +49,15 @@ public interface HsOfficeDebitorRepository extends Repository findDebitorByOptionalNameLike(String name); + @Timed("app.debitors.repo.save") HsOfficeDebitorEntity save(final HsOfficeDebitorEntity entity); + @Timed("app.debitors.repo.count") long count(); + @Timed("app.debitors.repo.deleteByUuid") int deleteByUuid(UUID uuid); } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerController.java index c39dcd49..c2f66594 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerController.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.office.partner; +import io.micrometer.core.annotation.Timed; import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.errors.ReferenceNotFoundException; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealEntity; @@ -50,7 +51,8 @@ public class HsOfficePartnerController implements HsOfficePartnersApi { @Override @Transactional(readOnly = true) - public ResponseEntity> listPartners( + @Timed("app.partners.api.getListOfPartners") + public ResponseEntity> getListOfPartners( final String currentSubject, final String assumedRoles, final String name) { @@ -64,7 +66,8 @@ public class HsOfficePartnerController implements HsOfficePartnersApi { @Override @Transactional - public ResponseEntity addPartner( + @Timed("app.partners.api.postNewPartner") + public ResponseEntity postNewPartner( final String currentSubject, final String assumedRoles, final HsOfficePartnerInsertResource body) { @@ -86,7 +89,8 @@ public class HsOfficePartnerController implements HsOfficePartnersApi { @Override @Transactional(readOnly = true) - public ResponseEntity getPartnerByUuid( + @Timed("app.partners.api.getSinglePartnerByUuid") + public ResponseEntity getSinglePartnerByUuid( final String currentSubject, final String assumedRoles, final UUID partnerUuid) { @@ -102,6 +106,7 @@ public class HsOfficePartnerController implements HsOfficePartnersApi { @Override @Transactional + @Timed("app.partners.api.deletePartnerByUuid") public ResponseEntity deletePartnerByUuid( final String currentSubject, final String assumedRoles, @@ -122,6 +127,7 @@ public class HsOfficePartnerController implements HsOfficePartnersApi { @Override @Transactional + @Timed("app.partners.api.patchPartner") public ResponseEntity patchPartner( final String currentSubject, final String assumedRoles, diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRepository.java index 2c5913a5..24a52568 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRepository.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.office.partner; +import io.micrometer.core.annotation.Timed; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; @@ -9,9 +10,11 @@ import java.util.UUID; public interface HsOfficePartnerRepository extends Repository { + @Timed("app.partners.repo.findByUuid") Optional findByUuid(UUID id); - List findAll(); // TODO.impl: move to a repo in test sources + @Timed("app.partners.repo.findAll") + List findAll(); // TODO.refa: move to a repo in test sources @Query(""" SELECT partner FROM HsOfficePartnerEntity partner @@ -25,12 +28,18 @@ public interface HsOfficePartnerRepository extends Repository findPartnerByOptionalNameLike(String name); + + @Timed("app.partners.repo.findPartnerByPartnerNumber") HsOfficePartnerEntity findPartnerByPartnerNumber(Integer partnerNumber); + @Timed("app.partners.repo.save") HsOfficePartnerEntity save(final HsOfficePartnerEntity entity); + @Timed("app.partners.repo.count") long count(); + @Timed("app.partners.repo.deleteByUuid") int deleteByUuid(UUID uuid); } diff --git a/src/main/resources/api-definition/hs-office/hs-office-partners-with-uuid.yaml b/src/main/resources/api-definition/hs-office/hs-office-partners-with-uuid.yaml index e19e6cd2..704a54a1 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-partners-with-uuid.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-partners-with-uuid.yaml @@ -2,7 +2,7 @@ get: tags: - hs-office-partners description: 'Fetch a single business partner by its uuid, if visible for the current subject.' - operationId: getPartnerByUuid + operationId: getSinglePartnerByUuid parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' diff --git a/src/main/resources/api-definition/hs-office/hs-office-partners.yaml b/src/main/resources/api-definition/hs-office/hs-office-partners.yaml index 9e97a91d..67df42b3 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-partners.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-partners.yaml @@ -3,7 +3,7 @@ get: description: Returns the list of (optionally filtered) business partners which are visible to the current subject or any of it's assumed roles. tags: - hs-office-partners - operationId: listPartners + operationId: getListOfPartners parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' @@ -31,7 +31,7 @@ post: summary: Adds a new business partner. tags: - hs-office-partners - operationId: addPartner + operationId: postNewPartner parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' 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 82472faa..5f82a9d3 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 @@ -58,7 +58,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu @Nested @Transactional - class ListPartners { + class GetListOfPartners { @Test void globalAdmin_withoutAssumedRoles_canViewAllPartners_ifNoCriteriaGiven() { @@ -87,10 +87,10 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu @Nested @Transactional - class AddPartner { + class PostNewPartner { @Test - void globalAdmin_withoutAssumedRole_canAddPartner() { + void globalAdmin_withoutAssumedRole_canPostNewPartner() { context.define("superuser-alex@hostsharing.net"); final var givenMandantPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").stream().findFirst().orElseThrow(); @@ -150,7 +150,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu } @Test - void globalAdmin_canNotAddPartner_ifContactDoesNotExist() { + void globalAdmin_canNotPostNewPartner_ifContactDoesNotExist() { context.define("superuser-alex@hostsharing.net"); final var givenMandantPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").get(0); @@ -188,7 +188,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu } @Test - void globalAdmin_canNotAddPartner_ifPersonDoesNotExist() { + void globalAdmin_canNotPostNewPartner_ifPersonDoesNotExist() { context.define("superuser-alex@hostsharing.net"); final var mandantPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").get(0); 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 caf1fe6f..31e0786d 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 @@ -91,7 +91,7 @@ class HsOfficePartnerControllerRestTest { } @Nested - class AddPartner { + class PostNewPartner { @Test void respondBadRequest_ifPersonUuidIsInvalid() throws Exception { -- 2.39.5 From 551537f1b1c16c130447406224238d1da73730e8 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 4 Dec 2024 09:26:35 +0100 Subject: [PATCH 05/13] @Timed for bankAccounts and sepaMandates and Controller method name refactoring --- .../bankaccount/HsOfficeBankAccountController.java | 11 ++++++++--- .../bankaccount/HsOfficeBankAccountRepository.java | 10 +++++++++- .../sepamandate/HsOfficeSepaMandateController.java | 12 +++++++++--- .../sepamandate/HsOfficeSepaMandateRepository.java | 8 +++++++- .../hs-office/hs-office-bankaccounts-with-uuid.yaml | 2 +- .../hs-office/hs-office-bankaccounts.yaml | 4 ++-- .../hs-office/hs-office-sepamandates-with-uuid.yaml | 2 +- .../hs-office/hs-office-sepamandates.yaml | 4 ++-- .../HsOfficeBankAccountControllerAcceptanceTest.java | 4 ++-- ...HsOfficeBankAccountRepositoryIntegrationTest.java | 2 +- .../HsOfficeSepaMandateControllerAcceptanceTest.java | 10 +++++----- 11 files changed, 47 insertions(+), 22 deletions(-) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountController.java index 69295853..50087bf4 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountController.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.office.bankaccount; +import io.micrometer.core.annotation.Timed; import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeBankAccountsApi; import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeBankAccountInsertResource; @@ -31,7 +32,8 @@ public class HsOfficeBankAccountController implements HsOfficeBankAccountsApi { @Override @Transactional(readOnly = true) - public ResponseEntity> listBankAccounts( + @Timed("app.bankAccounts.api.patchDebitor") + public ResponseEntity> getListOfBankAccounts( final String currentSubject, final String assumedRoles, final String holder) { @@ -45,7 +47,8 @@ public class HsOfficeBankAccountController implements HsOfficeBankAccountsApi { @Override @Transactional - public ResponseEntity addBankAccount( + @Timed("app.bankAccounts.api.postNewBankAccount") + public ResponseEntity postNewBankAccount( final String currentSubject, final String assumedRoles, final HsOfficeBankAccountInsertResource body) { @@ -71,7 +74,8 @@ public class HsOfficeBankAccountController implements HsOfficeBankAccountsApi { @Override @Transactional(readOnly = true) - public ResponseEntity getBankAccountByUuid( + @Timed("app.bankAccounts.api.getSingleBankAccountByUuid") + public ResponseEntity getSingleBankAccountByUuid( final String currentSubject, final String assumedRoles, final UUID bankAccountUuid) { @@ -87,6 +91,7 @@ public class HsOfficeBankAccountController implements HsOfficeBankAccountsApi { @Override @Transactional + @Timed("app.bankAccounts.api.deleteBankAccountByUuid") public ResponseEntity deleteBankAccountByUuid( final String currentSubject, final String assumedRoles, diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountRepository.java index 11de3bdb..ecc1b2c0 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountRepository.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.office.bankaccount; +import io.micrometer.core.annotation.Timed; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; @@ -9,23 +10,30 @@ import java.util.UUID; public interface HsOfficeBankAccountRepository extends Repository { + @Timed("app.bankAccounts.repo.findByUuid") Optional findByUuid(UUID id); @Query(""" SELECT c FROM HsOfficeBankAccountEntity c WHERE lower(c.holder) like lower(concat(:holder, '%')) ORDER BY c.holder - """) + """) + @Timed("app.bankAccounts.repo.findByOptionalHolderLikeImpl") List findByOptionalHolderLikeImpl(String holder); default List findByOptionalHolderLike(String holder) { return findByOptionalHolderLikeImpl(holder == null ? "" : holder); } + + @Timed("app.bankAccounts.repo.findByIbanOrderByIbanAsc") List findByIbanOrderByIbanAsc(String iban); + @Timed("app.bankAccounts.repo.save") S save(S entity); + @Timed("app.bankAccounts.repo.deleteByUuid") int deleteByUuid(final UUID uuid); + @Timed("app.bankAccounts.repo.count") long count(); } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateController.java index 0a72e425..05916d7c 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateController.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.office.sepamandate; +import io.micrometer.core.annotation.Timed; import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeSepaMandatesApi; import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeSepaMandateInsertResource; @@ -38,7 +39,8 @@ public class HsOfficeSepaMandateController implements HsOfficeSepaMandatesApi { @Override @Transactional(readOnly = true) - public ResponseEntity> listSepaMandatesByIban( + @Timed("app.sepaMandates.api.getListOfSepaMandates") + public ResponseEntity> getListOfSepaMandates( final String currentSubject, final String assumedRoles, final String iban) { @@ -53,7 +55,8 @@ public class HsOfficeSepaMandateController implements HsOfficeSepaMandatesApi { @Override @Transactional - public ResponseEntity addSepaMandate( + @Timed("app.sepaMandates.api.postNewSepaMandate") + public ResponseEntity postNewSepaMandate( final String currentSubject, final String assumedRoles, final HsOfficeSepaMandateInsertResource body) { @@ -76,7 +79,8 @@ public class HsOfficeSepaMandateController implements HsOfficeSepaMandatesApi { @Override @Transactional(readOnly = true) - public ResponseEntity getSepaMandateByUuid( + @Timed("app.sepaMandates.api.getSingleSepaMandateByUuid") + public ResponseEntity getSingleSepaMandateByUuid( final String currentSubject, final String assumedRoles, final UUID sepaMandateUuid) { @@ -93,6 +97,7 @@ public class HsOfficeSepaMandateController implements HsOfficeSepaMandatesApi { @Override @Transactional + @Timed("app.sepaMandates.api.deleteSepaMandateByUuid") public ResponseEntity deleteSepaMandateByUuid( final String currentSubject, final String assumedRoles, @@ -109,6 +114,7 @@ public class HsOfficeSepaMandateController implements HsOfficeSepaMandatesApi { @Override @Transactional + @Timed("app.sepaMandates.api.patchSepaMandate") public ResponseEntity patchSepaMandate( final String currentSubject, final String assumedRoles, diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateRepository.java index aab53bae..24ebfe1d 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateRepository.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.office.sepamandate; +import io.micrometer.core.annotation.Timed; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; @@ -9,6 +10,7 @@ import java.util.UUID; public interface HsOfficeSepaMandateRepository extends Repository { + @Timed("app.sepaMandates.repo.findByUuid") Optional findByUuid(UUID id); @Query(""" @@ -16,12 +18,16 @@ public interface HsOfficeSepaMandateRepository extends Repository findSepaMandateByOptionalIban(String iban); + @Timed("app.sepaMandates.repo.save") HsOfficeSepaMandateEntity save(final HsOfficeSepaMandateEntity entity); + @Timed("app.sepaMandates.repo.count") long count(); + @Timed("app.sepaMandates.repo.deleteByUuid") int deleteByUuid(UUID uuid); } diff --git a/src/main/resources/api-definition/hs-office/hs-office-bankaccounts-with-uuid.yaml b/src/main/resources/api-definition/hs-office/hs-office-bankaccounts-with-uuid.yaml index cdef972a..08602841 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-bankaccounts-with-uuid.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-bankaccounts-with-uuid.yaml @@ -2,7 +2,7 @@ get: tags: - hs-office-bank-accounts description: 'Fetch a single bank account by its uuid, if visible for the current subject.' - operationId: getBankAccountByUuid + operationId: getSingleBankAccountByUuid parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' diff --git a/src/main/resources/api-definition/hs-office/hs-office-bankaccounts.yaml b/src/main/resources/api-definition/hs-office/hs-office-bankaccounts.yaml index 316fc250..e492d093 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-bankaccounts.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-bankaccounts.yaml @@ -3,7 +3,7 @@ get: description: Returns the list of (optionally filtered) bankaccounts which are visible to the current subject or any of it's assumed roles. tags: - hs-office-bank-accounts - operationId: listBankAccounts + operationId: getListOfBankAccounts parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' @@ -31,7 +31,7 @@ post: summary: Adds a new bank account. tags: - hs-office-bank-accounts - operationId: addBankAccount + operationId: postNewBankAccount parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' diff --git a/src/main/resources/api-definition/hs-office/hs-office-sepamandates-with-uuid.yaml b/src/main/resources/api-definition/hs-office/hs-office-sepamandates-with-uuid.yaml index 1e14a235..3ff4ccb4 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-sepamandates-with-uuid.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-sepamandates-with-uuid.yaml @@ -2,7 +2,7 @@ get: tags: - hs-office-sepaMandates description: 'Fetch a single SEPA Mandate by its uuid, if visible for the current subject.' - operationId: getSepaMandateByUuid + operationId: getSingleSepaMandateByUuid parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' diff --git a/src/main/resources/api-definition/hs-office/hs-office-sepamandates.yaml b/src/main/resources/api-definition/hs-office/hs-office-sepamandates.yaml index 724d8ece..ad624014 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-sepamandates.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-sepamandates.yaml @@ -3,7 +3,7 @@ get: description: Returns the list of (optionally filtered) SEPA Mandates which are visible to the current subject or any of it's assumed roles. tags: - hs-office-sepaMandates - operationId: listSepaMandatesByIBAN + operationId: getListOfSepaMandates parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' @@ -31,7 +31,7 @@ post: summary: Adds a new SEPA Mandate. tags: - hs-office-sepaMandates - operationId: addSepaMandate + operationId: postNewSepaMandate parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountControllerAcceptanceTest.java index 4d6c9973..0a565a60 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountControllerAcceptanceTest.java @@ -50,7 +50,7 @@ class HsOfficeBankAccountControllerAcceptanceTest extends ContextBasedTestWithCl EntityManager em; @Nested - class ListBankAccounts { + class GetListOfBankAccounts { @Test void globalAdmin_withoutAssumedRoles_canViewAllBankAccounts_ifNoCriteriaGiven() throws JSONException { @@ -117,7 +117,7 @@ class HsOfficeBankAccountControllerAcceptanceTest extends ContextBasedTestWithCl class CreateBankAccount { @Test - void globalAdmin_withoutAssumedRole_canAddBankAccount() { + void globalAdmin_withoutAssumedRole_canPostNewBankAccount() { context.define("superuser-alex@hostsharing.net"); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountRepositoryIntegrationTest.java index ed573418..770ef859 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountRepositoryIntegrationTest.java @@ -128,7 +128,7 @@ class HsOfficeBankAccountRepositoryIntegrationTest extends ContextBasedTestWithC } @Nested - class ListBankAccounts { + class GetListOfBankAccounts { @Test public void globalAdmin_canViewAllBankAccounts() { diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateControllerAcceptanceTest.java index 4eccac8e..63cce53f 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateControllerAcceptanceTest.java @@ -132,10 +132,10 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl } @Nested - class AddSepaMandate { + class PostNewSepaMandate { @Test - void globalAdmin_canAddSepaMandate() { + void globalAdmin_canPostNewSepaMandate() { context.define("superuser-alex@hostsharing.net"); final var givenDebitor = debitorRepo.findDebitorByOptionalNameLike("Third").get(0); @@ -177,7 +177,7 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl // TODO.test: move validation tests to a ...WebMvcTest @Test - void globalAdmin_canNotAddSepaMandateWhenDebitorUuidIsMissing() { + void globalAdmin_canNotPostNewSepaMandateWhenDebitorUuidIsMissing() { context.define("superuser-alex@hostsharing.net"); final var givenDebitor = debitorRepo.findDebitorByOptionalNameLike("Third").get(0); @@ -202,7 +202,7 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl } @Test - void globalAdmin_canNotAddSepaMandate_ifBankAccountDoesNotExist() { + void globalAdmin_canNotPostNewSepaMandate_ifBankAccountDoesNotExist() { context.define("superuser-alex@hostsharing.net"); final var givenDebitor = debitorRepo.findDebitorByOptionalNameLike("Third").get(0); @@ -232,7 +232,7 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl } @Test - void globalAdmin_canNotAddSepaMandate_ifPersonDoesNotExist() { + void globalAdmin_canNotPostNewSepaMandate_ifPersonDoesNotExist() { context.define("superuser-alex@hostsharing.net"); final var givenDebitorUuid = UUID.fromString("00000000-0000-0000-0000-000000000000"); -- 2.39.5 From ea85952f12a73285a2f8f50e690d2dc9b1477c1a Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 4 Dec 2024 09:35:29 +0100 Subject: [PATCH 06/13] @Timed for memberships, coopShares and coopAssets --- .../HsOfficeCoopAssetsTransactionController.java | 4 ++++ .../HsOfficeCoopAssetsTransactionRepository.java | 7 ++++++- .../HsOfficeCoopSharesTransactionController.java | 6 ++++++ .../HsOfficeCoopSharesTransactionRepository.java | 7 ++++++- .../office/membership/HsOfficeMembershipController.java | 6 ++++++ .../office/membership/HsOfficeMembershipRepository.java | 8 ++++++++ 6 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java index 8288d7c1..b3b35ddb 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.office.coopassets; +import io.micrometer.core.annotation.Timed; import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.errors.MultiValidationException; import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeCoopAssetsApi; @@ -55,6 +56,7 @@ public class HsOfficeCoopAssetsTransactionController implements HsOfficeCoopAsse @Override @Transactional(readOnly = true) + @Timed("app.coopAssets.api.getListOfCoopAssets") public ResponseEntity> getListOfCoopAssets( final String currentSubject, final String assumedRoles, @@ -77,6 +79,7 @@ public class HsOfficeCoopAssetsTransactionController implements HsOfficeCoopAsse @Override @Transactional + @Timed("app.coopAssets.api.postNewCoopAssetTransaction") public ResponseEntity postNewCoopAssetTransaction( final String currentSubject, final String assumedRoles, @@ -102,6 +105,7 @@ public class HsOfficeCoopAssetsTransactionController implements HsOfficeCoopAsse @Override @Transactional(readOnly = true) + @Timed("app.coopAssets.api.getSingleCoopAssetTransactionByUuid") public ResponseEntity getSingleCoopAssetTransactionByUuid( final String currentSubject, final String assumedRoles, final UUID assetTransactionUuid) { diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepository.java index c606f476..26c2d09b 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepository.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.office.coopassets; +import io.micrometer.core.annotation.Timed; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; @@ -10,6 +11,7 @@ import java.util.UUID; public interface HsOfficeCoopAssetsTransactionRepository extends Repository { + @Timed("app.coopAssets.repo.findByUuid") Optional findByUuid(UUID id); @Query(""" @@ -18,11 +20,14 @@ public interface HsOfficeCoopAssetsTransactionRepository extends Repository= :fromValueDate)) AND ( CAST(:toValueDate AS java.time.LocalDate)IS NULL OR (at.valueDate <= :toValueDate)) ORDER BY at.membership.memberNumberSuffix, at.valueDate - """) + """) + @Timed("app.coopAssets.repo.findCoopAssetsTransactionByOptionalMembershipUuidAndDateRange") List findCoopAssetsTransactionByOptionalMembershipUuidAndDateRange( UUID membershipUuid, LocalDate fromValueDate, LocalDate toValueDate); + @Timed("app.coopAssets.repo.save") HsOfficeCoopAssetsTransactionEntity save(final HsOfficeCoopAssetsTransactionEntity entity); + @Timed("app.coopAssets.repo.count") long count(); } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionController.java index ebd47800..12540e66 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionController.java @@ -1,6 +1,8 @@ package net.hostsharing.hsadminng.hs.office.coopshares; import jakarta.persistence.EntityNotFoundException; + +import io.micrometer.core.annotation.Timed; import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeCoopSharesApi; import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeCoopSharesTransactionInsertResource; @@ -38,6 +40,8 @@ public class HsOfficeCoopSharesTransactionController implements HsOfficeCoopShar @Override @Transactional(readOnly = true) + + @Timed("app.coopShares.api.getListOfCoopShares") public ResponseEntity> getListOfCoopShares( final String currentSubject, final String assumedRoles, @@ -57,6 +61,7 @@ public class HsOfficeCoopSharesTransactionController implements HsOfficeCoopShar @Override @Transactional + @Timed("app.coopShares.repo.postNewCoopSharesTransaction") public ResponseEntity postNewCoopSharesTransaction( final String currentSubject, final String assumedRoles, @@ -80,6 +85,7 @@ public class HsOfficeCoopSharesTransactionController implements HsOfficeCoopShar @Override @Transactional(readOnly = true) + @Timed("app.coopShares.repo.getSingleCoopShareTransactionByUuid") public ResponseEntity getSingleCoopShareTransactionByUuid( final String currentSubject, final String assumedRoles, final UUID shareTransactionUuid) { diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionRepository.java index 5c3e0af6..d8322870 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionRepository.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.office.coopshares; +import io.micrometer.core.annotation.Timed; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; @@ -10,6 +11,7 @@ import java.util.UUID; public interface HsOfficeCoopSharesTransactionRepository extends Repository { + @Timed("app.coopShares.repo.findByUuid") Optional findByUuid(UUID id); @Query(""" @@ -18,11 +20,14 @@ public interface HsOfficeCoopSharesTransactionRepository extends Repository= :fromValueDate)) AND ( CAST(:toValueDate AS java.time.LocalDate)IS NULL OR (st.valueDate <= :toValueDate)) ORDER BY st.membership.memberNumberSuffix, st.valueDate - """) + """) + @Timed("app.coopShares.repo.findCoopSharesTransactionByOptionalMembershipUuidAndDateRange") List findCoopSharesTransactionByOptionalMembershipUuidAndDateRange( UUID membershipUuid, LocalDate fromValueDate, LocalDate toValueDate); + @Timed("app.coopShares.repo.save") HsOfficeCoopSharesTransactionEntity save(final HsOfficeCoopSharesTransactionEntity entity); + @Timed("app.coopShares.repo.count") long count(); } 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 f41bd5c2..d2ee381b 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 @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.office.membership; +import io.micrometer.core.annotation.Timed; import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeMembershipsApi; import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeMembershipInsertResource; @@ -33,6 +34,7 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi { @Override @Transactional(readOnly = true) + @Timed("app.membership.api.getListOfMemberships") public ResponseEntity> getListOfMemberships( final String currentSubject, final String assumedRoles, @@ -53,6 +55,7 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi { @Override @Transactional + @Timed("app.membership.api.postNewMembership") public ResponseEntity postNewMembership( final String currentSubject, final String assumedRoles, @@ -76,6 +79,7 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi { @Override @Transactional(readOnly = true) + @Timed("app.membership.api.getSingleMembershipByUuid") public ResponseEntity getSingleMembershipByUuid( final String currentSubject, final String assumedRoles, @@ -93,6 +97,7 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi { @Override @Transactional + @Timed("app.membership.api.deleteMembershipByUuid") public ResponseEntity deleteMembershipByUuid( final String currentSubject, final String assumedRoles, @@ -109,6 +114,7 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi { @Override @Transactional + @Timed("app.membership.api.patchMembership") public ResponseEntity patchMembership( final String currentSubject, final String assumedRoles, diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepository.java index d7f36d07..e0fb0e1e 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepository.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.office.membership; +import io.micrometer.core.annotation.Timed; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; @@ -10,10 +11,13 @@ import java.util.UUID; public interface HsOfficeMembershipRepository extends Repository { + @Timed("app.membership.repo.findByUuid") Optional findByUuid(UUID id); + @Timed("app.membership.repo.save") HsOfficeMembershipEntity save(final HsOfficeMembershipEntity entity); + @Timed("app.membership.repo.findAll") List findAll(); @Query(""" @@ -22,6 +26,7 @@ public interface HsOfficeMembershipRepository extends Repository findMembershipsByOptionalPartnerUuid(UUID partnerUuid); @Query(""" @@ -30,6 +35,7 @@ public interface HsOfficeMembershipRepository extends Repository Date: Wed, 4 Dec 2024 12:56:18 +0100 Subject: [PATCH 07/13] add ArchTest for @Timed on repos and controllers and add timed to every place it belongs to --- .../debitor/HsBookingDebitorRepository.java | 3 ++ .../BookingItemCreatedEventRepository.java | 3 ++ .../booking/item/HsBookingItemController.java | 12 +++-- .../item/HsBookingItemRbacRepository.java | 7 +++ .../item/HsBookingItemRealRepository.java | 7 +++ .../booking/item/HsBookingItemRepository.java | 1 + .../project/HsBookingProjectController.java | 10 +++- .../HsBookingProjectRbacRepository.java | 8 +++ .../HsBookingProjectRealRepository.java | 8 +++ .../project/HsBookingProjectRepository.java | 11 +++- .../asset/HsHostingAssetController.java | 16 ++++-- .../asset/HsHostingAssetPropsController.java | 7 ++- .../asset/HsHostingAssetRbacRepository.java | 8 +++ .../asset/HsHostingAssetRealRepository.java | 9 ++++ .../asset/HsHostingAssetRepository.java | 8 +++ .../HsOfficeBankAccountRepository.java | 1 + .../debitor/HsOfficeDebitorRepository.java | 6 +-- .../HsOfficeMembershipController.java | 10 ++-- .../HsOfficeMembershipRepository.java | 14 ++--- .../rbac/grant/RawRbacGrantRepository.java | 6 ++- .../rbac/grant/RbacGrantController.java | 13 +++-- .../rbac/grant/RbacGrantRepository.java | 6 +++ .../rbac/role/RbacRoleController.java | 4 +- .../rbac/role/RbacRoleRepository.java | 8 ++- .../rbac/subject/RbacSubjectController.java | 14 +++-- .../rbac/subject/RbacSubjectRepository.java | 7 +++ .../hs-booking-items-with-uuid.yaml | 2 +- .../hs-booking/hs-booking-items.yaml | 4 +- .../hs-booking/hs-booking-projects.yaml | 4 +- .../hs-hosting-asset-types-props.yaml | 2 +- .../hs-hosting/hs-hosting-asset-types.yaml | 2 +- .../hs-hosting-assets-with-uuid.yaml | 6 +-- .../hs-hosting/hs-hosting-assets.yaml | 4 +- .../rbac/rbac-grants-with-id.yaml | 4 +- .../api-definition/rbac/rbac-grants.yaml | 4 +- .../api-definition/rbac/rbac-roles.yaml | 2 +- .../rbac-subjects-with-id-permissions.yaml | 2 +- .../rbac/rbac-subjects-with-uuid.yaml | 2 +- .../api-definition/rbac/rbac-subjects.yaml | 4 +- .../hsadminng/arch/ArchitectureTest.java | 52 ++++++++++++++++++- ...HsBookingItemControllerAcceptanceTest.java | 6 +-- .../item/HsBookingItemControllerRestTest.java | 2 +- ...ookingProjectControllerAcceptanceTest.java | 4 +- ...sHostingAssetControllerAcceptanceTest.java | 6 +-- .../HsHostingAssetControllerRestTest.java | 4 +- .../RbacGrantControllerAcceptanceTest.java | 18 +++---- .../rbac/role/RawRbacObjectRepository.java | 2 + .../rbac/role/RawRbacRoleRepository.java | 2 + .../RbacSubjectControllerRestTest.java | 4 +- .../RbacSubjectRepositoryIntegrationTest.java | 4 +- 50 files changed, 266 insertions(+), 87 deletions(-) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/booking/debitor/HsBookingDebitorRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/booking/debitor/HsBookingDebitorRepository.java index f69dd72f..4fef88e2 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/booking/debitor/HsBookingDebitorRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/booking/debitor/HsBookingDebitorRepository.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.booking.debitor; +import io.micrometer.core.annotation.Timed; import org.springframework.data.repository.Repository; import java.util.List; @@ -8,7 +9,9 @@ import java.util.UUID; public interface HsBookingDebitorRepository extends Repository { + @Timed("app.bookingDebitor.repo.findByUuid") Optional findByUuid(UUID id); + @Timed("app.bookingDebitor.repo.findByDebitorNumber") List findByDebitorNumber(int debitorNumber); } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/booking/item/BookingItemCreatedEventRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/booking/item/BookingItemCreatedEventRepository.java index e36bda61..f94f1458 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/booking/item/BookingItemCreatedEventRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/booking/item/BookingItemCreatedEventRepository.java @@ -1,12 +1,15 @@ package net.hostsharing.hsadminng.hs.booking.item; +import io.micrometer.core.annotation.Timed; import org.springframework.data.repository.Repository; import java.util.UUID; public interface BookingItemCreatedEventRepository extends Repository { + @Timed("app.booking.items.repo.save") BookingItemCreatedEventEntity save(HsBookingItemRealEntity current); + @Timed("app.booking.items.repo.findByBookingItem") BookingItemCreatedEventEntity findByBookingItem(HsBookingItemRealEntity newBookingItem); } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemController.java b/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemController.java index e8441b01..6facc03f 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemController.java @@ -2,6 +2,7 @@ package net.hostsharing.hsadminng.hs.booking.item; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import io.micrometer.core.annotation.Timed; import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.hs.booking.generated.api.v1.api.HsBookingItemsApi; import net.hostsharing.hsadminng.hs.booking.generated.api.v1.model.HsBookingItemInsertResource; @@ -51,7 +52,8 @@ public class HsBookingItemController implements HsBookingItemsApi { @Override @Transactional(readOnly = true) - public ResponseEntity> listBookingItemsByProjectUuid( + @Timed("app.bookingItems.api.getListOfBookingItemsByProjectUuid") + public ResponseEntity> getListOfBookingItemsByProjectUuid( final String currentSubject, final String assumedRoles, final UUID projectUuid) { @@ -65,7 +67,8 @@ public class HsBookingItemController implements HsBookingItemsApi { @Override @Transactional - public ResponseEntity addBookingItem( + @Timed("app.bookingItems.api.postNewBookingItem") + public ResponseEntity postNewBookingItem( final String currentSubject, final String assumedRoles, final HsBookingItemInsertResource body) { @@ -94,7 +97,8 @@ public class HsBookingItemController implements HsBookingItemsApi { @Override @Transactional(readOnly = true) - public ResponseEntity getBookingItemByUuid( + @Timed("app.bookingItems.api.getSingleBookingItemByUuid") + public ResponseEntity getSingleBookingItemByUuid( final String currentSubject, final String assumedRoles, final UUID bookingItemUuid) { @@ -111,6 +115,7 @@ public class HsBookingItemController implements HsBookingItemsApi { @Override @Transactional + @Timed("app.bookingItems.api.deleteBookingIemByUuid") public ResponseEntity deleteBookingIemByUuid( final String currentSubject, final String assumedRoles, @@ -125,6 +130,7 @@ public class HsBookingItemController implements HsBookingItemsApi { @Override @Transactional + @Timed("app.bookingItems.api.patchBookingItem") public ResponseEntity patchBookingItem( final String currentSubject, final String assumedRoles, diff --git a/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRbacRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRbacRepository.java index 8c230445..392b7077 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRbacRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRbacRepository.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.booking.item; +import io.micrometer.core.annotation.Timed; import org.springframework.data.repository.Repository; import java.util.List; @@ -9,15 +10,21 @@ import java.util.UUID; public interface HsBookingItemRbacRepository extends HsBookingItemRepository, Repository { + @Timed("app.bookingItems.repo.findByUuid.rbac") Optional findByUuid(final UUID bookingItemUuid); + @Timed("app.bookingItems.repo.findByCaption.rbac") List findByCaption(String bookingItemCaption); + @Timed("app.bookingItems.repo.findAllByProjectUuid.rbac") List findAllByProjectUuid(final UUID projectItemUuid); + @Timed("app.bookingItems.repo.save.rbac") HsBookingItemRbacEntity save(HsBookingItemRbacEntity current); + @Timed("app.bookingItems.repo.deleteByUuid.rbac") int deleteByUuid(final UUID uuid); + @Timed("app.bookingItems.repo.count.rbac") long count(); } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRealRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRealRepository.java index d9c509cc..706b1349 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRealRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRealRepository.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.booking.item; +import io.micrometer.core.annotation.Timed; import org.springframework.data.repository.Repository; import java.util.List; @@ -9,15 +10,21 @@ import java.util.UUID; public interface HsBookingItemRealRepository extends HsBookingItemRepository, Repository { + @Timed("app.bookingItems.repo.findByUuid.real") Optional findByUuid(final UUID bookingItemUuid); + @Timed("app.bookingItems.repo.findByCaption.real") List findByCaption(String bookingItemCaption); + @Timed("app.bookingItems.repo.findAllByProjectUuid.real") List findAllByProjectUuid(final UUID projectItemUuid); + @Timed("app.bookingItems.repo.save.real") HsBookingItemRealEntity save(HsBookingItemRealEntity current); + @Timed("app.bookingItems.repo.deleteByUuid.real") int deleteByUuid(final UUID uuid); + @Timed("app.bookingItems.repo.count.real") long count(); } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRepository.java index 98ba547c..67cb8efc 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemRepository.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.booking.item; + import java.util.List; import java.util.Optional; import java.util.UUID; diff --git a/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectController.java b/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectController.java index f657d45e..ac21083a 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectController.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.booking.project; +import io.micrometer.core.annotation.Timed; import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.hs.booking.debitor.HsBookingDebitorRepository; import net.hostsharing.hsadminng.hs.booking.generated.api.v1.api.HsBookingProjectsApi; @@ -35,7 +36,8 @@ public class HsBookingProjectController implements HsBookingProjectsApi { @Override @Transactional(readOnly = true) - public ResponseEntity> listBookingProjectsByDebitorUuid( + @Timed("app.bookingProjects.api.getListOfBookingProjectsByDebitorUuid") + public ResponseEntity> getListOfBookingProjectsByDebitorUuid( final String currentSubject, final String assumedRoles, final UUID debitorUuid) { @@ -49,7 +51,8 @@ public class HsBookingProjectController implements HsBookingProjectsApi { @Override @Transactional - public ResponseEntity addBookingProject( + @Timed("app.bookingProjects.api.postNewBookingProject") + public ResponseEntity postNewBookingProject( final String currentSubject, final String assumedRoles, final HsBookingProjectInsertResource body) { @@ -71,6 +74,7 @@ public class HsBookingProjectController implements HsBookingProjectsApi { @Override @Transactional(readOnly = true) + @Timed("app.bookingProjects.api.getBookingProjectByUuid") public ResponseEntity getBookingProjectByUuid( final String currentSubject, final String assumedRoles, @@ -87,6 +91,7 @@ public class HsBookingProjectController implements HsBookingProjectsApi { @Override @Transactional + @Timed("app.bookingProjects.api.deleteBookingIemByUuid") public ResponseEntity deleteBookingIemByUuid( final String currentSubject, final String assumedRoles, @@ -101,6 +106,7 @@ public class HsBookingProjectController implements HsBookingProjectsApi { @Override @Transactional + @Timed("app.bookingProjects.api.patchBookingProject") public ResponseEntity patchBookingProject( final String currentSubject, final String assumedRoles, diff --git a/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectRbacRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectRbacRepository.java index 8541e002..63065bb2 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectRbacRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectRbacRepository.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.booking.project; +import io.micrometer.core.annotation.Timed; import org.springframework.data.repository.Repository; import java.util.List; @@ -9,14 +10,21 @@ import java.util.UUID; public interface HsBookingProjectRbacRepository extends HsBookingProjectRepository, Repository { + @Timed("app.bookingProjects.repo.findByUuid.rbac") Optional findByUuid(final UUID bookingProjectUuid); + + @Timed("app.bookingProjects.repo.findByCaption.rbac") List findByCaption(final String projectCaption); + @Timed("app.bookingProjects.repo.findAllByDebitorUuid.rbac") List findAllByDebitorUuid(final UUID bookingProjectUuid); + @Timed("app.bookingProjects.repo.save.rbac") HsBookingProjectRbacEntity save(HsBookingProjectRbacEntity current); + @Timed("app.bookingProjects.repo.deleteByUuid.rbac") int deleteByUuid(final UUID uuid); + @Timed("app.bookingProjects.repo.count.rbac") long count(); } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectRealRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectRealRepository.java index b6e74d62..66b978b5 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectRealRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectRealRepository.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.booking.project; +import io.micrometer.core.annotation.Timed; import org.springframework.data.repository.Repository; import java.util.List; @@ -9,14 +10,21 @@ import java.util.UUID; public interface HsBookingProjectRealRepository extends HsBookingProjectRepository, Repository { + @Timed("app.bookingProjects.repo.findByUuid.real") Optional findByUuid(final UUID bookingProjectUuid); + + @Timed("app.bookingProjects.repo.findByCaption.real") List findByCaption(final String projectCaption); + @Timed("app.bookingProjects.repo.findAllByDebitorUuid.real") List findAllByDebitorUuid(final UUID bookingProjectUuid); + @Timed("app.bookingProjects.repo.save.real") HsBookingProjectRealEntity save(HsBookingProjectRealEntity current); + @Timed("app.bookingProjects.repo.deleteByUuid.real") int deleteByUuid(final UUID uuid); + @Timed("app.bookingProjects.repo.count.real") long count(); } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectRepository.java index a609f625..0b9c7871 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectRepository.java @@ -1,19 +1,28 @@ package net.hostsharing.hsadminng.hs.booking.project; +import io.micrometer.core.annotation.Timed; + import java.util.List; import java.util.Optional; import java.util.UUID; public interface HsBookingProjectRepository { - Optional findByUuid(final UUID bookingProjectUuid); + @Timed("app.booking.projects.repo.findByUuid") + Optional findByUuid(final UUID findByUuid); + + @Timed("app.booking.projects.repo.findByCaption") List findByCaption(final String projectCaption); + @Timed("app.booking.projects.repo.findAllByDebitorUuid") List findAllByDebitorUuid(final UUID bookingProjectUuid); + @Timed("app.booking.projects.repo.save") E save(E current); + @Timed("app.booking.projects.repo.deleteByUuid") int deleteByUuid(final UUID uuid); + @Timed("app.booking.projects.repo.count") long count(); } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetController.java b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetController.java index 56b59427..a8d4f7cf 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetController.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.hosting.asset; +import io.micrometer.core.annotation.Timed; import net.hostsharing.hsadminng.hs.booking.item.HsBookingItemRealRepository; import net.hostsharing.hsadminng.hs.hosting.asset.validators.HostingAssetEntitySaveProcessor; import net.hostsharing.hsadminng.hs.hosting.asset.validators.HostingAssetEntityValidatorRegistry; @@ -48,7 +49,8 @@ public class HsHostingAssetController implements HsHostingAssetsApi { @Override @Transactional(readOnly = true) - public ResponseEntity> listAssets( + @Timed("app.hosting.assets.api.getListOfHostingAssets") + public ResponseEntity> getListOfHostingAssets( final String currentSubject, final String assumedRoles, final UUID debitorUuid, @@ -65,7 +67,8 @@ public class HsHostingAssetController implements HsHostingAssetsApi { @Override @Transactional - public ResponseEntity addAsset( + @Timed("app.hosting.assets.api.postNewHostingAsset") + public ResponseEntity postNewHostingAsset( final String currentSubject, final String assumedRoles, final HsHostingAssetInsertResource body) { @@ -93,7 +96,8 @@ public class HsHostingAssetController implements HsHostingAssetsApi { @Override @Transactional(readOnly = true) - public ResponseEntity getAssetByUuid( + @Timed("app.hosting.assets.api.getSingleHostingAssetByUuid") + public ResponseEntity getSingleHostingAssetByUuid( final String currentSubject, final String assumedRoles, final UUID assetUuid) { @@ -109,7 +113,8 @@ public class HsHostingAssetController implements HsHostingAssetsApi { @Override @Transactional - public ResponseEntity deleteAssetUuid( + @Timed("app.hosting.assets.api.deleteHostingAssetByUuid") + public ResponseEntity deleteHostingAssetByUuid( final String currentSubject, final String assumedRoles, final UUID assetUuid) { @@ -123,7 +128,8 @@ public class HsHostingAssetController implements HsHostingAssetsApi { @Override @Transactional - public ResponseEntity patchAsset( + @Timed("app.hosting.assets.api.patchHostingAsset") + public ResponseEntity patchHostingAsset( final String currentSubject, final String assumedRoles, final UUID assetUuid, diff --git a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetPropsController.java b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetPropsController.java index ca8bbb08..b4c56f4c 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetPropsController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetPropsController.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.hosting.asset; +import io.micrometer.core.annotation.Timed; import net.hostsharing.hsadminng.hs.hosting.asset.validators.HostingAssetEntityValidatorRegistry; import net.hostsharing.hsadminng.hs.hosting.generated.api.v1.api.HsHostingAssetPropsApi; import net.hostsharing.hsadminng.hs.hosting.generated.api.v1.model.HsHostingAssetTypeResource; @@ -14,7 +15,8 @@ import java.util.Map; public class HsHostingAssetPropsController implements HsHostingAssetPropsApi { @Override - public ResponseEntity> listAssetTypes() { + @Timed("app.hosting.assets.api.getListOfHostingAssetTypes") + public ResponseEntity> getListOfHostingAssetTypes() { final var resource = HostingAssetEntityValidatorRegistry.types().stream() .map(Enum::name) .toList(); @@ -22,7 +24,8 @@ public class HsHostingAssetPropsController implements HsHostingAssetPropsApi { } @Override - public ResponseEntity> listAssetTypeProps( + @Timed("app.hosting.assets.api.getListOfHostingAssetTypeProps") + public ResponseEntity> getListOfHostingAssetTypeProps( final HsHostingAssetTypeResource assetType) { final Enum type = HsHostingAssetType.of(assetType); diff --git a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRbacRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRbacRepository.java index 73050383..75a9863f 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRbacRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRbacRepository.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.hosting.asset; +import io.micrometer.core.annotation.Timed; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; @@ -10,8 +11,10 @@ import java.util.UUID; public interface HsHostingAssetRbacRepository extends HsHostingAssetRepository, Repository { + @Timed("app.hostingAsset.repo.findByUuid.rbac") Optional findByUuid(final UUID serverUuid); + @Timed("app.hostingAsset.repo.findByIdentifier.rbac") List findByIdentifier(String assetIdentifier); @Query(value = """ @@ -32,16 +35,21 @@ public interface HsHostingAssetRbacRepository extends HsHostingAssetRepository findAllByCriteriaImpl(UUID projectUuid, UUID parentAssetUuid, String type); + default List findAllByCriteria(final UUID projectUuid, final UUID parentAssetUuid, final HsHostingAssetType type) { return findAllByCriteriaImpl(projectUuid, parentAssetUuid, HsHostingAssetType.asString(type)); } + @Timed("app.hostingAsset.repo.save.rbac") HsHostingAssetRbacEntity save(HsHostingAsset current); + @Timed("app.hostingAsset.repo.deleteByUuid.rbac") int deleteByUuid(final UUID uuid); + @Timed("app.hostingAsset.repo.count.rbac") long count(); } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRealRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRealRepository.java index c3709039..64fc44bd 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRealRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRealRepository.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.hosting.asset; +import io.micrometer.core.annotation.Timed; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; @@ -10,8 +11,10 @@ import java.util.UUID; public interface HsHostingAssetRealRepository extends HsHostingAssetRepository, Repository { + @Timed("app.hostingAsset.repo.findByUuid.real") Optional findByUuid(final UUID serverUuid); + @Timed("app.hostingAsset.repo.findByIdentifier.real") List findByIdentifier(String assetIdentifier); default List findByTypeAndIdentifier(@NotNull HsHostingAssetType type, @NotNull String identifier) { @@ -24,6 +27,7 @@ public interface HsHostingAssetRealRepository extends HsHostingAssetRepository findByTypeAndIdentifierImpl(@NotNull String type, @NotNull String identifier); @Query(value = """ @@ -46,14 +50,19 @@ public interface HsHostingAssetRealRepository extends HsHostingAssetRepository findAllByCriteriaImpl(UUID projectUuid, UUID parentAssetUuid, String type); + default List findAllByCriteria(final UUID projectUuid, final UUID parentAssetUuid, final HsHostingAssetType type) { return findAllByCriteriaImpl(projectUuid, parentAssetUuid, HsHostingAssetType.asString(type)); } + @Timed("app.hostingAsset.repo.save.real") HsHostingAssetRealEntity save(HsHostingAssetRealEntity current); + @Timed("app.hostingAsset.repo.deleteByUuid.real") int deleteByUuid(final UUID uuid); + @Timed("app.hostingAsset.repo.count.real") long count(); } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRepository.java index 8e062869..a473accc 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRepository.java @@ -1,24 +1,32 @@ package net.hostsharing.hsadminng.hs.hosting.asset; +import io.micrometer.core.annotation.Timed; + import java.util.List; import java.util.Optional; import java.util.UUID; public interface HsHostingAssetRepository { + @Timed("app.hosting.assets.repo.findByUuid") Optional findByUuid(final UUID serverUuid); + @Timed("app.hosting.assets.repo.findByIdentifier") List findByIdentifier(String assetIdentifier); + @Timed("app.hosting.assets.repo.findAllByCriteriaImpl") List findAllByCriteriaImpl(UUID projectUuid, UUID parentAssetUuid, String type); default List findAllByCriteria(final UUID projectUuid, final UUID parentAssetUuid, final HsHostingAssetType type) { return findAllByCriteriaImpl(projectUuid, parentAssetUuid, HsHostingAssetType.asString(type)); } + @Timed("app.hosting.assets.repo.save") E save(HsHostingAsset current); + @Timed("app.hosting.assets.repo.deleteByUuid") int deleteByUuid(final UUID uuid); + @Timed("app.hosting.assets.repo.count") long count(); } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountRepository.java index ecc1b2c0..862a6e7d 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountRepository.java @@ -20,6 +20,7 @@ public interface HsOfficeBankAccountRepository extends Repository findByOptionalHolderLikeImpl(String holder); + default List findByOptionalHolderLike(String holder) { return findByOptionalHolderLikeImpl(holder == null ? "" : holder); } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepository.java index 3eb1835e..817eb202 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepository.java @@ -21,13 +21,13 @@ public interface HsOfficeDebitorRepository extends Repository findDebitorByDebitorNumber(int partnerNumber, String debitorNumberSuffix); + @Timed("app.debitors.repo.findDebitorByPartnerNumberAndDebitorNumberSuffix") + List findDebitorByPartnerNumberAndDebitorNumberSuffix(int partnerNumber, String debitorNumberSuffix); default List findDebitorByDebitorNumber(int debitorNumber) { final var partnerNumber = debitorNumber / 100; final String suffix = String.format("%02d", debitorNumber % 100); - final var result = findDebitorByDebitorNumber(partnerNumber, suffix); + final var result = findDebitorByPartnerNumberAndDebitorNumberSuffix(partnerNumber, suffix); return result; } 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 d2ee381b..3ba36f5c 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 @@ -34,7 +34,7 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi { @Override @Transactional(readOnly = true) - @Timed("app.membership.api.getListOfMemberships") + @Timed("app.office.membership.api.getListOfMemberships") public ResponseEntity> getListOfMemberships( final String currentSubject, final String assumedRoles, @@ -55,7 +55,7 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi { @Override @Transactional - @Timed("app.membership.api.postNewMembership") + @Timed("app.office.membership.api.postNewMembership") public ResponseEntity postNewMembership( final String currentSubject, final String assumedRoles, @@ -79,7 +79,7 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi { @Override @Transactional(readOnly = true) - @Timed("app.membership.api.getSingleMembershipByUuid") + @Timed("app.office.membership.api.getSingleMembershipByUuid") public ResponseEntity getSingleMembershipByUuid( final String currentSubject, final String assumedRoles, @@ -97,7 +97,7 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi { @Override @Transactional - @Timed("app.membership.api.deleteMembershipByUuid") + @Timed("app.office.membership.api.deleteMembershipByUuid") public ResponseEntity deleteMembershipByUuid( final String currentSubject, final String assumedRoles, @@ -114,7 +114,7 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi { @Override @Transactional - @Timed("app.membership.api.patchMembership") + @Timed("app.office.membership.api.patchMembership") public ResponseEntity patchMembership( final String currentSubject, final String assumedRoles, diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepository.java index e0fb0e1e..5a537b26 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepository.java @@ -11,13 +11,13 @@ import java.util.UUID; public interface HsOfficeMembershipRepository extends Repository { - @Timed("app.membership.repo.findByUuid") + @Timed("app.office.membership.repo.findByUuid") Optional findByUuid(UUID id); - @Timed("app.membership.repo.save") + @Timed("app.office.membership.repo.save") HsOfficeMembershipEntity save(final HsOfficeMembershipEntity entity); - @Timed("app.membership.repo.findAll") + @Timed("app.office.membership.repo.findAll") List findAll(); @Query(""" @@ -26,7 +26,7 @@ public interface HsOfficeMembershipRepository extends Repository findMembershipsByOptionalPartnerUuid(UUID partnerUuid); @Query(""" @@ -35,7 +35,7 @@ public interface HsOfficeMembershipRepository extends Repository { - List findAll(); + @Timed("app.rbac.grants.repo.findAll") + List findAll(); // TODO.refa: move to test repo + @Timed("app.rbac.grants.repo.findByAscendingUuid") List findByAscendingUuid(UUID ascendingUuid); + @Timed("app.rbac.grants.repo.findByDescendantUuid") List findByDescendantUuid(UUID refUuid); } diff --git a/src/main/java/net/hostsharing/hsadminng/rbac/grant/RbacGrantController.java b/src/main/java/net/hostsharing/hsadminng/rbac/grant/RbacGrantController.java index 6af53104..500c0ff3 100644 --- a/src/main/java/net/hostsharing/hsadminng/rbac/grant/RbacGrantController.java +++ b/src/main/java/net/hostsharing/hsadminng/rbac/grant/RbacGrantController.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.rbac.grant; +import io.micrometer.core.annotation.Timed; import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.mapper.StandardMapper; import net.hostsharing.hsadminng.rbac.generated.api.v1.api.RbacGrantsApi; @@ -32,7 +33,8 @@ public class RbacGrantController implements RbacGrantsApi { @Override @Transactional(readOnly = true) - public ResponseEntity getGrantById( + @Timed("app.rbac.grants.api.getListOfGrantsByUuid") + public ResponseEntity getListOfGrantsByUuid( final String currentSubject, final String assumedRoles, final UUID grantedRoleUuid, @@ -50,7 +52,8 @@ public class RbacGrantController implements RbacGrantsApi { @Override @Transactional(readOnly = true) - public ResponseEntity> listSubjectGrants( + @Timed("app.rbac.grants.api.getListOfSubjectGrants") + public ResponseEntity> getListOfSubjectGrants( final String currentSubject, final String assumedRoles) { @@ -61,7 +64,8 @@ public class RbacGrantController implements RbacGrantsApi { @Override @Transactional - public ResponseEntity grantRoleToSubject( + @Timed("app.rbac.grants.api.postNewRoleGrantToSubject") + public ResponseEntity postNewRoleGrantToSubject( final String currentSubject, final String assumedRoles, final RbacGrantResource body) { @@ -82,7 +86,8 @@ public class RbacGrantController implements RbacGrantsApi { @Override @Transactional - public ResponseEntity revokeRoleFromSubject( + @Timed("app.rbac.grants.api.deleteRoleGrantFromSubject") + public ResponseEntity deleteRoleGrantFromSubject( final String currentSubject, final String assumedRoles, final UUID grantedRoleUuid, diff --git a/src/main/java/net/hostsharing/hsadminng/rbac/grant/RbacGrantRepository.java b/src/main/java/net/hostsharing/hsadminng/rbac/grant/RbacGrantRepository.java index 9621e1f4..7aec28fa 100644 --- a/src/main/java/net/hostsharing/hsadminng/rbac/grant/RbacGrantRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/rbac/grant/RbacGrantRepository.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.rbac.grant; +import io.micrometer.core.annotation.Timed; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; @@ -13,12 +14,16 @@ public interface RbacGrantRepository extends Repository findAll(); + @Timed("app.rbac.grants.repo.save") RbacGrantEntity save(final RbacGrantEntity grant); @Modifying @@ -27,5 +32,6 @@ public interface RbacGrantRepository extends Repository> listRoles( + @Timed("app.rbac.roles.api.getListOfRoles") + public ResponseEntity> getListOfRoles( final String currentSubject, final String assumedRoles) { diff --git a/src/main/java/net/hostsharing/hsadminng/rbac/role/RbacRoleRepository.java b/src/main/java/net/hostsharing/hsadminng/rbac/role/RbacRoleRepository.java index 50a2e8b4..25348cd6 100644 --- a/src/main/java/net/hostsharing/hsadminng/rbac/role/RbacRoleRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/rbac/role/RbacRoleRepository.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.rbac.role; +import io.micrometer.core.annotation.Timed; import org.springframework.data.repository.Repository; import java.util.List; @@ -10,12 +11,15 @@ public interface RbacRoleRepository extends Repository { /** * @return the number of persistent RbacRoleEntity instances, mostly for testing purposes. */ - long count(); // TODO: move to test sources + @Timed("app.rbac.roles.repo.findByUuid") + long count(); // TODO.refa: move to test sources /** * @return all persistent RbacRoleEntity instances, assigned to the current subject (user or assumed roles) */ - List findAll(); + @Timed("app.rbac.roles.repo.findAll") + List findAll(); // TODO.refa: move to test sources + @Timed("app.rbac.roles.repo.findByRoleName") RbacRoleEntity findByRoleName(String roleName); } diff --git a/src/main/java/net/hostsharing/hsadminng/rbac/subject/RbacSubjectController.java b/src/main/java/net/hostsharing/hsadminng/rbac/subject/RbacSubjectController.java index 1676cc7c..f2f7afab 100644 --- a/src/main/java/net/hostsharing/hsadminng/rbac/subject/RbacSubjectController.java +++ b/src/main/java/net/hostsharing/hsadminng/rbac/subject/RbacSubjectController.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.rbac.subject; +import io.micrometer.core.annotation.Timed; import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.mapper.StandardMapper; import net.hostsharing.hsadminng.rbac.generated.api.v1.api.RbacSubjectsApi; @@ -28,7 +29,8 @@ public class RbacSubjectController implements RbacSubjectsApi { @Override @Transactional - public ResponseEntity createSubject( + @Timed("app.rbac.subjects.api.postNewSubject") + public ResponseEntity postNewSubject( final RbacSubjectResource body ) { context.define(null); @@ -48,6 +50,7 @@ public class RbacSubjectController implements RbacSubjectsApi { @Override @Transactional + @Timed("app.rbac.subjects.api.deleteSubjectByUuid") public ResponseEntity deleteSubjectByUuid( final String currentSubject, final String assumedRoles, @@ -62,7 +65,8 @@ public class RbacSubjectController implements RbacSubjectsApi { @Override @Transactional(readOnly = true) - public ResponseEntity getSubjectById( + @Timed("app.rbac.subjects.api.getSingleSubjectByUuid") + public ResponseEntity getSingleSubjectByUuid( final String currentSubject, final String assumedRoles, final UUID subjectUuid) { @@ -78,7 +82,8 @@ public class RbacSubjectController implements RbacSubjectsApi { @Override @Transactional(readOnly = true) - public ResponseEntity> listSubjects( + @Timed("app.rbac.subjects.api.getListOfSubjects") + public ResponseEntity> getListOfSubjects( final String currentSubject, final String assumedRoles, final String userName @@ -90,7 +95,8 @@ public class RbacSubjectController implements RbacSubjectsApi { @Override @Transactional(readOnly = true) - public ResponseEntity> listSubjectPermissions( + @Timed("app.rbac.subjects.api.getListOfSubjectPermissions") + public ResponseEntity> getListOfSubjectPermissions( final String currentSubject, final String assumedRoles, final UUID subjectUuid diff --git a/src/main/java/net/hostsharing/hsadminng/rbac/subject/RbacSubjectRepository.java b/src/main/java/net/hostsharing/hsadminng/rbac/subject/RbacSubjectRepository.java index 16a13962..36dd2675 100644 --- a/src/main/java/net/hostsharing/hsadminng/rbac/subject/RbacSubjectRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/rbac/subject/RbacSubjectRepository.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.rbac.subject; +import io.micrometer.core.annotation.Timed; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; @@ -14,15 +15,19 @@ public interface RbacSubjectRepository extends Repository findByOptionalNameLike(String userName); // bypasses the restricted view, to be able to grant rights to arbitrary user @Query(value = "select * from rbac.subject where name=:userName", nativeQuery = true) + @Timed("app.rbac.subjects.repo.findByName") RbacSubjectEntity findByName(String userName); + @Timed("app.rbac.subjects.repo.findByUuid") RbacSubjectEntity findByUuid(UUID uuid); @Query(value = "select * from rbac.grantedPermissions(:subjectUuid)", nativeQuery = true) + @Timed("app.rbac.subjects.repo.findPermissionsOfUserByUuid") List findPermissionsOfUserByUuid(UUID subjectUuid); /* @@ -32,6 +37,7 @@ public interface RbacSubjectRepository extends Repository haveAllPublicMethodsAnnotatedWith(Class annotation) { + return new ArchCondition<>("have all public methods annotated with @" + annotation.getSimpleName()) { + @Override + public void check(final JavaClass item, final ConditionEvents events) { + for (JavaMethod method : item.getMethods()) { + if (method.isAnnotatedWith(annotation)) { + continue; + } + if (isGeneratedSpringRepositoryMethod(item, method)) { + continue; + } + if (item.isAnnotatedWith(RestController.class) && !method.getModifiers().contains(PUBLIC)) { + continue; + } + final var message = String.format( + "Method %s in class %s is not annotated with @%s", + method.getName(), + item.getName(), + annotation.getSimpleName() + ); + events.add(SimpleConditionEvent.violated(method, message)); + } + } + }; + } + + private static boolean isGeneratedSpringRepositoryMethod(final JavaClass item, final JavaMethod method) { + // this is a heuristic, ideally we can determine all methods with generated database calls + return item.isAssignableTo(Repository.class) && !method.getModifiers().contains(JavaModifier.ABSTRACT); + } } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java index ea433e71..120f62f5 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerAcceptanceTest.java @@ -139,10 +139,10 @@ class HsBookingItemControllerAcceptanceTest extends ContextBasedTestWithCleanup @Nested @Order(3) - class AddBookingItem { + class PostNewBookingItem { @Test - void globalAdmin_canAddBookingItem() { + void globalAdmin_canPostNewBookingItem() { context.define("superuser-alex@hostsharing.net"); final var givenProject = findDefaultProjectOfDebitorNumber(1000111); @@ -349,7 +349,7 @@ class HsBookingItemControllerAcceptanceTest extends ContextBasedTestWithCleanup } @Test - void projectAgent_canAddBookingItemEvenIfHostingAssetCreationFails() { + void projectAgent_canPostNewBookingItemEvenIfHostingAssetCreationFails() { context.define("superuser-alex@hostsharing.net", "hs_booking.project#D-1000111-D-1000111defaultproject:AGENT"); final var givenProject = findDefaultProjectOfDebitorNumber(1000111); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerRestTest.java b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerRestTest.java index 06e51a24..77e0abc8 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerRestTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemControllerRestTest.java @@ -84,7 +84,7 @@ class HsBookingItemControllerRestTest { } @Nested - class AddBookingItem { + class PostNewBookingItem { @Test void globalAdmin_canAddValidBookingItem() throws Exception { diff --git a/src/test/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectControllerAcceptanceTest.java index d2860219..737cc0a2 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/booking/project/HsBookingProjectControllerAcceptanceTest.java @@ -79,10 +79,10 @@ class HsBookingProjectControllerAcceptanceTest extends ContextBasedTestWithClean } @Nested - class AddBookingProject { + class PostNewBookingProject { @Test - void globalAdmin_canAddBookingProject() { + void globalAdmin_canPostNewBookingProject() { context.define("superuser-alex@hostsharing.net"); final var givenDebitor = debitorRepo.findByDebitorNumber(1000111).stream() diff --git a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerAcceptanceTest.java index 5b732b68..2d493fd0 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerAcceptanceTest.java @@ -76,7 +76,7 @@ class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup @Nested @Order(2) - class ListAssets { + class GetListOfHostingAssets { @Test void globalAdmin_canViewAllAssetsOfArbitraryDebitor() { @@ -146,7 +146,7 @@ class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup @Nested @Order(3) - class AddAsset { + class PostNewHostingAsset { @Test void globalAdmin_canAddBookedAsset() { @@ -481,7 +481,7 @@ class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup @Nested @Order(4) - class PatchAsset { + class PatchHostingAsset { @Test void globalAdmin_canPatchAllUpdatablePropertiesOfAsset() { diff --git a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerRestTest.java b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerRestTest.java index 45fd83c4..5aad9e2f 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerRestTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerRestTest.java @@ -583,7 +583,7 @@ public class HsHostingAssetControllerRestTest { @ParameterizedTest @EnumSource(HsHostingAssetControllerRestTest.ListTestCases.class) - void shouldListAssets(final HsHostingAssetControllerRestTest.ListTestCases testCase) throws Exception { + void shouldGetListOfHostingAssets(final HsHostingAssetControllerRestTest.ListTestCases testCase) throws Exception { // given when(rbacAssetRepo.findAllByCriteria(null, null, testCase.assetType)) .thenReturn(testCase.givenHostingAssetsOfType); @@ -607,7 +607,7 @@ public class HsHostingAssetControllerRestTest { } @Test - void shouldPatchAsset() throws Exception { + void shouldPatchHostingAsset() throws Exception { // given final var givenDomainSetup = HsHostingAssetRealEntity.builder() .type(HsHostingAssetType.DOMAIN_SETUP) diff --git a/src/test/java/net/hostsharing/hsadminng/rbac/grant/RbacGrantControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/rbac/grant/RbacGrantControllerAcceptanceTest.java index db13757e..e2460d05 100644 --- a/src/test/java/net/hostsharing/hsadminng/rbac/grant/RbacGrantControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/rbac/grant/RbacGrantControllerAcceptanceTest.java @@ -161,7 +161,7 @@ class RbacGrantControllerAcceptanceTest extends ContextBasedTest { } @Nested - class GetGrantById { + class GetListOfGrantsByUuid { @Test void customerAdmin_withAssumedPacketAdminRole_canReadPacketAdminsGrantById() { @@ -171,7 +171,7 @@ class RbacGrantControllerAcceptanceTest extends ContextBasedTest { final var givenGrantedRole = getRbacRoleByName("rbactest.package#xxx00:ADMIN"); // when - final var grant = givencurrentSubjectAsPackageAdmin.getGrantById() + final var grant = givencurrentSubjectAsPackageAdmin.getListOfGrantsByUuid() .forGrantedRole(givenGrantedRole).toGranteeUser(givenGranteeUser); // then @@ -190,7 +190,7 @@ class RbacGrantControllerAcceptanceTest extends ContextBasedTest { final var givenGrantedRole = getRbacRoleByName("rbactest.package#xxx00:ADMIN"); // when - final var grant = givencurrentSubjectAsPackageAdmin.getGrantById() + final var grant = givencurrentSubjectAsPackageAdmin.getListOfGrantsByUuid() .forGrantedRole(givenGrantedRole).toGranteeUser(givenGranteeUser); // then @@ -211,7 +211,7 @@ class RbacGrantControllerAcceptanceTest extends ContextBasedTest { final var givenGrantedRole = getRbacRoleByName("rbactest.package#xxx00:ADMIN"); // when - final var grant = givencurrentSubjectAsPackageAdmin.getGrantById() + final var grant = givencurrentSubjectAsPackageAdmin.getListOfGrantsByUuid() .forGrantedRole(givenGrantedRole).toGranteeUser(givenGranteeUser); // then @@ -231,7 +231,7 @@ class RbacGrantControllerAcceptanceTest extends ContextBasedTest { "rbactest.package#xxx00:TENANT"); final var givenGranteeUser = findRbacSubjectByName("pac-admin-xxx00@xxx.example.com"); final var givenGrantedRole = getRbacRoleByName("rbactest.package#xxx00:ADMIN"); - final var grant = givencurrentSubjectAsPackageAdmin.getGrantById() + final var grant = givencurrentSubjectAsPackageAdmin.getListOfGrantsByUuid() .forGrantedRole(givenGrantedRole).toGranteeUser(givenGranteeUser); // then @@ -360,8 +360,8 @@ class RbacGrantControllerAcceptanceTest extends ContextBasedTest { return new RevokeFixture(givenOwnPackageAdminRole); } - GetGrantByIdFixture getGrantById() { - return new GetGrantByIdFixture(); + GetListOfGrantsByUuidFixture getListOfGrantsByUuid() { + return new GetListOfGrantsByUuidFixture(); } class GrantFixture { @@ -443,12 +443,12 @@ class RbacGrantControllerAcceptanceTest extends ContextBasedTest { } } - private class GetGrantByIdFixture { + private class GetListOfGrantsByUuidFixture { private Subject currentSubject = Subject.this; private RbacRoleEntity grantedRole; - GetGrantByIdFixture forGrantedRole(final RbacRoleEntity grantedRole) { + GetListOfGrantsByUuidFixture forGrantedRole(final RbacRoleEntity grantedRole) { this.grantedRole = grantedRole; return this; } diff --git a/src/test/java/net/hostsharing/hsadminng/rbac/role/RawRbacObjectRepository.java b/src/test/java/net/hostsharing/hsadminng/rbac/role/RawRbacObjectRepository.java index bda22795..dba24973 100644 --- a/src/test/java/net/hostsharing/hsadminng/rbac/role/RawRbacObjectRepository.java +++ b/src/test/java/net/hostsharing/hsadminng/rbac/role/RawRbacObjectRepository.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.rbac.role; +import io.micrometer.core.annotation.Timed; import org.springframework.data.repository.Repository; import java.util.List; @@ -7,5 +8,6 @@ import java.util.UUID; public interface RawRbacObjectRepository extends Repository { + @Timed("app.rbac.objects.repo.findAll.real") List findAll(); } diff --git a/src/test/java/net/hostsharing/hsadminng/rbac/role/RawRbacRoleRepository.java b/src/test/java/net/hostsharing/hsadminng/rbac/role/RawRbacRoleRepository.java index 029e1360..f9f629ce 100644 --- a/src/test/java/net/hostsharing/hsadminng/rbac/role/RawRbacRoleRepository.java +++ b/src/test/java/net/hostsharing/hsadminng/rbac/role/RawRbacRoleRepository.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.rbac.role; +import io.micrometer.core.annotation.Timed; import org.springframework.data.repository.Repository; import java.util.List; @@ -7,5 +8,6 @@ import java.util.UUID; public interface RawRbacRoleRepository extends Repository { + @Timed("app.rbac.roles.repo.findAll.real") List findAll(); } diff --git a/src/test/java/net/hostsharing/hsadminng/rbac/subject/RbacSubjectControllerRestTest.java b/src/test/java/net/hostsharing/hsadminng/rbac/subject/RbacSubjectControllerRestTest.java index 1b96029b..e788c34b 100644 --- a/src/test/java/net/hostsharing/hsadminng/rbac/subject/RbacSubjectControllerRestTest.java +++ b/src/test/java/net/hostsharing/hsadminng/rbac/subject/RbacSubjectControllerRestTest.java @@ -45,7 +45,7 @@ class RbacSubjectControllerRestTest { @Test - void createSubjectUsesGivenUuid() throws Exception { + void postNewSubjectUsesGivenUuid() throws Exception { // given final var givenUuid = UUID.randomUUID(); @@ -69,7 +69,7 @@ class RbacSubjectControllerRestTest { } @Test - void createSubjectGeneratesRandomUuidIfNotGiven() throws Exception { + void postNewSubjectGeneratesRandomUuidIfNotGiven() throws Exception { // when mockMvc.perform(MockMvcRequestBuilders .post("/api/rbac/subjects") diff --git a/src/test/java/net/hostsharing/hsadminng/rbac/subject/RbacSubjectRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/rbac/subject/RbacSubjectRepositoryIntegrationTest.java index c60142d5..ea72ce14 100644 --- a/src/test/java/net/hostsharing/hsadminng/rbac/subject/RbacSubjectRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/rbac/subject/RbacSubjectRepositoryIntegrationTest.java @@ -41,7 +41,7 @@ class RbacSubjectRepositoryIntegrationTest extends ContextBasedTest { HttpServletRequest request; @Nested - class CreateSubject { + class PostNewSubject { @Test @Transactional(propagation = Propagation.NEVER) @@ -178,7 +178,7 @@ class RbacSubjectRepositoryIntegrationTest extends ContextBasedTest { } @Nested - class ListSubjectPermissions { + class GetListOfSubjectPermissions { private static final String[] ALL_USER_PERMISSIONS = Array.of( // @formatter:off -- 2.39.5 From ed9e824179e922044704e275187b8360e892f919 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 4 Dec 2024 13:14:42 +0100 Subject: [PATCH 08/13] add ArchTest for @Timed on repos and controllers and add timed to every place it belongs --- .../debitor/HsBookingDebitorRepository.java | 4 ++-- .../bankaccount/HsOfficeBankAccountController.java | 8 ++++---- .../bankaccount/HsOfficeBankAccountRepository.java | 12 ++++++------ .../office/contact/HsOfficeContactController.java | 10 +++++----- .../contact/HsOfficeContactRbacRepository.java | 10 +++++----- .../contact/HsOfficeContactRealRepository.java | 10 +++++----- .../HsOfficeCoopAssetsTransactionController.java | 6 +++--- .../HsOfficeCoopAssetsTransactionRepository.java | 8 ++++---- .../HsOfficeCoopSharesTransactionController.java | 6 +++--- .../HsOfficeCoopSharesTransactionRepository.java | 8 ++++---- .../office/debitor/HsOfficeDebitorController.java | 10 +++++----- .../office/debitor/HsOfficeDebitorRepository.java | 12 ++++++------ .../office/partner/HsOfficePartnerController.java | 10 +++++----- .../office/partner/HsOfficePartnerRepository.java | 14 +++++++------- .../hs/office/person/HsOfficePersonController.java | 10 +++++----- .../hs/office/person/HsOfficePersonRepository.java | 10 +++++----- .../relation/HsOfficeRelationController.java | 8 ++++---- .../relation/HsOfficeRelationRbacRepository.java | 12 ++++++------ .../sepamandate/HsOfficeSepaMandateController.java | 10 +++++----- .../sepamandate/HsOfficeSepaMandateRepository.java | 10 +++++----- 20 files changed, 94 insertions(+), 94 deletions(-) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/booking/debitor/HsBookingDebitorRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/booking/debitor/HsBookingDebitorRepository.java index 4fef88e2..8d0bbe30 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/booking/debitor/HsBookingDebitorRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/booking/debitor/HsBookingDebitorRepository.java @@ -9,9 +9,9 @@ import java.util.UUID; public interface HsBookingDebitorRepository extends Repository { - @Timed("app.bookingDebitor.repo.findByUuid") + @Timed("app.booking.debitor.repo.findByUuid") Optional findByUuid(UUID id); - @Timed("app.bookingDebitor.repo.findByDebitorNumber") + @Timed("app.booking.debitor.repo.findByDebitorNumber") List findByDebitorNumber(int debitorNumber); } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountController.java index 50087bf4..72c37023 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountController.java @@ -32,7 +32,7 @@ public class HsOfficeBankAccountController implements HsOfficeBankAccountsApi { @Override @Transactional(readOnly = true) - @Timed("app.bankAccounts.api.patchDebitor") + @Timed("app.office.bankAccounts.api.patchDebitor") public ResponseEntity> getListOfBankAccounts( final String currentSubject, final String assumedRoles, @@ -47,7 +47,7 @@ public class HsOfficeBankAccountController implements HsOfficeBankAccountsApi { @Override @Transactional - @Timed("app.bankAccounts.api.postNewBankAccount") + @Timed("app.office.bankAccounts.api.postNewBankAccount") public ResponseEntity postNewBankAccount( final String currentSubject, final String assumedRoles, @@ -74,7 +74,7 @@ public class HsOfficeBankAccountController implements HsOfficeBankAccountsApi { @Override @Transactional(readOnly = true) - @Timed("app.bankAccounts.api.getSingleBankAccountByUuid") + @Timed("app.office.bankAccounts.api.getSingleBankAccountByUuid") public ResponseEntity getSingleBankAccountByUuid( final String currentSubject, final String assumedRoles, @@ -91,7 +91,7 @@ public class HsOfficeBankAccountController implements HsOfficeBankAccountsApi { @Override @Transactional - @Timed("app.bankAccounts.api.deleteBankAccountByUuid") + @Timed("app.office.bankAccounts.api.deleteBankAccountByUuid") public ResponseEntity deleteBankAccountByUuid( final String currentSubject, final String assumedRoles, diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountRepository.java index 862a6e7d..3e8cc20f 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountRepository.java @@ -10,7 +10,7 @@ import java.util.UUID; public interface HsOfficeBankAccountRepository extends Repository { - @Timed("app.bankAccounts.repo.findByUuid") + @Timed("app.office.bankAccounts.repo.findByUuid") Optional findByUuid(UUID id); @Query(""" @@ -18,7 +18,7 @@ public interface HsOfficeBankAccountRepository extends Repository findByOptionalHolderLikeImpl(String holder); default List findByOptionalHolderLike(String holder) { @@ -26,15 +26,15 @@ public interface HsOfficeBankAccountRepository extends Repository findByIbanOrderByIbanAsc(String iban); - @Timed("app.bankAccounts.repo.save") + @Timed("app.office.bankAccounts.repo.save") S save(S entity); - @Timed("app.bankAccounts.repo.deleteByUuid") + @Timed("app.office.bankAccounts.repo.deleteByUuid") int deleteByUuid(final UUID uuid); - @Timed("app.bankAccounts.repo.count") + @Timed("app.office.bankAccounts.repo.count") long count(); } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactController.java index 5c6a8a3a..fe08bd4f 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactController.java @@ -34,7 +34,7 @@ public class HsOfficeContactController implements HsOfficeContactsApi { @Override @Transactional(readOnly = true) - @Timed("app.contacts.api.getListOfContacts") + @Timed("app.office.contacts.api.getListOfContacts") public ResponseEntity> getListOfContacts( final String currentSubject, final String assumedRoles, @@ -49,7 +49,7 @@ public class HsOfficeContactController implements HsOfficeContactsApi { @Override @Transactional - @Timed("app.contacts.api.postNewContact") + @Timed("app.office.contacts.api.postNewContact") public ResponseEntity postNewContact( final String currentSubject, final String assumedRoles, @@ -72,7 +72,7 @@ public class HsOfficeContactController implements HsOfficeContactsApi { @Override @Transactional(readOnly = true) - @Timed("app.contacts.api.getSingleContactByUuid") + @Timed("app.office.contacts.api.getSingleContactByUuid") public ResponseEntity getSingleContactByUuid( final String currentSubject, final String assumedRoles, @@ -89,7 +89,7 @@ public class HsOfficeContactController implements HsOfficeContactsApi { @Override @Transactional - @Timed("app.contacts.api.deleteContactByUuid") + @Timed("app.office.contacts.api.deleteContactByUuid") public ResponseEntity deleteContactByUuid( final String currentSubject, final String assumedRoles, @@ -106,7 +106,7 @@ public class HsOfficeContactController implements HsOfficeContactsApi { @Override @Transactional - @Timed("app.contacts.api.patchContact") + @Timed("app.office.contacts.api.patchContact") public ResponseEntity patchContact( final String currentSubject, final String assumedRoles, diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactRbacRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactRbacRepository.java index 58f9ba61..f3a88bc0 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactRbacRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactRbacRepository.java @@ -10,7 +10,7 @@ import java.util.UUID; public interface HsOfficeContactRbacRepository extends Repository { - @Timed("app.contacts.repo.findByUuid.rbac") + @Timed("app.office.contacts.repo.findByUuid.rbac") Optional findByUuid(UUID id); @Query(""" @@ -18,15 +18,15 @@ public interface HsOfficeContactRbacRepository extends Repository findContactByOptionalCaptionLike(String caption); - @Timed("app.contacts.repo.save.rbac") + @Timed("app.office.contacts.repo.save.rbac") HsOfficeContactRbacEntity save(final HsOfficeContactRbacEntity entity); - @Timed("app.contacts.repo.deleteByUuid.rbac") + @Timed("app.office.contacts.repo.deleteByUuid.rbac") int deleteByUuid(final UUID uuid); - @Timed("app.contacts.repo.count.rbac") + @Timed("app.office.contacts.repo.count.rbac") long count(); } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactRealRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactRealRepository.java index a42c2226..3a65aea6 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactRealRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/contact/HsOfficeContactRealRepository.java @@ -10,7 +10,7 @@ import java.util.UUID; public interface HsOfficeContactRealRepository extends Repository { - @Timed("app.repo.contacts.findByUuid.real") + @Timed("app.office.contacts.repo.findByUuid.real") Optional findByUuid(UUID id); @Query(""" @@ -18,15 +18,15 @@ public interface HsOfficeContactRealRepository extends Repository findContactByOptionalCaptionLike(String caption); - @Timed("app.repo.contacts.save.real") + @Timed("app.office.contacts.repo.save.real") HsOfficeContactRealEntity save(final HsOfficeContactRealEntity entity); - @Timed("app.repo.contacts.deleteByUuid.real") + @Timed("app.office.contacts.repo.deleteByUuid.real") int deleteByUuid(final UUID uuid); - @Timed("app.repo.contacts.count.real") + @Timed("app.office.contacts.repo.count.real") long count(); } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java index b3b35ddb..fbb59788 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java @@ -56,7 +56,7 @@ public class HsOfficeCoopAssetsTransactionController implements HsOfficeCoopAsse @Override @Transactional(readOnly = true) - @Timed("app.coopAssets.api.getListOfCoopAssets") + @Timed("app.office.coopAssets.api.getListOfCoopAssets") public ResponseEntity> getListOfCoopAssets( final String currentSubject, final String assumedRoles, @@ -79,7 +79,7 @@ public class HsOfficeCoopAssetsTransactionController implements HsOfficeCoopAsse @Override @Transactional - @Timed("app.coopAssets.api.postNewCoopAssetTransaction") + @Timed("app.office.coopAssets.api.postNewCoopAssetTransaction") public ResponseEntity postNewCoopAssetTransaction( final String currentSubject, final String assumedRoles, @@ -105,7 +105,7 @@ public class HsOfficeCoopAssetsTransactionController implements HsOfficeCoopAsse @Override @Transactional(readOnly = true) - @Timed("app.coopAssets.api.getSingleCoopAssetTransactionByUuid") + @Timed("app.office.coopAssets.api.getSingleCoopAssetTransactionByUuid") public ResponseEntity getSingleCoopAssetTransactionByUuid( final String currentSubject, final String assumedRoles, final UUID assetTransactionUuid) { diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepository.java index 26c2d09b..7a8c7ad9 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepository.java @@ -11,7 +11,7 @@ import java.util.UUID; public interface HsOfficeCoopAssetsTransactionRepository extends Repository { - @Timed("app.coopAssets.repo.findByUuid") + @Timed("app.office.coopAssets.repo.findByUuid") Optional findByUuid(UUID id); @Query(""" @@ -21,13 +21,13 @@ public interface HsOfficeCoopAssetsTransactionRepository extends Repository findCoopAssetsTransactionByOptionalMembershipUuidAndDateRange( UUID membershipUuid, LocalDate fromValueDate, LocalDate toValueDate); - @Timed("app.coopAssets.repo.save") + @Timed("app.office.coopAssets.repo.save") HsOfficeCoopAssetsTransactionEntity save(final HsOfficeCoopAssetsTransactionEntity entity); - @Timed("app.coopAssets.repo.count") + @Timed("app.office.coopAssets.repo.count") long count(); } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionController.java index 12540e66..b903dd85 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionController.java @@ -41,7 +41,7 @@ public class HsOfficeCoopSharesTransactionController implements HsOfficeCoopShar @Override @Transactional(readOnly = true) - @Timed("app.coopShares.api.getListOfCoopShares") + @Timed("app.office.coopShares.api.getListOfCoopShares") public ResponseEntity> getListOfCoopShares( final String currentSubject, final String assumedRoles, @@ -61,7 +61,7 @@ public class HsOfficeCoopSharesTransactionController implements HsOfficeCoopShar @Override @Transactional - @Timed("app.coopShares.repo.postNewCoopSharesTransaction") + @Timed("app.office.coopShares.repo.postNewCoopSharesTransaction") public ResponseEntity postNewCoopSharesTransaction( final String currentSubject, final String assumedRoles, @@ -85,7 +85,7 @@ public class HsOfficeCoopSharesTransactionController implements HsOfficeCoopShar @Override @Transactional(readOnly = true) - @Timed("app.coopShares.repo.getSingleCoopShareTransactionByUuid") + @Timed("app.office.coopShares.repo.getSingleCoopShareTransactionByUuid") public ResponseEntity getSingleCoopShareTransactionByUuid( final String currentSubject, final String assumedRoles, final UUID shareTransactionUuid) { diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionRepository.java index d8322870..08429c97 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionRepository.java @@ -11,7 +11,7 @@ import java.util.UUID; public interface HsOfficeCoopSharesTransactionRepository extends Repository { - @Timed("app.coopShares.repo.findByUuid") + @Timed("app.office.coopShares.repo.findByUuid") Optional findByUuid(UUID id); @Query(""" @@ -21,13 +21,13 @@ public interface HsOfficeCoopSharesTransactionRepository extends Repository findCoopSharesTransactionByOptionalMembershipUuidAndDateRange( UUID membershipUuid, LocalDate fromValueDate, LocalDate toValueDate); - @Timed("app.coopShares.repo.save") + @Timed("app.office.coopShares.repo.save") HsOfficeCoopSharesTransactionEntity save(final HsOfficeCoopSharesTransactionEntity entity); - @Timed("app.coopShares.repo.count") + @Timed("app.office.coopShares.repo.count") long count(); } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorController.java index 391f7a2d..1792acdb 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorController.java @@ -52,7 +52,7 @@ public class HsOfficeDebitorController implements HsOfficeDebitorsApi { @Override @Transactional(readOnly = true) - @Timed("app.debitors.api.getListOfDebitors") + @Timed("app.office.debitors.api.getListOfDebitors") public ResponseEntity> getListOfDebitors( final String currentSubject, final String assumedRoles, @@ -70,7 +70,7 @@ public class HsOfficeDebitorController implements HsOfficeDebitorsApi { @Override @Transactional - @Timed("app.debitors.api.postNewDebitor") + @Timed("app.office.debitors.api.postNewDebitor") public ResponseEntity postNewDebitor( String currentSubject, String assumedRoles, @@ -118,7 +118,7 @@ public class HsOfficeDebitorController implements HsOfficeDebitorsApi { @Override @Transactional(readOnly = true) - @Timed("app.debitors.api.getSingleDebitorByUuid") + @Timed("app.office.debitors.api.getSingleDebitorByUuid") public ResponseEntity getSingleDebitorByUuid( final String currentSubject, final String assumedRoles, @@ -135,7 +135,7 @@ public class HsOfficeDebitorController implements HsOfficeDebitorsApi { @Override @Transactional - @Timed("app.debitors.api.deleteDebitorByUuid") + @Timed("app.office.debitors.api.deleteDebitorByUuid") public ResponseEntity deleteDebitorByUuid( final String currentSubject, final String assumedRoles, @@ -152,7 +152,7 @@ public class HsOfficeDebitorController implements HsOfficeDebitorsApi { @Override @Transactional - @Timed("app.debitors.api.patchDebitor") + @Timed("app.office.debitors.api.patchDebitor") public ResponseEntity patchDebitor( final String currentSubject, final String assumedRoles, diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepository.java index 817eb202..ab51663d 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepository.java @@ -10,7 +10,7 @@ import java.util.UUID; public interface HsOfficeDebitorRepository extends Repository { - @Timed("app.debitors.repo.findByUuid") + @Timed("app.office.debitors.repo.findByUuid") Optional findByUuid(UUID id); @Query(""" @@ -21,7 +21,7 @@ public interface HsOfficeDebitorRepository extends Repository findDebitorByPartnerNumberAndDebitorNumberSuffix(int partnerNumber, String debitorNumberSuffix); default List findDebitorByDebitorNumber(int debitorNumber) { @@ -49,15 +49,15 @@ public interface HsOfficeDebitorRepository extends Repository findDebitorByOptionalNameLike(String name); - @Timed("app.debitors.repo.save") + @Timed("app.office.debitors.repo.save") HsOfficeDebitorEntity save(final HsOfficeDebitorEntity entity); - @Timed("app.debitors.repo.count") + @Timed("app.office.debitors.repo.count") long count(); - @Timed("app.debitors.repo.deleteByUuid") + @Timed("app.office.debitors.repo.deleteByUuid") int deleteByUuid(UUID uuid); } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerController.java index c2f66594..5e8bba57 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerController.java @@ -51,7 +51,7 @@ public class HsOfficePartnerController implements HsOfficePartnersApi { @Override @Transactional(readOnly = true) - @Timed("app.partners.api.getListOfPartners") + @Timed("app.office.partners.api.getListOfPartners") public ResponseEntity> getListOfPartners( final String currentSubject, final String assumedRoles, @@ -66,7 +66,7 @@ public class HsOfficePartnerController implements HsOfficePartnersApi { @Override @Transactional - @Timed("app.partners.api.postNewPartner") + @Timed("app.office.partners.api.postNewPartner") public ResponseEntity postNewPartner( final String currentSubject, final String assumedRoles, @@ -89,7 +89,7 @@ public class HsOfficePartnerController implements HsOfficePartnersApi { @Override @Transactional(readOnly = true) - @Timed("app.partners.api.getSinglePartnerByUuid") + @Timed("app.office.partners.api.getSinglePartnerByUuid") public ResponseEntity getSinglePartnerByUuid( final String currentSubject, final String assumedRoles, @@ -106,7 +106,7 @@ public class HsOfficePartnerController implements HsOfficePartnersApi { @Override @Transactional - @Timed("app.partners.api.deletePartnerByUuid") + @Timed("app.office.partners.api.deletePartnerByUuid") public ResponseEntity deletePartnerByUuid( final String currentSubject, final String assumedRoles, @@ -127,7 +127,7 @@ public class HsOfficePartnerController implements HsOfficePartnersApi { @Override @Transactional - @Timed("app.partners.api.patchPartner") + @Timed("app.office.partners.api.patchPartner") public ResponseEntity patchPartner( final String currentSubject, final String assumedRoles, diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRepository.java index 24a52568..5a804d40 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRepository.java @@ -10,10 +10,10 @@ import java.util.UUID; public interface HsOfficePartnerRepository extends Repository { - @Timed("app.partners.repo.findByUuid") + @Timed("app.office.partners.repo.findByUuid") Optional findByUuid(UUID id); - @Timed("app.partners.repo.findAll") + @Timed("app.office.partners.repo.findAll") List findAll(); // TODO.refa: move to a repo in test sources @Query(""" @@ -28,18 +28,18 @@ public interface HsOfficePartnerRepository extends Repository findPartnerByOptionalNameLike(String name); - @Timed("app.partners.repo.findPartnerByPartnerNumber") + @Timed("app.office.partners.repo.findPartnerByPartnerNumber") HsOfficePartnerEntity findPartnerByPartnerNumber(Integer partnerNumber); - @Timed("app.partners.repo.save") + @Timed("app.office.partners.repo.save") HsOfficePartnerEntity save(final HsOfficePartnerEntity entity); - @Timed("app.partners.repo.count") + @Timed("app.office.partners.repo.count") long count(); - @Timed("app.partners.repo.deleteByUuid") + @Timed("app.office.partners.repo.deleteByUuid") int deleteByUuid(UUID uuid); } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonController.java index d1c1c018..bf277a54 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonController.java @@ -31,7 +31,7 @@ public class HsOfficePersonController implements HsOfficePersonsApi { @Override @Transactional(readOnly = true) - @Timed("app.persons.api.getListOfPersons") + @Timed("app.office.persons.api.getListOfPersons") public ResponseEntity> getListOfPersons( final String currentSubject, final String assumedRoles, @@ -46,7 +46,7 @@ public class HsOfficePersonController implements HsOfficePersonsApi { @Override @Transactional - @Timed("app.persons.api.postNewPerson") + @Timed("app.office.persons.api.postNewPerson") public ResponseEntity postNewPerson( final String currentSubject, final String assumedRoles, @@ -69,7 +69,7 @@ public class HsOfficePersonController implements HsOfficePersonsApi { @Override @Transactional(readOnly = true) - @Timed("app.persons.api.getSinglePersonByUuid") + @Timed("app.office.persons.api.getSinglePersonByUuid") public ResponseEntity getSinglePersonByUuid( final String currentSubject, final String assumedRoles, @@ -86,7 +86,7 @@ public class HsOfficePersonController implements HsOfficePersonsApi { @Override @Transactional - @Timed("app.persons.api.deletePersonByUuid") + @Timed("app.office.persons.api.deletePersonByUuid") public ResponseEntity deletePersonByUuid( final String currentSubject, final String assumedRoles, @@ -103,7 +103,7 @@ public class HsOfficePersonController implements HsOfficePersonsApi { @Override @Transactional - @Timed("app.persons.api.patchPerson") + @Timed("app.office.persons.api.patchPerson") public ResponseEntity patchPerson( final String currentSubject, final String assumedRoles, diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRepository.java index 41d195ce..91a2c2b3 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRepository.java @@ -10,7 +10,7 @@ import java.util.UUID; public interface HsOfficePersonRepository extends Repository { - @Timed("app.persons.repo.findByUuid.rbac") + @Timed("app.office.persons.repo.findByUuid.rbac") Optional findByUuid(UUID personUuid); @Query(""" @@ -20,15 +20,15 @@ public interface HsOfficePersonRepository extends Repository findPersonByOptionalNameLike(String name); - @Timed("app.persons.repo.save.rbac") + @Timed("app.office.persons.repo.save.rbac") HsOfficePersonEntity save(final HsOfficePersonEntity entity); - @Timed("app.persons.repo.deleteByUuid.rbac") + @Timed("app.office.persons.repo.deleteByUuid.rbac") int deleteByUuid(final UUID personUuid); - @Timed("app.persons.repo.count.rbac") + @Timed("app.office.persons.repo.count.rbac") long count(); } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationController.java index 5778d864..b8b8cd61 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationController.java @@ -44,7 +44,7 @@ public class HsOfficeRelationController implements HsOfficeRelationsApi { @Override @Transactional(readOnly = true) - @Timed("app.relations.api.getListOfRelations") + @Timed("app.office.relations.api.getListOfRelations") public ResponseEntity> getListOfRelations( final String currentSubject, final String assumedRoles, @@ -67,7 +67,7 @@ public class HsOfficeRelationController implements HsOfficeRelationsApi { @Override @Transactional - @Timed("app.relations.api.postNewRelation") + @Timed("app.office.relations.api.postNewRelation") public ResponseEntity postNewRelation( final String currentSubject, final String assumedRoles, @@ -102,7 +102,7 @@ public class HsOfficeRelationController implements HsOfficeRelationsApi { @Override @Transactional(readOnly = true) - @Timed("app.relations.api.getSingleRelationByUuid") + @Timed("app.office.relations.api.getSingleRelationByUuid") public ResponseEntity getSingleRelationByUuid( final String currentSubject, final String assumedRoles, @@ -136,7 +136,7 @@ public class HsOfficeRelationController implements HsOfficeRelationsApi { @Override @Transactional - @Timed("app.relations.api.patchRelation") + @Timed("app.office.relations.api.patchRelation") public ResponseEntity patchRelation( final String currentSubject, final String assumedRoles, diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRbacRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRbacRepository.java index 23889745..0443bc00 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRbacRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRbacRepository.java @@ -11,14 +11,14 @@ import java.util.UUID; public interface HsOfficeRelationRbacRepository extends Repository { - @Timed("app.relations.repo.findByUuid.rbac") + @Timed("app.office.relations.repo.findByUuid.rbac") Optional findByUuid(UUID id); @Query(value = """ SELECT p.* FROM hs_office.relation_rv AS p WHERE p.anchorUuid = :personUuid OR p.holderUuid = :personUuid """, nativeQuery = true) - @Timed("app.relations.repo.findRelationRelatedToPersonUuid.rbac") + @Timed("app.office.relations.repo.findRelationRelatedToPersonUuid.rbac") List findRelationRelatedToPersonUuid(@NotNull UUID personUuid); /** @@ -54,20 +54,20 @@ public interface HsOfficeRelationRbacRepository extends Repository findRelationRelatedToPersonUuidRelationTypePersonAndContactDataImpl( final UUID personUuid, final String relationType, final String personData, final String contactData); - @Timed("app.relations.repo.save.rbac") + @Timed("app.office.relations.repo.save.rbac") HsOfficeRelationRbacEntity save(final HsOfficeRelationRbacEntity entity); - @Timed("app.relations.repo.count.rbac") + @Timed("app.office.relations.repo.count.rbac") long count(); - @Timed("app.relations.repo.deleteByUuid.rbac") + @Timed("app.office.relations.repo.deleteByUuid.rbac") int deleteByUuid(UUID uuid); private static String toSqlLikeOperand(final String text) { diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateController.java index 05916d7c..02a3beb4 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateController.java @@ -39,7 +39,7 @@ public class HsOfficeSepaMandateController implements HsOfficeSepaMandatesApi { @Override @Transactional(readOnly = true) - @Timed("app.sepaMandates.api.getListOfSepaMandates") + @Timed("app.office.sepaMandates.api.getListOfSepaMandates") public ResponseEntity> getListOfSepaMandates( final String currentSubject, final String assumedRoles, @@ -55,7 +55,7 @@ public class HsOfficeSepaMandateController implements HsOfficeSepaMandatesApi { @Override @Transactional - @Timed("app.sepaMandates.api.postNewSepaMandate") + @Timed("app.office.sepaMandates.api.postNewSepaMandate") public ResponseEntity postNewSepaMandate( final String currentSubject, final String assumedRoles, @@ -79,7 +79,7 @@ public class HsOfficeSepaMandateController implements HsOfficeSepaMandatesApi { @Override @Transactional(readOnly = true) - @Timed("app.sepaMandates.api.getSingleSepaMandateByUuid") + @Timed("app.office.sepaMandates.api.getSingleSepaMandateByUuid") public ResponseEntity getSingleSepaMandateByUuid( final String currentSubject, final String assumedRoles, @@ -97,7 +97,7 @@ public class HsOfficeSepaMandateController implements HsOfficeSepaMandatesApi { @Override @Transactional - @Timed("app.sepaMandates.api.deleteSepaMandateByUuid") + @Timed("app.office.sepaMandates.api.deleteSepaMandateByUuid") public ResponseEntity deleteSepaMandateByUuid( final String currentSubject, final String assumedRoles, @@ -114,7 +114,7 @@ public class HsOfficeSepaMandateController implements HsOfficeSepaMandatesApi { @Override @Transactional - @Timed("app.sepaMandates.api.patchSepaMandate") + @Timed("app.office.sepaMandates.api.patchSepaMandate") public ResponseEntity patchSepaMandate( final String currentSubject, final String assumedRoles, diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateRepository.java index 24ebfe1d..5e414838 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateRepository.java @@ -10,7 +10,7 @@ import java.util.UUID; public interface HsOfficeSepaMandateRepository extends Repository { - @Timed("app.sepaMandates.repo.findByUuid") + @Timed("app.office.sepaMandates.repo.findByUuid") Optional findByUuid(UUID id); @Query(""" @@ -19,15 +19,15 @@ public interface HsOfficeSepaMandateRepository extends Repository findSepaMandateByOptionalIban(String iban); - @Timed("app.sepaMandates.repo.save") + @Timed("app.office.sepaMandates.repo.save") HsOfficeSepaMandateEntity save(final HsOfficeSepaMandateEntity entity); - @Timed("app.sepaMandates.repo.count") + @Timed("app.office.sepaMandates.repo.count") long count(); - @Timed("app.sepaMandates.repo.deleteByUuid") + @Timed("app.office.sepaMandates.repo.deleteByUuid") int deleteByUuid(UUID uuid); } -- 2.39.5 From df3f1dd5aae4ba7aff8b2ce4b0056d8987c87f6d Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 4 Dec 2024 15:56:34 +0100 Subject: [PATCH 09/13] split HsOfficePersonEntity into HsOfficePerson+HsOfficePersonRealEntity+HsOfficePersonRbacEntity --- .../debitor/HsOfficeDebitorRepository.java | 2 +- .../partner/HsOfficePartnerController.java | 6 +- .../office/partner/HsOfficePartnerEntity.java | 4 +- .../partner/HsOfficePartnerRepository.java | 2 +- .../person/HsOfficePersonController.java | 4 +- .../office/person/HsOfficePersonEntity.java | 103 ------------------ .../person/HsOfficePersonEntityPatcher.java | 4 +- .../person/HsOfficePersonRbacEntity.java | 52 +++++++++ ...java => HsOfficePersonRbacRepository.java} | 10 +- .../person/HsOfficePersonRealEntity.java | 23 ++++ .../person/HsOfficePersonRealRepository.java | 34 ++++++ .../hs/office/relation/HsOfficeRelation.java | 6 +- .../relation/HsOfficeRelationController.java | 8 +- .../relation/HsOfficeRelationRbacEntity.java | 6 +- .../hs/migration/BaseOfficeDataImport.java | 16 +-- ...OfficeDebitorControllerAcceptanceTest.java | 20 ++-- .../HsOfficeDebitorEntityUnitTest.java | 6 +- ...fficeDebitorRepositoryIntegrationTest.java | 4 +- .../office/debitor/TestHsOfficeDebitor.java | 6 +- ...OfficePartnerControllerAcceptanceTest.java | 8 +- .../HsOfficePartnerControllerRestTest.java | 10 +- ...cePartnerDetailsEntityPatcherUnitTest.java | 6 +- .../HsOfficePartnerEntityPatcherUnitTest.java | 4 +- .../HsOfficePartnerEntityUnitTest.java | 6 +- ...fficePartnerRepositoryIntegrationTest.java | 4 +- .../office/partner/TestHsOfficePartner.java | 6 +- ...sOfficePersonControllerAcceptanceTest.java | 8 +- .../HsOfficePersonEntityPatcherUnitTest.java | 20 ++-- .../person/HsOfficePersonEntityUnitTest.java | 26 ++--- ...OfficePersonRepositoryIntegrationTest.java | 20 ++-- .../hs/office/person/TestHsOfficePerson.java | 6 +- ...RealRelationRepositoryIntegrationTest.java | 4 +- ...fficeRelationControllerAcceptanceTest.java | 4 +- .../HsOfficeRelationPatcherUnitTest.java | 6 +- ...ficeRelationRepositoryIntegrationTest.java | 4 +- .../relation/HsOfficeRelationUnitTest.java | 6 +- .../hsadminng/hs/scenarios/ScenarioTest.java | 8 +- 37 files changed, 239 insertions(+), 233 deletions(-) delete mode 100644 src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonEntity.java create mode 100644 src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRbacEntity.java rename src/main/java/net/hostsharing/hsadminng/hs/office/person/{HsOfficePersonRepository.java => HsOfficePersonRbacRepository.java} (71%) create mode 100644 src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRealEntity.java create mode 100644 src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRealRepository.java diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepository.java index ab51663d..a62d1c42 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepository.java @@ -36,7 +36,7 @@ public interface HsOfficeDebitorRepository extends Repository ofNullable(p.getPartnerRel()) .map(HsOfficeRelation::getHolder) - .map(HsOfficePersonEntity::toShortString) + .map(HsOfficePerson::toShortString) .orElse(null)) .withProp(p -> ofNullable(p.getPartnerRel()) .map(HsOfficeRelation::getContact) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRepository.java index 5a804d40..282d3db3 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRepository.java @@ -20,7 +20,7 @@ public interface HsOfficePartnerRepository extends Repository, Stringifyable { - - private static Stringify toString = stringify(HsOfficePersonEntity.class, "person") - .withProp(Fields.personType, HsOfficePersonEntity::getPersonType) - .withProp(Fields.tradeName, HsOfficePersonEntity::getTradeName) - .withProp(Fields.salutation, HsOfficePersonEntity::getSalutation) - .withProp(Fields.title, HsOfficePersonEntity::getTitle) - .withProp(Fields.familyName, HsOfficePersonEntity::getFamilyName) - .withProp(Fields.givenName, HsOfficePersonEntity::getGivenName); - - @Id - @GeneratedValue - private UUID uuid; - - @Version - private int version; - - @Column(name = "persontype") - private HsOfficePersonType personType; - - @Column(name = "tradename") - private String tradeName; - - @Column(name = "salutation") - private String salutation; - - @Column(name = "title") - private String title; - - @Column(name = "familyname") - private String familyName; - - @Column(name = "givenname") - private String givenName; - - @Override - public String toString() { - return toString.apply(this); - } - - @Override - public String toShortString() { - return personType + " " + - (!StringUtils.isEmpty(tradeName) ? tradeName : (familyName + ", " + givenName)); - } - - public static RbacView rbac() { - return rbacViewFor("person", HsOfficePersonEntity.class) - .withIdentityView(SQL.projection("concat(tradeName, familyName, givenName)")) - .withUpdatableColumns("personType", "title", "salutation", "tradeName", "givenName", "familyName") - .toRole(GLOBAL, GUEST).grantPermission(INSERT) - - .createRole(OWNER, (with) -> { - with.permission(DELETE); - with.owningUser(CREATOR); - with.incomingSuperRole(GLOBAL, ADMIN); - }) - .createSubRole(ADMIN, (with) -> { - with.permission(UPDATE); - }) - .createSubRole(REFERRER, (with) -> { - with.permission(SELECT); - }); - } - - - public static void main(String[] args) throws IOException { - rbac().generateWithBaseFileName("5-hs-office/502-person/5023-hs-office-person-rbac"); - } -} diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonEntityPatcher.java b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonEntityPatcher.java index ede3fc03..77cd16aa 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonEntityPatcher.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonEntityPatcher.java @@ -9,9 +9,9 @@ import java.util.Optional; class HsOfficePersonEntityPatcher implements EntityPatcher { - private final HsOfficePersonEntity entity; + private final HsOfficePersonRbacEntity entity; - HsOfficePersonEntityPatcher(final HsOfficePersonEntity entity) { + HsOfficePersonEntityPatcher(final HsOfficePersonRbacEntity entity) { this.entity = entity; } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRbacEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRbacEntity.java new file mode 100644 index 00000000..a9011558 --- /dev/null +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRbacEntity.java @@ -0,0 +1,52 @@ +package net.hostsharing.hsadminng.hs.office.person; + +import lombok.*; +import lombok.experimental.FieldNameConstants; +import lombok.experimental.SuperBuilder; +import net.hostsharing.hsadminng.errors.DisplayAs; +import net.hostsharing.hsadminng.rbac.generator.RbacView; +import net.hostsharing.hsadminng.rbac.generator.RbacView.SQL; + +import jakarta.persistence.*; +import java.io.IOException; + +import static net.hostsharing.hsadminng.rbac.generator.RbacView.GLOBAL; +import static net.hostsharing.hsadminng.rbac.generator.RbacView.Permission.*; +import static net.hostsharing.hsadminng.rbac.generator.RbacView.RbacSubjectReference.UserRole.CREATOR; +import static net.hostsharing.hsadminng.rbac.generator.RbacView.Role.*; +import static net.hostsharing.hsadminng.rbac.generator.RbacView.rbacViewFor; + +@Entity +@Table(schema = "hs_office", name = "person_rv") +@Getter +@Setter +@NoArgsConstructor +@SuperBuilder(toBuilder = true) +@FieldNameConstants +@DisplayAs("RbacPerson") +public class HsOfficePersonRbacEntity extends HsOfficePerson { + + public static RbacView rbac() { + return rbacViewFor("person", HsOfficePersonRbacEntity.class) + .withIdentityView(SQL.projection("concat(tradeName, familyName, givenName)")) + .withUpdatableColumns("personType", "title", "salutation", "tradeName", "givenName", "familyName") + .toRole(GLOBAL, GUEST).grantPermission(INSERT) + + .createRole(OWNER, (with) -> { + with.permission(DELETE); + with.owningUser(CREATOR); + with.incomingSuperRole(GLOBAL, ADMIN); + }) + .createSubRole(ADMIN, (with) -> { + with.permission(UPDATE); + }) + .createSubRole(REFERRER, (with) -> { + with.permission(SELECT); + }); + } + + + public static void main(String[] args) throws IOException { + rbac().generateWithBaseFileName("5-hs-office/502-person/5023-hs-office-person-rbac"); + } +} diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRbacRepository.java similarity index 71% rename from src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRepository.java rename to src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRbacRepository.java index 91a2c2b3..a6b2a436 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRbacRepository.java @@ -8,23 +8,23 @@ import java.util.List; import java.util.Optional; import java.util.UUID; -public interface HsOfficePersonRepository extends Repository { +public interface HsOfficePersonRbacRepository extends Repository { @Timed("app.office.persons.repo.findByUuid.rbac") - Optional findByUuid(UUID personUuid); + Optional findByUuid(UUID personUuid); @Query(""" - SELECT p FROM HsOfficePersonEntity p + SELECT p FROM HsOfficePersonRbacEntity p WHERE :name is null OR p.tradeName like concat(cast(:name as text), '%') OR p.givenName like concat(cast(:name as text), '%') OR p.familyName like concat(cast(:name as text), '%') """) @Timed("app.office.persons.repo.findPersonByOptionalNameLike.rbac") - List findPersonByOptionalNameLike(String name); + List findPersonByOptionalNameLike(String name); @Timed("app.office.persons.repo.save.rbac") - HsOfficePersonEntity save(final HsOfficePersonEntity entity); + HsOfficePersonRbacEntity save(final HsOfficePersonRbacEntity entity); @Timed("app.office.persons.repo.deleteByUuid.rbac") int deleteByUuid(final UUID personUuid); diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRealEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRealEntity.java new file mode 100644 index 00000000..766785a0 --- /dev/null +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRealEntity.java @@ -0,0 +1,23 @@ +package net.hostsharing.hsadminng.hs.office.person; + +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.FieldNameConstants; +import lombok.experimental.SuperBuilder; +import net.hostsharing.hsadminng.errors.DisplayAs; + +import jakarta.persistence.Entity; +import jakarta.persistence.Table; + + +@Entity +@Table(schema = "hs_office", name = "person") +@Getter +@Setter +@NoArgsConstructor +@SuperBuilder(toBuilder = true) +@FieldNameConstants +@DisplayAs("RealPerson") +public class HsOfficePersonRealEntity extends HsOfficePerson { +} diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRealRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRealRepository.java new file mode 100644 index 00000000..5041b702 --- /dev/null +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRealRepository.java @@ -0,0 +1,34 @@ +package net.hostsharing.hsadminng.hs.office.person; + +import io.micrometer.core.annotation.Timed; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.Repository; + +import java.util.List; +import java.util.Optional; +import java.util.UUID; + +public interface HsOfficePersonRealRepository extends Repository { + + @Timed("app.office.persons.repo.findByUuid.rbac") + Optional findByUuid(UUID personUuid); + + @Query(""" + SELECT p FROM HsOfficePersonRbacEntity p + WHERE :name is null + OR p.tradeName like concat(cast(:name as text), '%') + OR p.givenName like concat(cast(:name as text), '%') + OR p.familyName like concat(cast(:name as text), '%') + """) + @Timed("app.office.persons.repo.findPersonByOptionalNameLike.rbac") + List findPersonByOptionalNameLike(String name); + + @Timed("app.office.persons.repo.save.rbac") + HsOfficePersonRealEntity save(final HsOfficePersonRealEntity entity); + + @Timed("app.office.persons.repo.deleteByUuid.rbac") + int deleteByUuid(final UUID personUuid); + + @Timed("app.office.persons.repo.count.rbac") + long count(); +} diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelation.java b/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelation.java index c1b4ad8c..7a687a3b 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelation.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelation.java @@ -4,7 +4,7 @@ import lombok.*; import lombok.experimental.FieldNameConstants; import lombok.experimental.SuperBuilder; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealEntity; -import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity; +import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealEntity; import net.hostsharing.hsadminng.persistence.BaseEntity; import net.hostsharing.hsadminng.repr.Stringify; import net.hostsharing.hsadminng.repr.Stringifyable; @@ -45,11 +45,11 @@ public class HsOfficeRelation implements BaseEntity, Stringify @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "anchoruuid") - private HsOfficePersonEntity anchor; + private HsOfficePersonRealEntity anchor; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "holderuuid") - private HsOfficePersonEntity holder; + private HsOfficePersonRealEntity holder; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "contactuuid") diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationController.java index b8b8cd61..d543e81e 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationController.java @@ -5,7 +5,7 @@ import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealRepository; import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeRelationsApi; import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.*; -import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository; +import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealRepository; import net.hostsharing.hsadminng.mapper.StandardMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; @@ -34,7 +34,7 @@ public class HsOfficeRelationController implements HsOfficeRelationsApi { private HsOfficeRelationRbacRepository relationRbacRepo; @Autowired - private HsOfficePersonRepository holderRepo; + private HsOfficePersonRealRepository personRepo; @Autowired private HsOfficeContactRealRepository realContactRepo; @@ -78,10 +78,10 @@ public class HsOfficeRelationController implements HsOfficeRelationsApi { final var entityToSave = new HsOfficeRelationRbacEntity(); entityToSave.setType(HsOfficeRelationType.valueOf(body.getType())); entityToSave.setMark(body.getMark()); - entityToSave.setAnchor(holderRepo.findByUuid(body.getAnchorUuid()).orElseThrow( + entityToSave.setAnchor(personRepo.findByUuid(body.getAnchorUuid()).orElseThrow( () -> new NoSuchElementException("cannot find Person by anchorUuid: " + body.getAnchorUuid()) )); - entityToSave.setHolder(holderRepo.findByUuid(body.getHolderUuid()).orElseThrow( + entityToSave.setHolder(personRepo.findByUuid(body.getHolderUuid()).orElseThrow( () -> new NoSuchElementException("cannot find Person by holderUuid: " + body.getHolderUuid()) )); entityToSave.setContact(realContactRepo.findByUuid(body.getContactUuid()).orElseThrow( diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRbacEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRbacEntity.java index e6e1beea..062c3702 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRbacEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRbacEntity.java @@ -6,7 +6,7 @@ import lombok.Setter; import lombok.experimental.SuperBuilder; import net.hostsharing.hsadminng.errors.DisplayAs; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRbacEntity; -import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity; +import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRbacEntity; import net.hostsharing.hsadminng.rbac.generator.RbacView; import net.hostsharing.hsadminng.rbac.generator.RbacView.SQL; @@ -52,11 +52,11 @@ public class HsOfficeRelationRbacEntity extends HsOfficeRelation { .withRestrictedViewOrderBy(SQL.expression( "(select idName from hs_office.person_iv p where p.uuid = target.holderUuid)")) .withUpdatableColumns("contactUuid") - .importEntityAlias("anchorPerson", HsOfficePersonEntity.class, usingDefaultCase(), + .importEntityAlias("anchorPerson", HsOfficePersonRbacEntity.class, usingDefaultCase(), dependsOnColumn("anchorUuid"), directlyFetchedByDependsOnColumn(), NOT_NULL) - .importEntityAlias("holderPerson", HsOfficePersonEntity.class, usingDefaultCase(), + .importEntityAlias("holderPerson", HsOfficePersonRbacEntity.class, usingDefaultCase(), dependsOnColumn("holderUuid"), directlyFetchedByDependsOnColumn(), NOT_NULL) 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 311ce4ad..7e9bd3c3 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java @@ -11,7 +11,7 @@ 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.person.HsOfficePersonEntity; +import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealEntity; import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelation; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity; @@ -81,7 +81,7 @@ public abstract class BaseOfficeDataImport extends CsvDataImport { ); static Map contacts = new WriteOnceMap<>(); - static Map persons = new WriteOnceMap<>(); + static Map persons = new WriteOnceMap<>(); static Map partners = new WriteOnceMap<>(); static Map debitors = new WriteOnceMap<>(); static Map memberships = new WriteOnceMap<>(); @@ -731,7 +731,7 @@ public abstract class BaseOfficeDataImport extends CsvDataImport { return; } - final var person = HsOfficePersonEntity.builder().build(); + final var person = HsOfficePersonRealEntity.builder().build(); final var partnerRel = addRelation( HsOfficeRelationType.PARTNER, @@ -994,14 +994,14 @@ public abstract class BaseOfficeDataImport extends CsvDataImport { addPerson(partnerPerson, rec); } - HsOfficePersonEntity contactPerson = partnerPerson; + HsOfficePersonRealEntity contactPerson = partnerPerson; if (!StringUtils.equals(rec.getString("firma"), partnerPerson.getTradeName()) || partnerPerson.getPersonType() != determinePersonType(rec) || !StringUtils.equals(rec.getString("title"), partnerPerson.getTitle()) || !StringUtils.equals(rec.getString("salut"), partnerPerson.getSalutation()) || !StringUtils.equals(rec.getString("first_name"), partnerPerson.getGivenName()) || !StringUtils.equals(rec.getString("last_name"), partnerPerson.getFamilyName())) { - contactPerson = addPerson(HsOfficePersonEntity.builder().build(), rec); + contactPerson = addPerson(HsOfficePersonRealEntity.builder().build(), rec); } final var contact = HsOfficeContactRealEntity.builder().build(); @@ -1084,8 +1084,8 @@ public abstract class BaseOfficeDataImport extends CsvDataImport { private static HsOfficeRelationRealEntity addRelation( final HsOfficeRelationType type, - final HsOfficePersonEntity anchor, - final HsOfficePersonEntity holder, + final HsOfficePersonRealEntity anchor, + final HsOfficePersonRealEntity holder, final HsOfficeContactRealEntity contact) { final var rel = HsOfficeRelationRealEntity.builder() .anchor(anchor) @@ -1097,7 +1097,7 @@ public abstract class BaseOfficeDataImport extends CsvDataImport { return rel; } - private HsOfficePersonEntity addPerson(final HsOfficePersonEntity person, final Record contactRecord) { + private HsOfficePersonRealEntity addPerson(final HsOfficePersonRealEntity person, final Record contactRecord) { person.setSalutation(contactRecord.getString("salut")); person.setTitle(contactRecord.getString("title")); person.setGivenName(contactRecord.getString("first_name")); 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 65cfa7f5..d0b56745 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 @@ -7,7 +7,7 @@ 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.person.HsOfficePersonRepository; +import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealRepository; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealRepository; import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup; @@ -57,16 +57,16 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu HsOfficePartnerRepository partnerRepo; @Autowired - HsOfficeContactRealRepository contactrealRepo; + HsOfficeContactRealRepository contactRealRepo; @Autowired HsOfficeBankAccountRepository bankAccountRepo; @Autowired - HsOfficePersonRepository personRepo; + HsOfficePersonRealRepository personRealRepo; @Autowired - HsOfficeRelationRealRepository relrealRepo; + HsOfficeRelationRealRepository relationRealRepo; @Autowired JpaAttempt jpaAttempt; @@ -270,13 +270,13 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu context.define("superuser-alex@hostsharing.net"); final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("Third").get(0); - final var givenContact = contactrealRepo.findContactByOptionalCaptionLike("fourth").get(0); + final var givenContact = contactRealRepo.findContactByOptionalCaptionLike("fourth").get(0); final var givenBankAccount = bankAccountRepo.findByOptionalHolderLike("Fourth").get(0); - final var givenBillingPerson = personRepo.findPersonByOptionalNameLike("Fourth").get(0); + final var givenBillingPerson = personRealRepo.findPersonByOptionalNameLike("Fourth").get(0); final var givenDebitorRelUUid = jpaAttempt.transacted(() -> { context.define("superuser-alex@hostsharing.net"); - return relrealRepo.save(HsOfficeRelationRealEntity.builder() + return relationRealRepo.save(HsOfficeRelationRealEntity.builder() .type(DEBITOR) .anchor(givenPartner.getPartnerRel().getHolder()) .holder(givenBillingPerson) @@ -327,7 +327,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu context.define("superuser-alex@hostsharing.net"); final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("Third").get(0); - final var givenContact = contactrealRepo.findContactByOptionalCaptionLike("fourth").get(0); + final var givenContact = contactRealRepo.findContactByOptionalCaptionLike("fourth").get(0); final var location = RestAssured // @formatter:off .given() @@ -554,7 +554,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu context.define("superuser-alex@hostsharing.net"); final var givenDebitor = givenSomeTemporaryDebitor(); - final var givenContact = contactrealRepo.findContactByOptionalCaptionLike("fourth").get(0); + final var givenContact = contactRealRepo.findContactByOptionalCaptionLike("fourth").get(0); final var location = RestAssured // @formatter:off .given() @@ -724,7 +724,7 @@ class HsOfficeDebitorControllerAcceptanceTest extends ContextBasedTestWithCleanu return jpaAttempt.transacted(() -> { context.define("superuser-alex@hostsharing.net"); final var givenPartner = partnerRepo.findPartnerByOptionalNameLike("Fourth").get(0).load(); - final var givenContact = contactrealRepo.findContactByOptionalCaptionLike("fourth contact").get(0); + final var givenContact = contactRealRepo.findContactByOptionalCaptionLike("fourth contact").get(0); final var newDebitor = HsOfficeDebitorEntity.builder() .debitorNumberSuffix(nextDebitorSuffix()) .billable(true) 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 a1c5ea0e..57351efe 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 @@ -2,7 +2,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.person.HsOfficePersonEntity; +import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealEntity; import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity; import net.hostsharing.hsadminng.rbac.generator.RbacViewMermaidFlowchartGenerator; @@ -13,11 +13,11 @@ import static org.assertj.core.api.Assertions.assertThat; class HsOfficeDebitorEntityUnitTest { private final HsOfficeRelationRealEntity givenDebitorRel = HsOfficeRelationRealEntity.builder() - .anchor(HsOfficePersonEntity.builder() + .anchor(HsOfficePersonRealEntity.builder() .personType(HsOfficePersonType.LEGAL_PERSON) .tradeName("some partner trade name") .build()) - .holder(HsOfficePersonEntity.builder() + .holder(HsOfficePersonRealEntity.builder() .personType(HsOfficePersonType.LEGAL_PERSON) .tradeName("some billing trade name") .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 16cca312..781077cb 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 @@ -4,7 +4,7 @@ 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.person.HsOfficePersonRepository; +import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealRepository; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelation; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType; @@ -53,7 +53,7 @@ class HsOfficeDebitorRepositoryIntegrationTest extends ContextBasedTestWithClean HsOfficeContactRealRepository contactrealRepo; @Autowired - HsOfficePersonRepository personRepo; + HsOfficePersonRealRepository personRepo; @Autowired HsOfficeBankAccountRepository bankAccountRepo; diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/TestHsOfficeDebitor.java b/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/TestHsOfficeDebitor.java index a3df1026..cd6233dc 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/TestHsOfficeDebitor.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/debitor/TestHsOfficeDebitor.java @@ -1,7 +1,7 @@ package net.hostsharing.hsadminng.hs.office.debitor; import lombok.experimental.UtilityClass; -import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity; +import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealEntity; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity; import static net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealTestEntity.TEST_REAL_CONTACT; @@ -15,8 +15,8 @@ public class TestHsOfficeDebitor { public static final HsOfficeDebitorEntity TEST_DEBITOR = HsOfficeDebitorEntity.builder() .debitorNumberSuffix(DEFAULT_DEBITOR_SUFFIX) .debitorRel(HsOfficeRelationRealEntity.builder() - .holder(HsOfficePersonEntity.builder().build()) - .anchor(HsOfficePersonEntity.builder().build()) + .holder(HsOfficePersonRealEntity.builder().build()) + .anchor(HsOfficePersonRealEntity.builder().build()) .contact(TEST_REAL_CONTACT) .build()) .partner(TEST_PARTNER) 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 5f82a9d3..14be1371 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 @@ -5,8 +5,8 @@ import io.restassured.http.ContentType; import net.hostsharing.hsadminng.HsadminNgApplication; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealEntity; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealRepository; -import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity; -import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository; +import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRbacEntity; +import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealRepository; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelation; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealRepository; @@ -48,7 +48,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu HsOfficeRelationRealRepository relationRepo; @Autowired - HsOfficePersonRepository personRepo; + HsOfficePersonRealRepository personRepo; @Autowired HsOfficeContactRealRepository contactrealRepo; @@ -224,7 +224,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu // TODO.impl: we want this error message: // .body("message", is("ERROR: [400] Unable to find Person by uuid: " + GIVEN_NON_EXISTING_UUID)); // but ModelMapper creates this error message: - .body("message", is("ERROR: [400] Unable to find " + HsOfficePersonEntity.class.getName() + " with id " + GIVEN_NON_EXISTING_UUID)); + .body("message", is("ERROR: [400] Unable to find " + HsOfficePersonRbacEntity.class.getName() + " with id " + GIVEN_NON_EXISTING_UUID)); // @formatter:on } } 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 31e0786d..7757366f 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 @@ -2,7 +2,7 @@ package net.hostsharing.hsadminng.hs.office.partner; import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRbacEntity; -import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity; +import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRbacEntity; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealRepository; import net.hostsharing.hsadminng.mapper.StandardMapper; @@ -66,10 +66,10 @@ class HsOfficePartnerControllerRestTest { EntityManagerFactory emf; @Mock - HsOfficePersonEntity mandateMock; + HsOfficePersonRbacEntity mandateMock; @Mock - HsOfficePersonEntity personMock; + HsOfficePersonRbacEntity personMock; @Mock HsOfficeContactRbacEntity contactMock; @@ -84,8 +84,8 @@ class HsOfficePartnerControllerRestTest { when(emf.createEntityManager(any(SynchronizationType.class))).thenReturn(em); when(emf.createEntityManager(any(SynchronizationType.class), any(Map.class))).thenReturn(em); - lenient().when(em.getReference(HsOfficePersonEntity.class, GIVEN_MANDANTE_UUID)).thenReturn(mandateMock); - lenient().when(em.getReference(HsOfficePersonEntity.class, GIVEN_PERSON_UUID)).thenReturn(personMock); + lenient().when(em.getReference(HsOfficePersonRbacEntity.class, GIVEN_MANDANTE_UUID)).thenReturn(mandateMock); + lenient().when(em.getReference(HsOfficePersonRbacEntity.class, GIVEN_PERSON_UUID)).thenReturn(personMock); lenient().when(em.getReference(HsOfficeContactRbacEntity.class, GIVEN_CONTACT_UUID)).thenReturn(contactMock); lenient().when(em.getReference(any(), eq(GIVEN_INVALID_UUID))).thenThrow(EntityNotFoundException.class); } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerDetailsEntityPatcherUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerDetailsEntityPatcherUnitTest.java index 8a3c0084..71923e01 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerDetailsEntityPatcherUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerDetailsEntityPatcherUnitTest.java @@ -2,7 +2,7 @@ package net.hostsharing.hsadminng.hs.office.partner; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRbacEntity; import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartnerDetailsPatchResource; -import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity; +import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRbacEntity; import net.hostsharing.hsadminng.rbac.test.PatchUnitTestBase; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.TestInstance; @@ -45,8 +45,8 @@ class HsOfficePartnerDetailsEntityPatcherUnitTest extends PatchUnitTestBase< void initMocks() { lenient().when(em.getReference(eq(HsOfficeContactRbacEntity.class), any())).thenAnswer(invocation -> HsOfficeContactRbacEntity.builder().uuid(invocation.getArgument(1)).build()); - lenient().when(em.getReference(eq(HsOfficePersonEntity.class), any())).thenAnswer(invocation -> - HsOfficePersonEntity.builder().uuid(invocation.getArgument(1)).build()); + lenient().when(em.getReference(eq(HsOfficePersonRbacEntity.class), any())).thenAnswer(invocation -> + HsOfficePersonRbacEntity.builder().uuid(invocation.getArgument(1)).build()); } @Override 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 a2ed7ca5..102b54e5 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 @@ -2,7 +2,7 @@ package net.hostsharing.hsadminng.hs.office.partner; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealEntity; import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficePartnerPatchResource; -import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity; +import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealEntity; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity; import net.hostsharing.hsadminng.rbac.test.PatchUnitTestBase; import org.junit.jupiter.api.BeforeEach; @@ -33,7 +33,7 @@ class HsOfficePartnerEntityPatcherUnitTest extends PatchUnitTestBase< private static final UUID INITIAL_DETAILS_UUID = UUID.randomUUID(); private static final UUID PATCHED_PARTNER_ROLE_UUID = UUID.randomUUID(); - private final HsOfficePersonEntity givenInitialPerson = HsOfficePersonEntity.builder() + private final HsOfficePersonRealEntity givenInitialPerson = HsOfficePersonRealEntity.builder() .uuid(INITIAL_PERSON_UUID) .build(); private final HsOfficeContactRealEntity givenInitialContact = HsOfficeContactRealEntity.builder() 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 33c83df7..93ca0315 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 @@ -1,7 +1,7 @@ package net.hostsharing.hsadminng.hs.office.partner; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealEntity; -import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity; +import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealEntity; import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType; @@ -15,12 +15,12 @@ class HsOfficePartnerEntityUnitTest { private final HsOfficePartnerEntity givenPartner = HsOfficePartnerEntity.builder() .partnerNumber(12345) .partnerRel(HsOfficeRelationRealEntity.builder() - .anchor(HsOfficePersonEntity.builder() + .anchor(HsOfficePersonRealEntity.builder() .personType(HsOfficePersonType.LEGAL_PERSON) .tradeName("Hostsharing eG") .build()) .type(HsOfficeRelationType.PARTNER) - .holder(HsOfficePersonEntity.builder() + .holder(HsOfficePersonRealEntity.builder() .personType(HsOfficePersonType.LEGAL_PERSON) .tradeName("some trade name") .build()) 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 90c79490..79ff449d 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 @@ -2,7 +2,7 @@ package net.hostsharing.hsadminng.hs.office.partner; import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealRepository; -import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository; +import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealRepository; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealRepository; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType; @@ -45,7 +45,7 @@ class HsOfficePartnerRepositoryIntegrationTest extends ContextBasedTestWithClean HsOfficeRelationRealRepository relationRepo; @Autowired - HsOfficePersonRepository personRepo; + HsOfficePersonRealRepository personRepo; @Autowired HsOfficeContactRealRepository contactrealRepo; 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 1d3b8164..02358e28 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 @@ -1,7 +1,7 @@ package net.hostsharing.hsadminng.hs.office.partner; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealEntity; -import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity; +import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealEntity; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationType; @@ -16,12 +16,12 @@ public class TestHsOfficePartner { .partnerNumber(10001) .partnerRel( HsOfficeRelationRealEntity.builder() - .holder(HsOfficePersonEntity.builder() + .holder(HsOfficePersonRealEntity.builder() .personType(LEGAL_PERSON) .tradeName("Hostsharing eG") .build()) .type(HsOfficeRelationType.PARTNER) - .holder(HsOfficePersonEntity.builder() + .holder(HsOfficePersonRealEntity.builder() .personType(LEGAL_PERSON) .tradeName(tradeName) .build()) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonControllerAcceptanceTest.java index d0228ad2..15307e4e 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonControllerAcceptanceTest.java @@ -43,7 +43,7 @@ class HsOfficePersonControllerAcceptanceTest extends ContextBasedTestWithCleanup Context contextMock; @Autowired - HsOfficePersonRepository personRepo; + HsOfficePersonRealRepository personRepo; @Autowired JpaAttempt jpaAttempt; @@ -327,10 +327,10 @@ class HsOfficePersonControllerAcceptanceTest extends ContextBasedTestWithCleanup } } - private HsOfficePersonEntity givenSomeTemporaryPersonCreatedBy(final String creatingUser) { + private HsOfficePersonRealEntity givenSomeTemporaryPersonCreatedBy(final String creatingUser) { return jpaAttempt.transacted(() -> { context.define(creatingUser); - final var newPerson = HsOfficePersonEntity.builder() + final var newPerson = HsOfficePersonRealEntity.builder() .uuid(UUID.randomUUID()) .personType(HsOfficePersonType.LEGAL_PERSON) .tradeName("Temp " + Context.getCallerMethodNameFromStackFrame(2)) @@ -347,7 +347,7 @@ class HsOfficePersonControllerAcceptanceTest extends ContextBasedTestWithCleanup jpaAttempt.transacted(() -> { context.define("superuser-alex@hostsharing.net", null); em.createQuery(""" - DELETE FROM HsOfficePersonEntity p + DELETE FROM HsOfficePersonRealEntity p WHERE p.tradeName LIKE 'Temp %' OR p.givenName LIKE 'Temp %' """).executeUpdate(); }).assertSuccessful(); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonEntityPatcherUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonEntityPatcherUnitTest.java index 39dabaa7..c38e4153 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonEntityPatcherUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonEntityPatcherUnitTest.java @@ -13,14 +13,14 @@ import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; @TestInstance(PER_CLASS) class HsOfficePersonEntityPatcherUnitTest extends PatchUnitTestBase< HsOfficePersonPatchResource, - HsOfficePersonEntity + HsOfficePersonRbacEntity > { private static final UUID INITIAL_PERSON_UUID = UUID.randomUUID(); @Override - protected HsOfficePersonEntity newInitialEntity() { - final var entity = new HsOfficePersonEntity(); + protected HsOfficePersonRbacEntity newInitialEntity() { + final var entity = new HsOfficePersonRbacEntity(); entity.setUuid(INITIAL_PERSON_UUID); entity.setPersonType(HsOfficePersonType.LEGAL_PERSON); entity.setTradeName("initial trade name"); @@ -37,7 +37,7 @@ class HsOfficePersonEntityPatcherUnitTest extends PatchUnitTestBase< } @Override - protected HsOfficePersonEntityPatcher createPatcher(final HsOfficePersonEntity entity) { + protected HsOfficePersonEntityPatcher createPatcher(final HsOfficePersonRbacEntity entity) { return new HsOfficePersonEntityPatcher(entity); } @@ -48,34 +48,34 @@ class HsOfficePersonEntityPatcherUnitTest extends PatchUnitTestBase< "personType", HsOfficePersonPatchResource::setPersonType, HsOfficePersonTypeResource.INCORPORATED_FIRM, - HsOfficePersonEntity::setPersonType, + HsOfficePersonRbacEntity::setPersonType, HsOfficePersonType.INCORPORATED_FIRM) .notNullable(), new JsonNullableProperty<>( "tradeName", HsOfficePersonPatchResource::setTradeName, "patched trade name", - HsOfficePersonEntity::setTradeName), + HsOfficePersonRbacEntity::setTradeName), new JsonNullableProperty<>( "title", HsOfficePersonPatchResource::setTitle, "Dr. Patch.", - HsOfficePersonEntity::setTitle), + HsOfficePersonRbacEntity::setTitle), new JsonNullableProperty<>( "salutation", HsOfficePersonPatchResource::setSalutation, "Hallo Ini", - HsOfficePersonEntity::setSalutation), + HsOfficePersonRbacEntity::setSalutation), new JsonNullableProperty<>( "familyName", HsOfficePersonPatchResource::setFamilyName, "patched family name", - HsOfficePersonEntity::setFamilyName), + HsOfficePersonRbacEntity::setFamilyName), new JsonNullableProperty<>( "patched given name", HsOfficePersonPatchResource::setGivenName, "patched given name", - HsOfficePersonEntity::setGivenName) + HsOfficePersonRbacEntity::setGivenName) ); } } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonEntityUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonEntityUnitTest.java index 36c4b870..40b52ae1 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonEntityUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonEntityUnitTest.java @@ -11,7 +11,7 @@ class HsOfficePersonEntityUnitTest { @Test void getDisplayReturnsTradeNameIfAvailable() { - final var givenPersonEntity = HsOfficePersonEntity.builder() + final var givenPersonEntity = HsOfficePersonRbacEntity.builder() .personType(HsOfficePersonType.LEGAL_PERSON) .tradeName("some trade name") .build(); @@ -23,7 +23,7 @@ class HsOfficePersonEntityUnitTest { @Test void getDisplayReturnsFamilyAndGivenNameIfNoTradeNameAvailable() { - final var givenPersonEntity = HsOfficePersonEntity.builder() + final var givenPersonEntity = HsOfficePersonRbacEntity.builder() .personType(HsOfficePersonType.NATURAL_PERSON) .familyName("some family name") .givenName("some given name") @@ -36,7 +36,7 @@ class HsOfficePersonEntityUnitTest { @Test void toShortStringWithTradeNameReturnsTradeName() { - final var givenPersonEntity = HsOfficePersonEntity.builder() + final var givenPersonEntity = HsOfficePersonRbacEntity.builder() .personType(HsOfficePersonType.LEGAL_PERSON) .tradeName("some trade name") .familyName("some family name") @@ -50,7 +50,7 @@ class HsOfficePersonEntityUnitTest { @Test void toShortStringWithoutTradeNameReturnsFamilyAndGivenName() { - final var givenPersonEntity = HsOfficePersonEntity.builder() + final var givenPersonEntity = HsOfficePersonRbacEntity.builder() .personType(HsOfficePersonType.NATURAL_PERSON) .familyName("some family name") .givenName("some given name") @@ -63,7 +63,7 @@ class HsOfficePersonEntityUnitTest { @Test void toShortStringWithSalutationAndTitleReturnsSalutationAndTitle() { - final var givenPersonEntity = HsOfficePersonEntity.builder() + final var givenPersonEntity = HsOfficePersonRbacEntity.builder() .personType(HsOfficePersonType.NATURAL_PERSON) .salutation("Frau") .title("Dr.") @@ -78,7 +78,7 @@ class HsOfficePersonEntityUnitTest { @Test void toShortStringWithSalutationAndWithoutTitleReturnsSalutation() { - final var givenPersonEntity = HsOfficePersonEntity.builder() + final var givenPersonEntity = HsOfficePersonRbacEntity.builder() .personType(HsOfficePersonType.NATURAL_PERSON) .salutation("Frau") .familyName("some family name") @@ -92,7 +92,7 @@ class HsOfficePersonEntityUnitTest { @Test void toShortStringWithoutSalutationAndWithTitleReturnsTitle() { - final var givenPersonEntity = HsOfficePersonEntity.builder() + final var givenPersonEntity = HsOfficePersonRbacEntity.builder() .personType(HsOfficePersonType.NATURAL_PERSON) .title("Dr. Dr.") .familyName("some family name") @@ -106,7 +106,7 @@ class HsOfficePersonEntityUnitTest { @Test void toStringWithAllFieldsReturnsAllButUuid() { - final var givenPersonEntity = HsOfficePersonEntity.builder() + final var givenPersonEntity = HsOfficePersonRbacEntity.builder() .uuid(UUID.randomUUID()) .personType(HsOfficePersonType.NATURAL_PERSON) .tradeName("some trade name") @@ -122,7 +122,7 @@ class HsOfficePersonEntityUnitTest { @Test void toStringSkipsNullFields() { - final var givenPersonEntity = HsOfficePersonEntity.builder() + final var givenPersonEntity = HsOfficePersonRbacEntity.builder() .familyName("some family name") .givenName("some given name") .build(); @@ -133,7 +133,7 @@ class HsOfficePersonEntityUnitTest { } @Test void toStringWithSalutationAndTitleRetursSalutationAndTitle() { - final var givenPersonEntity = HsOfficePersonEntity.builder() + final var givenPersonEntity = HsOfficePersonRbacEntity.builder() .salutation("Herr") .title("Prof. Dr.") .familyName("some family name") @@ -146,7 +146,7 @@ class HsOfficePersonEntityUnitTest { } @Test void toStringWithSalutationAndWithoutTitleSkipsTitle() { - final var givenPersonEntity = HsOfficePersonEntity.builder() + final var givenPersonEntity = HsOfficePersonRbacEntity.builder() .salutation("Herr") .familyName("some family name") .givenName("some given name") @@ -159,7 +159,7 @@ class HsOfficePersonEntityUnitTest { @Test void toStringWithoutSalutationAndWithTitleSkipsSalutation() { - final var givenPersonEntity = HsOfficePersonEntity.builder() + final var givenPersonEntity = HsOfficePersonRbacEntity.builder() .title("some title") .familyName("some family name") .givenName("some given name") @@ -172,7 +172,7 @@ class HsOfficePersonEntityUnitTest { @Test void definesRbac() { - final var rbacFlowchart = new RbacViewMermaidFlowchartGenerator(HsOfficePersonEntity.rbac()).toString(); + final var rbacFlowchart = new RbacViewMermaidFlowchartGenerator(HsOfficePersonRbacEntity.rbac()).toString(); assertThat(rbacFlowchart).isEqualTo(""" %%{init:{'flowchart':{'htmlLabels':false}}}%% flowchart TB diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRepositoryIntegrationTest.java index 595c732a..34b02379 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRepositoryIntegrationTest.java @@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat; class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanup { @Autowired - HsOfficePersonRepository personRepo; + HsOfficePersonRbacRepository personRepo; @Autowired RawRbacRoleRepository rawRoleRepo; @@ -64,7 +64,7 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu // then result.assertSuccessful(); - assertThat(result.returnedValue()).isNotNull().extracting(HsOfficePersonEntity::getUuid).isNotNull(); + assertThat(result.returnedValue()).isNotNull().extracting(HsOfficePersonRbacEntity::getUuid).isNotNull(); assertThatPersonIsPersisted(result.returnedValue()); assertThat(personRepo.count()).isEqualTo(count + 1); } @@ -81,7 +81,7 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu // then result.assertSuccessful(); - assertThat(result.returnedValue()).isNotNull().extracting(HsOfficePersonEntity::getUuid).isNotNull(); + assertThat(result.returnedValue()).isNotNull().extracting(HsOfficePersonRbacEntity::getUuid).isNotNull(); assertThatPersonIsPersisted(result.returnedValue()); assertThat(personRepo.count()).isEqualTo(count + 1); } @@ -122,7 +122,7 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu )); } - private void assertThatPersonIsPersisted(final HsOfficePersonEntity saved) { + private void assertThatPersonIsPersisted(final HsOfficePersonRbacEntity saved) { final var found = personRepo.findByUuid(saved.getUuid()); assertThat(found).isNotEmpty().get().extracting(Object::toString).isEqualTo(saved.toString()); } @@ -276,27 +276,27 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu "[creating person test-data, hs_office.person, INSERT, Third OHG, null]"); } - private HsOfficePersonEntity givenSomeTemporaryPerson( + private HsOfficePersonRbacEntity givenSomeTemporaryPerson( final String createdByUser, - Supplier entitySupplier) { + Supplier entitySupplier) { return jpaAttempt.transacted(() -> { context(createdByUser); return toCleanup(personRepo.save(entitySupplier.get())); }).assumeSuccessful().returnedValue(); } - private HsOfficePersonEntity givenSomeTemporaryPerson(final String createdByUser) { + private HsOfficePersonRbacEntity givenSomeTemporaryPerson(final String createdByUser) { return givenSomeTemporaryPerson(createdByUser, () -> hsOfficePerson("some temporary person #" + RandomStringUtils.random(12))); } - void exactlyThesePersonsAreReturned(final List actualResult, final String... personCaptions) { + void exactlyThesePersonsAreReturned(final List actualResult, final String... personCaptions) { assertThat(actualResult) - .extracting(HsOfficePersonEntity::getTradeName) + .extracting(HsOfficePersonRbacEntity::getTradeName) .containsExactlyInAnyOrder(personCaptions); } - void allThesePersonsAreReturned(final List actualResult, final String... personCaptions) { + void allThesePersonsAreReturned(final List actualResult, final String... personCaptions) { assertThat(actualResult) .extracting(hsOfficePersonEntity -> hsOfficePersonEntity.toShortString()) .contains(personCaptions); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/person/TestHsOfficePerson.java b/src/test/java/net/hostsharing/hsadminng/hs/office/person/TestHsOfficePerson.java index f8e8bafe..b0612ba0 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/person/TestHsOfficePerson.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/person/TestHsOfficePerson.java @@ -3,10 +3,10 @@ package net.hostsharing.hsadminng.hs.office.person; public class TestHsOfficePerson { - public static final HsOfficePersonEntity somePerson = hsOfficePerson("some person"); + public static final HsOfficePersonRbacEntity somePerson = hsOfficePerson("some person"); - static public HsOfficePersonEntity hsOfficePerson(final String tradeName) { - return HsOfficePersonEntity.builder() + static public HsOfficePersonRbacEntity hsOfficePerson(final String tradeName) { + return HsOfficePersonRbacEntity.builder() .personType(HsOfficePersonType.NATURAL_PERSON) .tradeName(tradeName) .build(); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRealRelationRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRealRelationRepositoryIntegrationTest.java index 5c912263..0b51abf9 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRealRelationRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRealRelationRepositoryIntegrationTest.java @@ -1,7 +1,7 @@ package net.hostsharing.hsadminng.hs.office.relation; import net.hostsharing.hsadminng.context.Context; -import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository; +import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRbacRepository; import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType; import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup; import net.hostsharing.hsadminng.rbac.test.JpaAttempt; @@ -30,7 +30,7 @@ class HsOfficeRealRelationRepositoryIntegrationTest extends ContextBasedTestWith HsOfficeRelationRealRepository relationRealRepo; @Autowired - HsOfficePersonRepository personRepo; + HsOfficePersonRbacRepository personRepo; @PersistenceContext EntityManager em; diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationControllerAcceptanceTest.java index 02a228f5..53e1f591 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationControllerAcceptanceTest.java @@ -3,11 +3,11 @@ package net.hostsharing.hsadminng.hs.office.relation; import io.restassured.RestAssured; import io.restassured.http.ContentType; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealRepository; +import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealRepository; import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup; import net.hostsharing.hsadminng.HsadminNgApplication; import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeRelationTypeResource; -import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository; import net.hostsharing.hsadminng.rbac.test.JpaAttempt; import net.hostsharing.hsadminng.test.DisableSecurityConfig; import org.junit.jupiter.api.Nested; @@ -45,7 +45,7 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean HsOfficeRelationRealRepository relationrealRepo; @Autowired - HsOfficePersonRepository personRepo; + HsOfficePersonRealRepository personRepo; @Autowired HsOfficeContactRealRepository contactrealRepo; diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationPatcherUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationPatcherUnitTest.java index 2fc9b95e..343fcd90 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationPatcherUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationPatcherUnitTest.java @@ -2,7 +2,7 @@ package net.hostsharing.hsadminng.hs.office.relation; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealEntity; import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeRelationPatchResource; -import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity; +import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealEntity; import net.hostsharing.hsadminng.rbac.test.PatchUnitTestBase; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.TestInstance; @@ -38,10 +38,10 @@ class HsOfficeRelationPatcherUnitTest extends PatchUnitTestBase< HsOfficeContactRealEntity.builder().uuid(invocation.getArgument(1)).build()); } - final HsOfficePersonEntity givenInitialAnchorPerson = HsOfficePersonEntity.builder() + final HsOfficePersonRealEntity givenInitialAnchorPerson = HsOfficePersonRealEntity.builder() .uuid(UUID.randomUUID()) .build(); - final HsOfficePersonEntity givenInitialHolderPerson = HsOfficePersonEntity.builder() + final HsOfficePersonRealEntity givenInitialHolderPerson = HsOfficePersonRealEntity.builder() .uuid(UUID.randomUUID()) .build(); final HsOfficeContactRealEntity givenInitialContact = HsOfficeContactRealEntity.builder() diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRepositoryIntegrationTest.java index 2bf26ee0..b2f50977 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationRepositoryIntegrationTest.java @@ -2,7 +2,7 @@ package net.hostsharing.hsadminng.hs.office.relation; import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealRepository; -import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository; +import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealRepository; 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 HsOfficeRelationRepositoryIntegrationTest extends ContextBasedTestWithClea HsOfficeRelationRbacRepository relationRbacRepo; @Autowired - HsOfficePersonRepository personRepo; + HsOfficePersonRealRepository personRepo; @Autowired HsOfficeContactRealRepository contactrealRepo; diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationUnitTest.java index 96ebc37c..5ae594b0 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationUnitTest.java @@ -1,6 +1,6 @@ package net.hostsharing.hsadminng.hs.office.relation; -import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity; +import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealEntity; import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonType; import net.hostsharing.hsadminng.rbac.generator.RbacViewMermaidFlowchartGenerator; import org.junit.jupiter.api.Test; @@ -9,11 +9,11 @@ import static org.assertj.core.api.Assertions.assertThat; class HsOfficeRelationUnitTest { - private HsOfficePersonEntity anchor = HsOfficePersonEntity.builder() + private HsOfficePersonRealEntity anchor = HsOfficePersonRealEntity.builder() .personType(HsOfficePersonType.LEGAL_PERSON) .tradeName("some trade name") .build(); - private HsOfficePersonEntity holder = HsOfficePersonEntity.builder() + private HsOfficePersonRealEntity holder = HsOfficePersonRealEntity.builder() .personType(HsOfficePersonType.NATURAL_PERSON) .familyName("Meier") .givenName("Mellie") diff --git a/src/test/java/net/hostsharing/hsadminng/hs/scenarios/ScenarioTest.java b/src/test/java/net/hostsharing/hsadminng/hs/scenarios/ScenarioTest.java index d1da4bb1..75ea20e7 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/scenarios/ScenarioTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/scenarios/ScenarioTest.java @@ -1,8 +1,8 @@ package net.hostsharing.hsadminng.hs.scenarios; import lombok.SneakyThrows; -import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity; -import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRepository; +import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRbacEntity; +import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRbacRepository; import net.hostsharing.hsadminng.lambda.Reducer; import net.hostsharing.hsadminng.rbac.context.ContextBasedTest; import net.hostsharing.hsadminng.rbac.test.JpaAttempt; @@ -68,7 +68,7 @@ public abstract class ScenarioTest extends ContextBasedTest { Integer port; @Autowired - HsOfficePersonRepository personRepo; + HsOfficePersonRbacRepository personRepo; @Autowired JpaAttempt jpaAttempt; @@ -117,7 +117,7 @@ public abstract class ScenarioTest extends ContextBasedTest { null, personRepo.findPersonByOptionalNameLike("Hostsharing eG") .stream() - .map(HsOfficePersonEntity::getUuid) + .map(HsOfficePersonRbacEntity::getUuid) .reduce(Reducer::toSingleElement).orElseThrow()) ); } -- 2.39.5 From afca44946602f53b9d343da21982b35f2463dc12 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 4 Dec 2024 15:57:27 +0100 Subject: [PATCH 10/13] addd missing HsOfficePerson to git --- .../hs/office/person/HsOfficePerson.java | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePerson.java diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePerson.java b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePerson.java new file mode 100644 index 00000000..8842dac2 --- /dev/null +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePerson.java @@ -0,0 +1,79 @@ +package net.hostsharing.hsadminng.hs.office.person; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.FieldNameConstants; +import lombok.experimental.SuperBuilder; +import net.hostsharing.hsadminng.errors.DisplayAs; +import net.hostsharing.hsadminng.persistence.BaseEntity; +import net.hostsharing.hsadminng.repr.Stringify; +import net.hostsharing.hsadminng.repr.Stringifyable; +import org.apache.commons.lang3.StringUtils; + +import jakarta.persistence.Column; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.MappedSuperclass; +import jakarta.persistence.Version; +import java.util.UUID; + +import static net.hostsharing.hsadminng.repr.Stringify.stringify; + +@MappedSuperclass +@Getter +@Setter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor(access = AccessLevel.PROTECTED) +@SuperBuilder(toBuilder = true) +@FieldNameConstants +@DisplayAs("Person") +public class HsOfficePerson & BaseEntity> implements BaseEntity, Stringifyable { + + private static Stringify toString = stringify(HsOfficePerson.class, "person") + .withProp(Fields.personType, HsOfficePerson::getPersonType) + .withProp(Fields.tradeName, HsOfficePerson::getTradeName) + .withProp(Fields.salutation, HsOfficePerson::getSalutation) + .withProp(Fields.title, HsOfficePerson::getTitle) + .withProp(Fields.familyName, HsOfficePerson::getFamilyName) + .withProp(Fields.givenName, HsOfficePerson::getGivenName); + + @Id + @GeneratedValue + private UUID uuid; + + @Version + private int version; + + @Column(name = "persontype") + private HsOfficePersonType personType; + + @Column(name = "tradename") + private String tradeName; + + @Column(name = "salutation") + private String salutation; + + @Column(name = "title") + private String title; + + @Column(name = "familyname") + private String familyName; + + @Column(name = "givenname") + private String givenName; + + @Override + public String toString() { + return toString.apply(this); + } + + @Override + public String toShortString() { + return personType + " " + + (!StringUtils.isEmpty(tradeName) ? tradeName : (familyName + ", " + givenName)); + } + +} -- 2.39.5 From 5eb1fd4085f8514609ccb4e9f1484b3f0fc26fde Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 4 Dec 2024 16:48:42 +0100 Subject: [PATCH 11/13] add HsOfficePersonRealRepositoryIntegrationTest --- .../person/HsOfficePersonRealRepository.java | 5 +- ...ePersonRbacRepositoryIntegrationTest.java} | 50 ++--- ...java => HsOfficePersonRbacTestEntity.java} | 6 +- ...cePersonRealRepositoryIntegrationTest.java | 182 ++++++++++++++++++ .../person/HsOfficePersonRealTestEntity.java | 14 ++ 5 files changed, 225 insertions(+), 32 deletions(-) rename src/test/java/net/hostsharing/hsadminng/hs/office/person/{HsOfficePersonRepositoryIntegrationTest.java => HsOfficePersonRbacRepositoryIntegrationTest.java} (86%) rename src/test/java/net/hostsharing/hsadminng/hs/office/person/{TestHsOfficePerson.java => HsOfficePersonRbacTestEntity.java} (63%) create mode 100644 src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRealRepositoryIntegrationTest.java create mode 100644 src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRealTestEntity.java diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRealRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRealRepository.java index 5041b702..668661ad 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRealRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRealRepository.java @@ -14,7 +14,7 @@ public interface HsOfficePersonRealRepository extends Repository findByUuid(UUID personUuid); @Query(""" - SELECT p FROM HsOfficePersonRbacEntity p + SELECT p FROM HsOfficePersonRealEntity p WHERE :name is null OR p.tradeName like concat(cast(:name as text), '%') OR p.givenName like concat(cast(:name as text), '%') @@ -26,9 +26,6 @@ public interface HsOfficePersonRealRepository extends Repository toCleanup(personRepo.save( - hsOfficePerson("a new person")))); + final var result = attempt(em, () -> toCleanup(personRbacRepo.save( + hsOfficePersonRbacEntity("a new person")))); // then result.assertSuccessful(); assertThat(result.returnedValue()).isNotNull().extracting(HsOfficePersonRbacEntity::getUuid).isNotNull(); assertThatPersonIsPersisted(result.returnedValue()); - assertThat(personRepo.count()).isEqualTo(count + 1); + assertThat(personRbacRepo.count()).isEqualTo(count + 1); } @Test public void arbitraryUser_canCreateNewPerson() { // given context("selfregistered-user-drew@hostsharing.org"); - final var count = personRepo.count(); + final var count = personRbacRepo.count(); // when - final var result = attempt(em, () -> toCleanup(personRepo.save( - hsOfficePerson("another new person")))); + final var result = attempt(em, () -> toCleanup(personRbacRepo.save( + hsOfficePersonRbacEntity("another new person")))); // then result.assertSuccessful(); assertThat(result.returnedValue()).isNotNull().extracting(HsOfficePersonRbacEntity::getUuid).isNotNull(); assertThatPersonIsPersisted(result.returnedValue()); - assertThat(personRepo.count()).isEqualTo(count + 1); + assertThat(personRbacRepo.count()).isEqualTo(count + 1); } @Test @@ -95,7 +95,7 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu // when attempt(em, () -> toCleanup( - personRepo.save(hsOfficePerson("another new person")) + personRbacRepo.save(hsOfficePersonRbacEntity("another new person")) )).assumeSuccessful(); // then @@ -123,7 +123,7 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu } private void assertThatPersonIsPersisted(final HsOfficePersonRbacEntity saved) { - final var found = personRepo.findByUuid(saved.getUuid()); + final var found = personRbacRepo.findByUuid(saved.getUuid()); assertThat(found).isNotEmpty().get().extracting(Object::toString).isEqualTo(saved.toString()); } } @@ -137,7 +137,7 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu context("superuser-alex@hostsharing.net"); // when - final var result = personRepo.findPersonByOptionalNameLike(null); + final var result = personRbacRepo.findPersonByOptionalNameLike(null); // then allThesePersonsAreReturned( @@ -155,7 +155,7 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu // when: context("pac-admin-zzz00@zzz.example.com"); - final var result = personRepo.findPersonByOptionalNameLike(null); + final var result = personRbacRepo.findPersonByOptionalNameLike(null); // then: exactlyThesePersonsAreReturned(result, givenPerson.getTradeName()); @@ -171,7 +171,7 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu context("superuser-alex@hostsharing.net", null); // when - final var result = personRepo.findPersonByOptionalNameLike("Second"); + final var result = personRbacRepo.findPersonByOptionalNameLike("Second"); // then exactlyThesePersonsAreReturned(result, "Second e.K."); @@ -184,7 +184,7 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu // when: context("selfregistered-user-drew@hostsharing.org"); - final var result = personRepo.findPersonByOptionalNameLike(givenPerson.getTradeName()); + final var result = personRbacRepo.findPersonByOptionalNameLike(givenPerson.getTradeName()); // then: exactlyThesePersonsAreReturned(result, givenPerson.getTradeName()); @@ -202,14 +202,14 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu // when final var result = jpaAttempt.transacted(() -> { context("superuser-alex@hostsharing.net", null); - personRepo.deleteByUuid(givenPerson.getUuid()); + personRbacRepo.deleteByUuid(givenPerson.getUuid()); }); // then result.assertSuccessful(); assertThat(jpaAttempt.transacted(() -> { context("superuser-alex@hostsharing.net", null); - return personRepo.findPersonByOptionalNameLike(givenPerson.getTradeName()); + return personRbacRepo.findPersonByOptionalNameLike(givenPerson.getTradeName()); }).assertSuccessful().returnedValue()).hasSize(0); } @@ -221,14 +221,14 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu // when final var result = jpaAttempt.transacted(() -> { context("selfregistered-user-drew@hostsharing.org", null); - personRepo.deleteByUuid(givenPerson.getUuid()); + personRbacRepo.deleteByUuid(givenPerson.getUuid()); }); // then result.assertSuccessful(); assertThat(jpaAttempt.transacted(() -> { context("superuser-alex@hostsharing.net", null); - return personRepo.findPersonByOptionalNameLike(givenPerson.getTradeName()); + return personRbacRepo.findPersonByOptionalNameLike(givenPerson.getTradeName()); }).assertSuccessful().returnedValue()).hasSize(0); } @@ -245,7 +245,7 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu // when final var result = jpaAttempt.transacted(() -> { context("selfregistered-user-drew@hostsharing.org", null); - return personRepo.deleteByUuid(givenPerson.getUuid()); + return personRbacRepo.deleteByUuid(givenPerson.getUuid()); }); // then @@ -281,13 +281,13 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu Supplier entitySupplier) { return jpaAttempt.transacted(() -> { context(createdByUser); - return toCleanup(personRepo.save(entitySupplier.get())); + return toCleanup(personRbacRepo.save(entitySupplier.get())); }).assumeSuccessful().returnedValue(); } private HsOfficePersonRbacEntity givenSomeTemporaryPerson(final String createdByUser) { return givenSomeTemporaryPerson(createdByUser, () -> - hsOfficePerson("some temporary person #" + RandomStringUtils.random(12))); + hsOfficePersonRbacEntity("some temporary person #" + RandomStringUtils.random(12))); } void exactlyThesePersonsAreReturned(final List actualResult, final String... personCaptions) { @@ -298,7 +298,7 @@ class HsOfficePersonRepositoryIntegrationTest extends ContextBasedTestWithCleanu void allThesePersonsAreReturned(final List actualResult, final String... personCaptions) { assertThat(actualResult) - .extracting(hsOfficePersonEntity -> hsOfficePersonEntity.toShortString()) + .extracting(HsOfficePerson::toShortString) .contains(personCaptions); } } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/person/TestHsOfficePerson.java b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRbacTestEntity.java similarity index 63% rename from src/test/java/net/hostsharing/hsadminng/hs/office/person/TestHsOfficePerson.java rename to src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRbacTestEntity.java index b0612ba0..7a6d6261 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/person/TestHsOfficePerson.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRbacTestEntity.java @@ -1,11 +1,11 @@ package net.hostsharing.hsadminng.hs.office.person; -public class TestHsOfficePerson { +public class HsOfficePersonRbacTestEntity { - public static final HsOfficePersonRbacEntity somePerson = hsOfficePerson("some person"); + public static final HsOfficePersonRbacEntity somePerson = hsOfficePersonRbacEntity("some person"); - static public HsOfficePersonRbacEntity hsOfficePerson(final String tradeName) { + public static HsOfficePersonRbacEntity hsOfficePersonRbacEntity(final String tradeName) { return HsOfficePersonRbacEntity.builder() .personType(HsOfficePersonType.NATURAL_PERSON) .tradeName(tradeName) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRealRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRealRepositoryIntegrationTest.java new file mode 100644 index 00000000..91897601 --- /dev/null +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRealRepositoryIntegrationTest.java @@ -0,0 +1,182 @@ +package net.hostsharing.hsadminng.hs.office.person; + +import net.hostsharing.hsadminng.context.Context; +import net.hostsharing.hsadminng.mapper.Array; +import net.hostsharing.hsadminng.rbac.grant.RawRbacGrantRepository; +import net.hostsharing.hsadminng.rbac.role.RawRbacRoleRepository; +import net.hostsharing.hsadminng.rbac.test.ContextBasedTestWithCleanup; +import net.hostsharing.hsadminng.rbac.test.JpaAttempt; +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.Import; + +import jakarta.persistence.EntityManager; +import jakarta.persistence.PersistenceContext; +import jakarta.servlet.http.HttpServletRequest; +import java.util.Arrays; +import java.util.List; + +import static net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealTestEntity.hsOfficePersonRealEntity; +import static net.hostsharing.hsadminng.rbac.grant.RawRbacGrantEntity.distinctGrantDisplaysOf; +import static net.hostsharing.hsadminng.rbac.role.RawRbacRoleEntity.distinctRoleNamesOf; +import static net.hostsharing.hsadminng.rbac.test.JpaAttempt.attempt; +import static org.assertj.core.api.Assertions.assertThat; + +@DataJpaTest +@Import( { Context.class, JpaAttempt.class }) +class HsOfficePersonRealRepositoryIntegrationTest extends ContextBasedTestWithCleanup { + + @Autowired + HsOfficePersonRealRepository personRealRepo; + + @Autowired + RawRbacRoleRepository rawRoleRepo; + + @Autowired + RawRbacGrantRepository rawGrantRepo; + + @PersistenceContext + EntityManager em; + + @Autowired + JpaAttempt jpaAttempt; + + @MockBean + HttpServletRequest request; + @Autowired + private HsOfficePersonRealRepository hsOfficePersonRealRepository; + + @Nested + class CreatePerson { + + @Test + public void arbitraryUser_canCreateNewPerson() { + // given + context("selfregistered-user-drew@hostsharing.org"); + final var count = personRealRepo.count(); + + // when + final var result = attempt(em, () -> toCleanup(personRealRepo.save( + hsOfficePersonRealEntity("another new person")))); + + // then + result.assertSuccessful(); + assertThat(result.returnedValue()).isNotNull().extracting(HsOfficePersonRealEntity::getUuid).isNotNull(); + assertThatPersonIsPersisted(result.returnedValue()); + assertThat(personRealRepo.count()).isEqualTo(count + 1); + } + + @Test + public void createsAndGrantsRoles() { + // given + context("selfregistered-user-drew@hostsharing.org"); + final var initialRoleNames = distinctRoleNamesOf(rawRoleRepo.findAll()); + final var initialGrantNames = distinctGrantDisplaysOf(rawGrantRepo.findAll()); + + // when + attempt(em, () -> toCleanup( + personRealRepo.save(hsOfficePersonRealEntity("another new person")) + )).assumeSuccessful(); + + // then + assertThat(distinctRoleNamesOf(rawRoleRepo.findAll())).containsExactlyInAnyOrder( + Array.from( + initialRoleNames, + "hs_office.person#anothernewperson:OWNER", + "hs_office.person#anothernewperson:ADMIN", + "hs_office.person#anothernewperson:REFERRER" + )); + assertThat(distinctGrantDisplaysOf(rawGrantRepo.findAll())).containsExactlyInAnyOrder( + Array.fromFormatted( + initialGrantNames, + "{ grant perm:hs_office.person#anothernewperson:INSERT>hs_office.relation to role:hs_office.person#anothernewperson:ADMIN by system and assume }", + + "{ grant role:hs_office.person#anothernewperson:OWNER to user:selfregistered-user-drew@hostsharing.org by hs_office.person#anothernewperson:OWNER and assume }", + "{ grant role:hs_office.person#anothernewperson:OWNER to role:rbac.global#global:ADMIN by system and assume }", + "{ grant perm:hs_office.person#anothernewperson:UPDATE to role:hs_office.person#anothernewperson:ADMIN by system and assume }", + "{ grant perm:hs_office.person#anothernewperson:DELETE to role:hs_office.person#anothernewperson:OWNER by system and assume }", + "{ grant role:hs_office.person#anothernewperson:ADMIN to role:hs_office.person#anothernewperson:OWNER by system and assume }", + + "{ grant perm:hs_office.person#anothernewperson:SELECT to role:hs_office.person#anothernewperson:REFERRER by system and assume }", + "{ grant role:hs_office.person#anothernewperson:REFERRER to role:hs_office.person#anothernewperson:ADMIN by system and assume }" + )); + } + + private void assertThatPersonIsPersisted(final HsOfficePersonRealEntity saved) { + final var found = personRealRepo.findByUuid(saved.getUuid()); + assertThat(found).isNotEmpty().get().extracting(Object::toString).isEqualTo(saved.toString()); + } + } + + @Nested + class FindAllPersons { + + @Test + public void arbitraryUser_canViewAllPersons() { + // given + context("selfregistered-user-drew@hostsharing.org"); + + // when + final var result = personRealRepo.findPersonByOptionalNameLike(null); + + // then + allThesePersonsAreReturned( + result, + "NP Smith, Peter", + "LP Second e.K.", + "IF Third OHG", + "UF Erben Bessler"); + } + } + + @Nested + class FindByCaptionLike { + + @Test + public void arbitraryUser_canViewAllPersons() { + // given + context("selfregistered-user-drew@hostsharing.org"); + + // when + final var result = personRealRepo.findPersonByOptionalNameLike("Second"); + + // then + exactlyThesePersonsAreReturned(result, "Second e.K."); + } + } + + @Test + public void auditJournalLogIsAvailable() { + // given + final var query = em.createNativeQuery(""" + select currentTask, targetTable, targetOp, targetdelta->>'tradename', targetdelta->>'lastname' + from base.tx_journal_v + where targettable = 'hs_office.person'; + """); + + // when + @SuppressWarnings("unchecked") final List customerLogEntries = query.getResultList(); + + // then + assertThat(customerLogEntries).map(Arrays::toString).contains( + "[creating person test-data, hs_office.person, INSERT, Hostsharing eG, null]", + "[creating person test-data, hs_office.person, INSERT, First GmbH, null]", + "[creating person test-data, hs_office.person, INSERT, Second e.K., null]", + "[creating person test-data, hs_office.person, INSERT, Third OHG, null]"); + } + + void exactlyThesePersonsAreReturned(final List actualResult, final String... personCaptions) { + assertThat(actualResult) + .extracting(HsOfficePersonRealEntity::getTradeName) + .containsExactlyInAnyOrder(personCaptions); + } + + void allThesePersonsAreReturned(final List actualResult, final String... personCaptions) { + assertThat(actualResult) + .extracting(HsOfficePerson::toShortString) + .contains(personCaptions); + } +} diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRealTestEntity.java b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRealTestEntity.java new file mode 100644 index 00000000..3284d494 --- /dev/null +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRealTestEntity.java @@ -0,0 +1,14 @@ +package net.hostsharing.hsadminng.hs.office.person; + + +public class HsOfficePersonRealTestEntity { + + public static final HsOfficePersonRealEntity somePerson = hsOfficePersonRealEntity("some person"); + + public static HsOfficePersonRealEntity hsOfficePersonRealEntity(final String tradeName) { + return HsOfficePersonRealEntity.builder() + .personType(HsOfficePersonType.NATURAL_PERSON) + .tradeName(tradeName) + .build(); + } +} -- 2.39.5 From 6c82ec2bf133e8a38f193f5ee934a045664e9b5b Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 4 Dec 2024 17:16:30 +0100 Subject: [PATCH 12/13] fix related partner tests --- ...OfficePartnerControllerAcceptanceTest.java | 28 +++++++++---------- .../HsOfficePartnerControllerRestTest.java | 12 ++++---- 2 files changed, 20 insertions(+), 20 deletions(-) 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 14be1371..e5ea3cca 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 @@ -5,7 +5,7 @@ import io.restassured.http.ContentType; import net.hostsharing.hsadminng.HsadminNgApplication; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealEntity; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealRepository; -import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRbacEntity; +import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealEntity; 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,10 +48,10 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu HsOfficeRelationRealRepository relationRepo; @Autowired - HsOfficePersonRealRepository personRepo; + HsOfficePersonRealRepository personRealRepo; @Autowired - HsOfficeContactRealRepository contactrealRepo; + HsOfficeContactRealRepository contactRealRepo; @Autowired JpaAttempt jpaAttempt; @@ -93,9 +93,9 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu void globalAdmin_withoutAssumedRole_canPostNewPartner() { context.define("superuser-alex@hostsharing.net"); - final var givenMandantPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").stream().findFirst().orElseThrow(); - final var givenPerson = personRepo.findPersonByOptionalNameLike("Third").stream().findFirst().orElseThrow(); - final var givenContact = contactrealRepo.findContactByOptionalCaptionLike("fourth").stream().findFirst().orElseThrow(); + final var givenMandantPerson = personRealRepo.findPersonByOptionalNameLike("Hostsharing eG").stream().findFirst().orElseThrow(); + final var givenPerson = personRealRepo.findPersonByOptionalNameLike("Third").stream().findFirst().orElseThrow(); + final var givenContact = contactRealRepo.findContactByOptionalCaptionLike("fourth").stream().findFirst().orElseThrow(); final var location = RestAssured // @formatter:off .given() @@ -153,8 +153,8 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu void globalAdmin_canNotPostNewPartner_ifContactDoesNotExist() { context.define("superuser-alex@hostsharing.net"); - final var givenMandantPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").get(0); - final var givenPerson = personRepo.findPersonByOptionalNameLike("Third").get(0); + final var givenMandantPerson = personRealRepo.findPersonByOptionalNameLike("Hostsharing eG").get(0); + final var givenPerson = personRealRepo.findPersonByOptionalNameLike("Third").get(0); final var location = RestAssured // @formatter:off .given() @@ -191,8 +191,8 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu void globalAdmin_canNotPostNewPartner_ifPersonDoesNotExist() { context.define("superuser-alex@hostsharing.net"); - final var mandantPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").get(0); - final var givenContact = contactrealRepo.findContactByOptionalCaptionLike("fourth").get(0); + final var mandantPerson = personRealRepo.findPersonByOptionalNameLike("Hostsharing eG").get(0); + final var givenContact = contactRealRepo.findContactByOptionalCaptionLike("fourth").get(0); final var location = RestAssured // @formatter:off .given() @@ -224,7 +224,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu // TODO.impl: we want this error message: // .body("message", is("ERROR: [400] Unable to find Person by uuid: " + GIVEN_NON_EXISTING_UUID)); // but ModelMapper creates this error message: - .body("message", is("ERROR: [400] Unable to find " + HsOfficePersonRbacEntity.class.getName() + " with id " + GIVEN_NON_EXISTING_UUID)); + .body("message", is("ERROR: [400] Unable to find " + HsOfficePersonRealEntity.class.getName() + " with id " + GIVEN_NON_EXISTING_UUID)); // @formatter:on } } @@ -528,9 +528,9 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu final String contactName) { return jpaAttempt.transacted(() -> { context.define("superuser-alex@hostsharing.net"); - final var givenMandantPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").stream().findFirst().orElseThrow(); - final var givenPerson = personRepo.findPersonByOptionalNameLike(partnerHolderName).stream().findFirst().orElseThrow(); - final var givenContact = contactrealRepo.findContactByOptionalCaptionLike(contactName).stream().findFirst().orElseThrow(); + final var givenMandantPerson = personRealRepo.findPersonByOptionalNameLike("Hostsharing eG").stream().findFirst().orElseThrow(); + final var givenPerson = personRealRepo.findPersonByOptionalNameLike(partnerHolderName).stream().findFirst().orElseThrow(); + final var givenContact = contactRealRepo.findContactByOptionalCaptionLike(contactName).stream().findFirst().orElseThrow(); final var partnerRel = new HsOfficeRelationRealEntity(); partnerRel.setType(HsOfficeRelationType.PARTNER); 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 7757366f..dbc6081b 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 @@ -2,7 +2,7 @@ package net.hostsharing.hsadminng.hs.office.partner; import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRbacEntity; -import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRbacEntity; +import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonRealEntity; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealEntity; import net.hostsharing.hsadminng.hs.office.relation.HsOfficeRelationRealRepository; import net.hostsharing.hsadminng.mapper.StandardMapper; @@ -66,10 +66,10 @@ class HsOfficePartnerControllerRestTest { EntityManagerFactory emf; @Mock - HsOfficePersonRbacEntity mandateMock; + HsOfficePersonRealEntity mandateMock; @Mock - HsOfficePersonRbacEntity personMock; + HsOfficePersonRealEntity personMock; @Mock HsOfficeContactRbacEntity contactMock; @@ -84,8 +84,8 @@ class HsOfficePartnerControllerRestTest { when(emf.createEntityManager(any(SynchronizationType.class))).thenReturn(em); when(emf.createEntityManager(any(SynchronizationType.class), any(Map.class))).thenReturn(em); - lenient().when(em.getReference(HsOfficePersonRbacEntity.class, GIVEN_MANDANTE_UUID)).thenReturn(mandateMock); - lenient().when(em.getReference(HsOfficePersonRbacEntity.class, GIVEN_PERSON_UUID)).thenReturn(personMock); + lenient().when(em.getReference(HsOfficePersonRealEntity.class, GIVEN_MANDANTE_UUID)).thenReturn(mandateMock); + lenient().when(em.getReference(HsOfficePersonRealEntity.class, GIVEN_PERSON_UUID)).thenReturn(personMock); lenient().when(em.getReference(HsOfficeContactRbacEntity.class, GIVEN_CONTACT_UUID)).thenReturn(contactMock); lenient().when(em.getReference(any(), eq(GIVEN_INVALID_UUID))).thenThrow(EntityNotFoundException.class); } @@ -127,7 +127,7 @@ class HsOfficePartnerControllerRestTest { .andExpect(status().is4xxClientError()) .andExpect(jsonPath("statusCode", is(400))) .andExpect(jsonPath("statusPhrase", is("Bad Request"))) - .andExpect(jsonPath("message", startsWith("ERROR: [400] Cannot resolve HsOfficePersonEntity with uuid "))); + .andExpect(jsonPath("message", startsWith("ERROR: [400] Cannot resolve HsOfficePersonRealEntity with uuid "))); } @Test -- 2.39.5 From a7748d4ee895038b838d1933edf78decf227f86b Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Thu, 5 Dec 2024 09:42:32 +0100 Subject: [PATCH 13/13] fix @Timed names in HsOfficePersonRealRepository --- .../hs/office/person/HsOfficePersonRealRepository.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRealRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRealRepository.java index 668661ad..0204f8ea 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRealRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/person/HsOfficePersonRealRepository.java @@ -10,7 +10,7 @@ import java.util.UUID; public interface HsOfficePersonRealRepository extends Repository { - @Timed("app.office.persons.repo.findByUuid.rbac") + @Timed("app.office.persons.repo.findByUuid.real") Optional findByUuid(UUID personUuid); @Query(""" @@ -20,12 +20,12 @@ public interface HsOfficePersonRealRepository extends Repository findPersonByOptionalNameLike(String name); - @Timed("app.office.persons.repo.save.rbac") + @Timed("app.office.persons.repo.save.real") HsOfficePersonRealEntity save(final HsOfficePersonRealEntity entity); - @Timed("app.office.persons.repo.count.rbac") + @Timed("app.office.persons.repo.count.real") long count(); } -- 2.39.5