diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountController.java index 69295853..50087bf4 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountController.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.office.bankaccount; +import io.micrometer.core.annotation.Timed; import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeBankAccountsApi; import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeBankAccountInsertResource; @@ -31,7 +32,8 @@ public class HsOfficeBankAccountController implements HsOfficeBankAccountsApi { @Override @Transactional(readOnly = true) - public ResponseEntity> listBankAccounts( + @Timed("app.bankAccounts.api.patchDebitor") + public ResponseEntity> getListOfBankAccounts( final String currentSubject, final String assumedRoles, final String holder) { @@ -45,7 +47,8 @@ public class HsOfficeBankAccountController implements HsOfficeBankAccountsApi { @Override @Transactional - public ResponseEntity addBankAccount( + @Timed("app.bankAccounts.api.postNewBankAccount") + public ResponseEntity postNewBankAccount( final String currentSubject, final String assumedRoles, final HsOfficeBankAccountInsertResource body) { @@ -71,7 +74,8 @@ public class HsOfficeBankAccountController implements HsOfficeBankAccountsApi { @Override @Transactional(readOnly = true) - public ResponseEntity getBankAccountByUuid( + @Timed("app.bankAccounts.api.getSingleBankAccountByUuid") + public ResponseEntity getSingleBankAccountByUuid( final String currentSubject, final String assumedRoles, final UUID bankAccountUuid) { @@ -87,6 +91,7 @@ public class HsOfficeBankAccountController implements HsOfficeBankAccountsApi { @Override @Transactional + @Timed("app.bankAccounts.api.deleteBankAccountByUuid") public ResponseEntity deleteBankAccountByUuid( final String currentSubject, final String assumedRoles, diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountRepository.java index 11de3bdb..ecc1b2c0 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountRepository.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.office.bankaccount; +import io.micrometer.core.annotation.Timed; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; @@ -9,23 +10,30 @@ import java.util.UUID; public interface HsOfficeBankAccountRepository extends Repository { + @Timed("app.bankAccounts.repo.findByUuid") Optional findByUuid(UUID id); @Query(""" SELECT c FROM HsOfficeBankAccountEntity c WHERE lower(c.holder) like lower(concat(:holder, '%')) ORDER BY c.holder - """) + """) + @Timed("app.bankAccounts.repo.findByOptionalHolderLikeImpl") List findByOptionalHolderLikeImpl(String holder); default List findByOptionalHolderLike(String holder) { return findByOptionalHolderLikeImpl(holder == null ? "" : holder); } + + @Timed("app.bankAccounts.repo.findByIbanOrderByIbanAsc") List findByIbanOrderByIbanAsc(String iban); + @Timed("app.bankAccounts.repo.save") S save(S entity); + @Timed("app.bankAccounts.repo.deleteByUuid") int deleteByUuid(final UUID uuid); + @Timed("app.bankAccounts.repo.count") long count(); } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateController.java index 0a72e425..05916d7c 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateController.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.office.sepamandate; +import io.micrometer.core.annotation.Timed; import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeSepaMandatesApi; import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeSepaMandateInsertResource; @@ -38,7 +39,8 @@ public class HsOfficeSepaMandateController implements HsOfficeSepaMandatesApi { @Override @Transactional(readOnly = true) - public ResponseEntity> listSepaMandatesByIban( + @Timed("app.sepaMandates.api.getListOfSepaMandates") + public ResponseEntity> getListOfSepaMandates( final String currentSubject, final String assumedRoles, final String iban) { @@ -53,7 +55,8 @@ public class HsOfficeSepaMandateController implements HsOfficeSepaMandatesApi { @Override @Transactional - public ResponseEntity addSepaMandate( + @Timed("app.sepaMandates.api.postNewSepaMandate") + public ResponseEntity postNewSepaMandate( final String currentSubject, final String assumedRoles, final HsOfficeSepaMandateInsertResource body) { @@ -76,7 +79,8 @@ public class HsOfficeSepaMandateController implements HsOfficeSepaMandatesApi { @Override @Transactional(readOnly = true) - public ResponseEntity getSepaMandateByUuid( + @Timed("app.sepaMandates.api.getSingleSepaMandateByUuid") + public ResponseEntity getSingleSepaMandateByUuid( final String currentSubject, final String assumedRoles, final UUID sepaMandateUuid) { @@ -93,6 +97,7 @@ public class HsOfficeSepaMandateController implements HsOfficeSepaMandatesApi { @Override @Transactional + @Timed("app.sepaMandates.api.deleteSepaMandateByUuid") public ResponseEntity deleteSepaMandateByUuid( final String currentSubject, final String assumedRoles, @@ -109,6 +114,7 @@ public class HsOfficeSepaMandateController implements HsOfficeSepaMandatesApi { @Override @Transactional + @Timed("app.sepaMandates.api.patchSepaMandate") public ResponseEntity patchSepaMandate( final String currentSubject, final String assumedRoles, diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateRepository.java index aab53bae..24ebfe1d 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateRepository.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.office.sepamandate; +import io.micrometer.core.annotation.Timed; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; @@ -9,6 +10,7 @@ import java.util.UUID; public interface HsOfficeSepaMandateRepository extends Repository { + @Timed("app.sepaMandates.repo.findByUuid") Optional findByUuid(UUID id); @Query(""" @@ -16,12 +18,16 @@ public interface HsOfficeSepaMandateRepository extends Repository findSepaMandateByOptionalIban(String iban); + @Timed("app.sepaMandates.repo.save") HsOfficeSepaMandateEntity save(final HsOfficeSepaMandateEntity entity); + @Timed("app.sepaMandates.repo.count") long count(); + @Timed("app.sepaMandates.repo.deleteByUuid") int deleteByUuid(UUID uuid); } diff --git a/src/main/resources/api-definition/hs-office/hs-office-bankaccounts-with-uuid.yaml b/src/main/resources/api-definition/hs-office/hs-office-bankaccounts-with-uuid.yaml index cdef972a..08602841 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-bankaccounts-with-uuid.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-bankaccounts-with-uuid.yaml @@ -2,7 +2,7 @@ get: tags: - hs-office-bank-accounts description: 'Fetch a single bank account by its uuid, if visible for the current subject.' - operationId: getBankAccountByUuid + operationId: getSingleBankAccountByUuid parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' diff --git a/src/main/resources/api-definition/hs-office/hs-office-bankaccounts.yaml b/src/main/resources/api-definition/hs-office/hs-office-bankaccounts.yaml index 316fc250..e492d093 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-bankaccounts.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-bankaccounts.yaml @@ -3,7 +3,7 @@ get: description: Returns the list of (optionally filtered) bankaccounts which are visible to the current subject or any of it's assumed roles. tags: - hs-office-bank-accounts - operationId: listBankAccounts + operationId: getListOfBankAccounts parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' @@ -31,7 +31,7 @@ post: summary: Adds a new bank account. tags: - hs-office-bank-accounts - operationId: addBankAccount + operationId: postNewBankAccount parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' diff --git a/src/main/resources/api-definition/hs-office/hs-office-sepamandates-with-uuid.yaml b/src/main/resources/api-definition/hs-office/hs-office-sepamandates-with-uuid.yaml index 1e14a235..3ff4ccb4 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-sepamandates-with-uuid.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-sepamandates-with-uuid.yaml @@ -2,7 +2,7 @@ get: tags: - hs-office-sepaMandates description: 'Fetch a single SEPA Mandate by its uuid, if visible for the current subject.' - operationId: getSepaMandateByUuid + operationId: getSingleSepaMandateByUuid parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' diff --git a/src/main/resources/api-definition/hs-office/hs-office-sepamandates.yaml b/src/main/resources/api-definition/hs-office/hs-office-sepamandates.yaml index 724d8ece..ad624014 100644 --- a/src/main/resources/api-definition/hs-office/hs-office-sepamandates.yaml +++ b/src/main/resources/api-definition/hs-office/hs-office-sepamandates.yaml @@ -3,7 +3,7 @@ get: description: Returns the list of (optionally filtered) SEPA Mandates which are visible to the current subject or any of it's assumed roles. tags: - hs-office-sepaMandates - operationId: listSepaMandatesByIBAN + operationId: getListOfSepaMandates parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' @@ -31,7 +31,7 @@ post: summary: Adds a new SEPA Mandate. tags: - hs-office-sepaMandates - operationId: addSepaMandate + operationId: postNewSepaMandate parameters: - $ref: 'auth.yaml#/components/parameters/currentSubject' - $ref: 'auth.yaml#/components/parameters/assumedRoles' diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountControllerAcceptanceTest.java index 4d6c9973..0a565a60 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountControllerAcceptanceTest.java @@ -50,7 +50,7 @@ class HsOfficeBankAccountControllerAcceptanceTest extends ContextBasedTestWithCl EntityManager em; @Nested - class ListBankAccounts { + class GetListOfBankAccounts { @Test void globalAdmin_withoutAssumedRoles_canViewAllBankAccounts_ifNoCriteriaGiven() throws JSONException { @@ -117,7 +117,7 @@ class HsOfficeBankAccountControllerAcceptanceTest extends ContextBasedTestWithCl class CreateBankAccount { @Test - void globalAdmin_withoutAssumedRole_canAddBankAccount() { + void globalAdmin_withoutAssumedRole_canPostNewBankAccount() { context.define("superuser-alex@hostsharing.net"); diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountRepositoryIntegrationTest.java index ed573418..770ef859 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/bankaccount/HsOfficeBankAccountRepositoryIntegrationTest.java @@ -128,7 +128,7 @@ class HsOfficeBankAccountRepositoryIntegrationTest extends ContextBasedTestWithC } @Nested - class ListBankAccounts { + class GetListOfBankAccounts { @Test public void globalAdmin_canViewAllBankAccounts() { diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateControllerAcceptanceTest.java index 4eccac8e..63cce53f 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/sepamandate/HsOfficeSepaMandateControllerAcceptanceTest.java @@ -132,10 +132,10 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl } @Nested - class AddSepaMandate { + class PostNewSepaMandate { @Test - void globalAdmin_canAddSepaMandate() { + void globalAdmin_canPostNewSepaMandate() { context.define("superuser-alex@hostsharing.net"); final var givenDebitor = debitorRepo.findDebitorByOptionalNameLike("Third").get(0); @@ -177,7 +177,7 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl // TODO.test: move validation tests to a ...WebMvcTest @Test - void globalAdmin_canNotAddSepaMandateWhenDebitorUuidIsMissing() { + void globalAdmin_canNotPostNewSepaMandateWhenDebitorUuidIsMissing() { context.define("superuser-alex@hostsharing.net"); final var givenDebitor = debitorRepo.findDebitorByOptionalNameLike("Third").get(0); @@ -202,7 +202,7 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl } @Test - void globalAdmin_canNotAddSepaMandate_ifBankAccountDoesNotExist() { + void globalAdmin_canNotPostNewSepaMandate_ifBankAccountDoesNotExist() { context.define("superuser-alex@hostsharing.net"); final var givenDebitor = debitorRepo.findDebitorByOptionalNameLike("Third").get(0); @@ -232,7 +232,7 @@ class HsOfficeSepaMandateControllerAcceptanceTest extends ContextBasedTestWithCl } @Test - void globalAdmin_canNotAddSepaMandate_ifPersonDoesNotExist() { + void globalAdmin_canNotPostNewSepaMandate_ifPersonDoesNotExist() { context.define("superuser-alex@hostsharing.net"); final var givenDebitorUuid = UUID.fromString("00000000-0000-0000-0000-000000000000");