diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorController.java index 011db6a2..391f7a2d 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorController.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.office.debitor; +import io.micrometer.core.annotation.Timed; import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeDebitorsApi; import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeDebitorInsertResource; @@ -51,6 +52,7 @@ public class HsOfficeDebitorController implements HsOfficeDebitorsApi { @Override @Transactional(readOnly = true) + @Timed("app.debitors.api.getListOfDebitors") public ResponseEntity> getListOfDebitors( final String currentSubject, final String assumedRoles, @@ -68,6 +70,7 @@ public class HsOfficeDebitorController implements HsOfficeDebitorsApi { @Override @Transactional + @Timed("app.debitors.api.postNewDebitor") public ResponseEntity postNewDebitor( String currentSubject, String assumedRoles, @@ -115,6 +118,7 @@ public class HsOfficeDebitorController implements HsOfficeDebitorsApi { @Override @Transactional(readOnly = true) + @Timed("app.debitors.api.getSingleDebitorByUuid") public ResponseEntity getSingleDebitorByUuid( final String currentSubject, final String assumedRoles, @@ -131,6 +135,7 @@ public class HsOfficeDebitorController implements HsOfficeDebitorsApi { @Override @Transactional + @Timed("app.debitors.api.deleteDebitorByUuid") public ResponseEntity deleteDebitorByUuid( final String currentSubject, final String assumedRoles, @@ -147,6 +152,7 @@ public class HsOfficeDebitorController implements HsOfficeDebitorsApi { @Override @Transactional + @Timed("app.debitors.api.patchDebitor") public ResponseEntity patchDebitor( final String currentSubject, final String assumedRoles, diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepository.java index 30dabb59..3eb1835e 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/debitor/HsOfficeDebitorRepository.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.office.debitor; +import io.micrometer.core.annotation.Timed; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; @@ -9,6 +10,7 @@ import java.util.UUID; public interface HsOfficeDebitorRepository extends Repository { + @Timed("app.debitors.repo.findByUuid") Optional findByUuid(UUID id); @Query(""" @@ -19,7 +21,8 @@ public interface HsOfficeDebitorRepository extends Repository findDebitorByDebitorNumber(int partnerNumber, String debitorNumberSuffix); + @Timed("app.debitors.repo.findDebitorByDebitorNumber") + List findDebitorByDebitorNumber(int partnerNumber, String debitorNumberSuffix); default List findDebitorByDebitorNumber(int debitorNumber) { final var partnerNumber = debitorNumber / 100; @@ -46,11 +49,15 @@ public interface HsOfficeDebitorRepository extends Repository findDebitorByOptionalNameLike(String name); + @Timed("app.debitors.repo.save") HsOfficeDebitorEntity save(final HsOfficeDebitorEntity entity); + @Timed("app.debitors.repo.count") long count(); + @Timed("app.debitors.repo.deleteByUuid") int deleteByUuid(UUID uuid); } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerController.java index c39dcd49..c2f66594 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerController.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.office.partner; +import io.micrometer.core.annotation.Timed; import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.errors.ReferenceNotFoundException; import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactRealEntity; @@ -50,7 +51,8 @@ public class HsOfficePartnerController implements HsOfficePartnersApi { @Override @Transactional(readOnly = true) - public ResponseEntity> listPartners( + @Timed("app.partners.api.getListOfPartners") + public ResponseEntity> getListOfPartners( final String currentSubject, final String assumedRoles, final String name) { @@ -64,7 +66,8 @@ public class HsOfficePartnerController implements HsOfficePartnersApi { @Override @Transactional - public ResponseEntity addPartner( + @Timed("app.partners.api.postNewPartner") + public ResponseEntity postNewPartner( final String currentSubject, final String assumedRoles, final HsOfficePartnerInsertResource body) { @@ -86,7 +89,8 @@ public class HsOfficePartnerController implements HsOfficePartnersApi { @Override @Transactional(readOnly = true) - public ResponseEntity getPartnerByUuid( + @Timed("app.partners.api.getSinglePartnerByUuid") + public ResponseEntity getSinglePartnerByUuid( final String currentSubject, final String assumedRoles, final UUID partnerUuid) { @@ -102,6 +106,7 @@ public class HsOfficePartnerController implements HsOfficePartnersApi { @Override @Transactional + @Timed("app.partners.api.deletePartnerByUuid") public ResponseEntity deletePartnerByUuid( final String currentSubject, final String assumedRoles, @@ -122,6 +127,7 @@ public class HsOfficePartnerController implements HsOfficePartnersApi { @Override @Transactional + @Timed("app.partners.api.patchPartner") public ResponseEntity patchPartner( final String currentSubject, final String assumedRoles, diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRepository.java index 2c5913a5..24a52568 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerRepository.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.office.partner; +import io.micrometer.core.annotation.Timed; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; @@ -9,9 +10,11 @@ import java.util.UUID; public interface HsOfficePartnerRepository extends Repository { + @Timed("app.partners.repo.findByUuid") Optional findByUuid(UUID id); - List findAll(); // TODO.impl: move to a repo in test sources + @Timed("app.partners.repo.findAll") + List findAll(); // TODO.refa: move to a repo in test sources @Query(""" SELECT partner FROM HsOfficePartnerEntity partner @@ -25,12 +28,18 @@ public interface HsOfficePartnerRepository extends Repository findPartnerByOptionalNameLike(String name); + + @Timed("app.partners.repo.findPartnerByPartnerNumber") HsOfficePartnerEntity findPartnerByPartnerNumber(Integer partnerNumber); + @Timed("app.partners.repo.save") HsOfficePartnerEntity save(final HsOfficePartnerEntity entity); + @Timed("app.partners.repo.count") long count(); + @Timed("app.partners.repo.deleteByUuid") int deleteByUuid(UUID uuid); } diff --git a/src/main/resources/api-definition/hs-office/hs-office-partners-with-uuid.yaml b/src/main/resources/api-definition/hs-office/hs-office-partners-with-uuid.yaml index e19e6cd2..704a54a1 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-partners-with-uuid.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-partners-with-uuid.yaml @@ -2,7 +2,7 @@ get: tags: - hs-office-partners description: 'Fetch a single business partner by its uuid, if visible for the current subject.' - operationId: getPartnerByUuid + operationId: getSinglePartnerByUuid parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' diff --git a/src/main/resources/api-definition/hs-office/hs-office-partners.yaml b/src/main/resources/api-definition/hs-office/hs-office-partners.yaml index 9e97a91d..67df42b3 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-partners.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-partners.yaml @@ -3,7 +3,7 @@ get: description: Returns the list of (optionally filtered) business partners which are visible to the current subject or any of it's assumed roles. tags: - hs-office-partners - operationId: listPartners + operationId: getListOfPartners parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' @@ -31,7 +31,7 @@ post: summary: Adds a new business partner. tags: - hs-office-partners - operationId: addPartner + operationId: postNewPartner parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerAcceptanceTest.java index 82472faa..5f82a9d3 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerAcceptanceTest.java @@ -58,7 +58,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu @Nested @Transactional - class ListPartners { + class GetListOfPartners { @Test void globalAdmin_withoutAssumedRoles_canViewAllPartners_ifNoCriteriaGiven() { @@ -87,10 +87,10 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu @Nested @Transactional - class AddPartner { + class PostNewPartner { @Test - void globalAdmin_withoutAssumedRole_canAddPartner() { + void globalAdmin_withoutAssumedRole_canPostNewPartner() { context.define("superuser-alex@hostsharing.net"); final var givenMandantPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").stream().findFirst().orElseThrow(); @@ -150,7 +150,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu } @Test - void globalAdmin_canNotAddPartner_ifContactDoesNotExist() { + void globalAdmin_canNotPostNewPartner_ifContactDoesNotExist() { context.define("superuser-alex@hostsharing.net"); final var givenMandantPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").get(0); @@ -188,7 +188,7 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu } @Test - void globalAdmin_canNotAddPartner_ifPersonDoesNotExist() { + void globalAdmin_canNotPostNewPartner_ifPersonDoesNotExist() { context.define("superuser-alex@hostsharing.net"); final var mandantPerson = personRepo.findPersonByOptionalNameLike("Hostsharing eG").get(0); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerRestTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerRestTest.java index caf1fe6f..31e0786d 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerRestTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/partner/HsOfficePartnerControllerRestTest.java @@ -91,7 +91,7 @@ class HsOfficePartnerControllerRestTest { } @Nested - class AddPartner { + class PostNewPartner { @Test void respondBadRequest_ifPersonUuidIsInvalid() throws Exception {