From 0832c90c82861300075dda1dc14066747119bc55 Mon Sep 17 00:00:00 2001 From: Timotheus Pokorra Date: Thu, 5 Dec 2024 10:22:42 +0100 Subject: [PATCH 1/2] TP-20241126-znuny-view-customer_company (#129) Co-authored-by: Dev und Test fuer hsadminng Reviewed-on: https://dev.hostsharing.net/hostsharing/hs.hsadmin.ng/pulls/129 Reviewed-by: Michael Hoennig --- .../9-hs-global/9120-integration-znuny.sql | 36 +++++++++++++++---- .../hs/migration/BaseOfficeDataImport.java | 9 ++--- 2 files changed, 34 insertions(+), 11 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 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..a6c64600 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/migration/BaseOfficeDataImport.java @@ -884,15 +884,15 @@ public abstract class BaseOfficeDataImport extends CsvDataImport { 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 && @@ -905,10 +905,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)) From ddba946d72239c91927520f7a02c531dd5aa1955 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Thu, 5 Dec 2024 10:32:34 +0100 Subject: [PATCH 2/2] add micrometer @Timing annotations to Controllers+Repositories + ArchTest (#128) Co-authored-by: Michael Hoennig Reviewed-on: https://dev.hostsharing.net/hostsharing/hs.hsadmin.ng/pulls/128 Reviewed-by: Timotheus Pokorra --- .../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 +++ .../HsOfficeBankAccountController.java | 11 ++-- .../HsOfficeBankAccountRepository.java | 11 +++- .../contact/HsOfficeContactController.java | 12 +++-- .../HsOfficeContactRbacRepository.java | 8 ++- .../HsOfficeContactRealRepository.java | 8 ++- ...OfficeCoopAssetsTransactionController.java | 4 ++ ...OfficeCoopAssetsTransactionRepository.java | 7 ++- ...OfficeCoopSharesTransactionController.java | 6 +++ ...OfficeCoopSharesTransactionRepository.java | 7 ++- .../debitor/HsOfficeDebitorController.java | 6 +++ .../debitor/HsOfficeDebitorRepository.java | 11 +++- .../HsOfficeMembershipController.java | 6 +++ .../HsOfficeMembershipRepository.java | 8 +++ .../partner/HsOfficePartnerController.java | 12 +++-- .../partner/HsOfficePartnerRepository.java | 11 +++- .../person/HsOfficePersonController.java | 12 +++-- .../person/HsOfficePersonRepository.java | 8 ++- .../relation/HsOfficeRelationController.java | 13 +++-- .../HsOfficeRelationRbacRepository.java | 7 +++ .../HsOfficeRelationRealRepository.java | 7 +++ .../HsOfficeSepaMandateController.java | 12 +++-- .../HsOfficeSepaMandateRepository.java | 8 ++- .../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 +- .../hs-office-bankaccounts-with-uuid.yaml | 2 +- .../hs-office/hs-office-bankaccounts.yaml | 4 +- .../hs-office-contacts-with-uuid.yaml | 2 +- .../hs-office/hs-office-contacts.yaml | 4 +- .../hs-office-partners-with-uuid.yaml | 2 +- .../hs-office/hs-office-partners.yaml | 4 +- .../hs-office-persons-with-uuid.yaml | 2 +- .../hs-office/hs-office-persons.yaml | 4 +- .../hs-office-relations-with-uuid.yaml | 2 +- .../hs-office/hs-office-relations.yaml | 4 +- .../hs-office-sepamandates-with-uuid.yaml | 2 +- .../hs-office/hs-office-sepamandates.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 +- src/main/resources/application.yml | 12 ++++- .../hsadminng/arch/ArchitectureTest.java | 52 ++++++++++++++++++- ...HsBookingItemControllerAcceptanceTest.java | 6 +-- .../item/HsBookingItemControllerRestTest.java | 2 +- ...ookingProjectControllerAcceptanceTest.java | 4 +- ...sHostingAssetControllerAcceptanceTest.java | 6 +-- .../HsHostingAssetControllerRestTest.java | 4 +- ...ceBankAccountControllerAcceptanceTest.java | 4 +- ...eBankAccountRepositoryIntegrationTest.java | 2 +- ...OfficePartnerControllerAcceptanceTest.java | 10 ++-- .../HsOfficePartnerControllerRestTest.java | 2 +- ...sOfficePersonControllerAcceptanceTest.java | 2 +- ...fficeRelationControllerAcceptanceTest.java | 2 +- ...ceSepaMandateControllerAcceptanceTest.java | 10 ++-- .../RbacGrantControllerAcceptanceTest.java | 18 +++---- .../rbac/role/RawRbacObjectRepository.java | 2 + .../rbac/role/RawRbacRoleRepository.java | 2 + .../RbacSubjectControllerRestTest.java | 4 +- .../RbacSubjectRepositoryIntegrationTest.java | 4 +- 88 files changed, 461 insertions(+), 136 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..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 @@ -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.booking.debitor.repo.findByUuid") Optional findByUuid(UUID id); + @Timed("app.booking.debitor.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/HsOfficeBankAccountController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountController.java index 69295853..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 @@ -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.office.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.office.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.office.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.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 11de3bdb..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 @@ -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,31 @@ import java.util.UUID; public interface HsOfficeBankAccountRepository extends Repository { + @Timed("app.office.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.office.bankAccounts.repo.findByOptionalHolderLikeImpl") List findByOptionalHolderLikeImpl(String holder); + default List findByOptionalHolderLike(String holder) { return findByOptionalHolderLikeImpl(holder == null ? "" : holder); } + + @Timed("app.office.bankAccounts.repo.findByIbanOrderByIbanAsc") List findByIbanOrderByIbanAsc(String iban); + @Timed("app.office.bankAccounts.repo.save") S save(S entity); + @Timed("app.office.bankAccounts.repo.deleteByUuid") int deleteByUuid(final UUID uuid); + @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 0f94e858..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 @@ -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.office.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.office.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.office.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.office.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.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 e893bced..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 @@ -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.office.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.office.contacts.repo.findContactByOptionalCaptionLike.rbac") List findContactByOptionalCaptionLike(String caption); + @Timed("app.office.contacts.repo.save.rbac") HsOfficeContactRbacEntity save(final HsOfficeContactRbacEntity entity); + @Timed("app.office.contacts.repo.deleteByUuid.rbac") int deleteByUuid(final UUID uuid); + @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 b4099422..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 @@ -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.office.contacts.repo.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.office.contacts.repo.findContactByOptionalCaptionLike.real") List findContactByOptionalCaptionLike(String caption); + @Timed("app.office.contacts.repo.save.real") HsOfficeContactRealEntity save(final HsOfficeContactRealEntity entity); + @Timed("app.office.contacts.repo.deleteByUuid.real") int deleteByUuid(final UUID uuid); + @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 8288d7c1..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 @@ -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.office.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.office.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.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 c606f476..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 @@ -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.office.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.office.coopAssets.repo.findCoopAssetsTransactionByOptionalMembershipUuidAndDateRange") List findCoopAssetsTransactionByOptionalMembershipUuidAndDateRange( UUID membershipUuid, LocalDate fromValueDate, LocalDate toValueDate); + @Timed("app.office.coopAssets.repo.save") HsOfficeCoopAssetsTransactionEntity save(final HsOfficeCoopAssetsTransactionEntity entity); + @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 ebd47800..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 @@ -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.office.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.office.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.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 5c3e0af6..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 @@ -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.office.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.office.coopShares.repo.findCoopSharesTransactionByOptionalMembershipUuidAndDateRange") List findCoopSharesTransactionByOptionalMembershipUuidAndDateRange( UUID membershipUuid, LocalDate fromValueDate, LocalDate toValueDate); + @Timed("app.office.coopShares.repo.save") HsOfficeCoopSharesTransactionEntity save(final HsOfficeCoopSharesTransactionEntity entity); + @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 011db6a2..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 @@ -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.office.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.office.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.office.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.office.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.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 30dabb59..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 @@ -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.office.debitors.repo.findByUuid") Optional findByUuid(UUID id); @Query(""" @@ -19,12 +21,13 @@ public interface HsOfficeDebitorRepository extends Repository findDebitorByDebitorNumber(int partnerNumber, String debitorNumberSuffix); + @Timed("app.office.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; } @@ -46,11 +49,15 @@ public interface HsOfficeDebitorRepository extends Repository findDebitorByOptionalNameLike(String name); + @Timed("app.office.debitors.repo.save") HsOfficeDebitorEntity save(final HsOfficeDebitorEntity entity); + @Timed("app.office.debitors.repo.count") long count(); + @Timed("app.office.debitors.repo.deleteByUuid") int deleteByUuid(UUID uuid); } 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..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 @@ -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.office.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.office.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.office.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.office.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.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 d7f36d07..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 @@ -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.office.membership.repo.findByUuid") Optional findByUuid(UUID id); + @Timed("app.office.membership.repo.save") HsOfficeMembershipEntity save(final HsOfficeMembershipEntity entity); + @Timed("app.office.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> listPartners( + @Timed("app.office.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.office.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.office.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.office.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.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 2c5913a5..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 @@ -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.office.partners.repo.findByUuid") Optional findByUuid(UUID id); - List findAll(); // TODO.impl: move to a repo in test sources + @Timed("app.office.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.office.partners.repo.findPartnerByPartnerNumber") HsOfficePartnerEntity findPartnerByPartnerNumber(Integer partnerNumber); + @Timed("app.office.partners.repo.save") HsOfficePartnerEntity save(final HsOfficePartnerEntity entity); + @Timed("app.office.partners.repo.count") long count(); + @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 ac746aab..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 @@ -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.office.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.office.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.office.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.office.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.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 f7481339..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 @@ -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.office.persons.repo.findByUuid.rbac") Optional findByUuid(UUID personUuid); @Query(""" @@ -17,12 +19,16 @@ public interface HsOfficePersonRepository extends Repository findPersonByOptionalNameLike(String name); + @Timed("app.office.persons.repo.save.rbac") HsOfficePersonEntity save(final HsOfficePersonEntity 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/HsOfficeRelationController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/relation/HsOfficeRelationController.java index 29078bb3..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 @@ -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.office.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.office.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.office.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.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 cce31305..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 @@ -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.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.office.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.office.relations.repo.save.rbac") HsOfficeRelationRbacEntity save(final HsOfficeRelationRbacEntity entity); + @Timed("app.office.relations.repo.count.rbac") long count(); + @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/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/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateController.java index 0a72e425..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 @@ -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.office.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.office.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.office.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.office.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.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 aab53bae..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 @@ -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.office.sepaMandates.repo.findByUuid") Optional findByUuid(UUID id); @Query(""" @@ -16,12 +18,16 @@ public interface HsOfficeSepaMandateRepository extends Repository findSepaMandateByOptionalIban(String iban); + @Timed("app.office.sepaMandates.repo.save") HsOfficeSepaMandateEntity save(final HsOfficeSepaMandateEntity entity); + @Timed("app.office.sepaMandates.repo.count") long count(); + @Timed("app.office.sepaMandates.repo.deleteByUuid") int deleteByUuid(UUID uuid); } diff --git a/src/main/java/net/hostsharing/hsadminng/rbac/grant/RawRbacGrantRepository.java b/src/main/java/net/hostsharing/hsadminng/rbac/grant/RawRbacGrantRepository.java index 1d0ba3a1..7ed53b27 100644 --- a/src/main/java/net/hostsharing/hsadminng/rbac/grant/RawRbacGrantRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/rbac/grant/RawRbacGrantRepository.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.rbac.grant; +import io.micrometer.core.annotation.Timed; import org.springframework.data.repository.Repository; import java.util.List; @@ -7,9 +8,12 @@ import java.util.UUID; public interface RawRbacGrantRepository 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/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/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 { 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() { 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"); 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