add micrometer @Timing annotations to Controllers+Repositories + ArchTest #128
@ -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<List<HsOfficeBankAccountResource>> listBankAccounts(
|
||||
@Timed("app.bankAccounts.api.patchDebitor")
|
||||
public ResponseEntity<List<HsOfficeBankAccountResource>> getListOfBankAccounts(
|
||||
final String currentSubject,
|
||||
final String assumedRoles,
|
||||
final String holder) {
|
||||
@ -45,7 +47,8 @@ public class HsOfficeBankAccountController implements HsOfficeBankAccountsApi {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public ResponseEntity<HsOfficeBankAccountResource> addBankAccount(
|
||||
@Timed("app.bankAccounts.api.postNewBankAccount")
|
||||
public ResponseEntity<HsOfficeBankAccountResource> 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<HsOfficeBankAccountResource> getBankAccountByUuid(
|
||||
@Timed("app.bankAccounts.api.getSingleBankAccountByUuid")
|
||||
public ResponseEntity<HsOfficeBankAccountResource> 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<Void> deleteBankAccountByUuid(
|
||||
final String currentSubject,
|
||||
final String assumedRoles,
|
||||
|
@ -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,6 +10,7 @@ import java.util.UUID;
|
||||
|
||||
public interface HsOfficeBankAccountRepository extends Repository<HsOfficeBankAccountEntity, UUID> {
|
||||
|
||||
@Timed("app.bankAccounts.repo.findByUuid")
|
||||
Optional<HsOfficeBankAccountEntity> findByUuid(UUID id);
|
||||
|
||||
@Query("""
|
||||
@ -16,16 +18,22 @@ public interface HsOfficeBankAccountRepository extends Repository<HsOfficeBankAc
|
||||
WHERE lower(c.holder) like lower(concat(:holder, '%'))
|
||||
ORDER BY c.holder
|
||||
""")
|
||||
@Timed("app.bankAccounts.repo.findByOptionalHolderLikeImpl")
|
||||
List<HsOfficeBankAccountEntity> findByOptionalHolderLikeImpl(String holder);
|
||||
default List<HsOfficeBankAccountEntity> findByOptionalHolderLike(String holder) {
|
||||
return findByOptionalHolderLikeImpl(holder == null ? "" : holder);
|
||||
}
|
||||
|
||||
|
||||
@Timed("app.bankAccounts.repo.findByIbanOrderByIbanAsc")
|
||||
List<HsOfficeBankAccountEntity> findByIbanOrderByIbanAsc(String iban);
|
||||
|
||||
@Timed("app.bankAccounts.repo.save")
|
||||
<S extends HsOfficeBankAccountEntity> S save(S entity);
|
||||
|
||||
@Timed("app.bankAccounts.repo.deleteByUuid")
|
||||
int deleteByUuid(final UUID uuid);
|
||||
|
||||
@Timed("app.bankAccounts.repo.count")
|
||||
long count();
|
||||
}
|
||||
|
@ -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<List<HsOfficeSepaMandateResource>> listSepaMandatesByIban(
|
||||
@Timed("app.sepaMandates.api.getListOfSepaMandates")
|
||||
public ResponseEntity<List<HsOfficeSepaMandateResource>> getListOfSepaMandates(
|
||||
final String currentSubject,
|
||||
final String assumedRoles,
|
||||
final String iban) {
|
||||
@ -53,7 +55,8 @@ public class HsOfficeSepaMandateController implements HsOfficeSepaMandatesApi {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public ResponseEntity<HsOfficeSepaMandateResource> addSepaMandate(
|
||||
@Timed("app.sepaMandates.api.postNewSepaMandate")
|
||||
public ResponseEntity<HsOfficeSepaMandateResource> 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<HsOfficeSepaMandateResource> getSepaMandateByUuid(
|
||||
@Timed("app.sepaMandates.api.getSingleSepaMandateByUuid")
|
||||
public ResponseEntity<HsOfficeSepaMandateResource> 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<Void> 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<HsOfficeSepaMandateResource> patchSepaMandate(
|
||||
final String currentSubject,
|
||||
final String assumedRoles,
|
||||
|
@ -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<HsOfficeSepaMandateEntity, UUID> {
|
||||
|
||||
@Timed("app.sepaMandates.repo.findByUuid")
|
||||
Optional<HsOfficeSepaMandateEntity> findByUuid(UUID id);
|
||||
|
||||
@Query("""
|
||||
@ -17,11 +19,15 @@ public interface HsOfficeSepaMandateRepository extends Repository<HsOfficeSepaMa
|
||||
OR mandate.bankAccount.iban like concat(cast(:iban as text), '%')
|
||||
ORDER BY mandate.bankAccount.iban
|
||||
""")
|
||||
@Timed("app.sepaMandates.repo.findSepaMandateByOptionalIban")
|
||||
List<HsOfficeSepaMandateEntity> 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);
|
||||
}
|
||||
|
@ -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'
|
||||
|
@ -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'
|
||||
|
@ -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'
|
||||
|
@ -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'
|
||||
|
@ -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");
|
||||
|
||||
|
@ -128,7 +128,7 @@ class HsOfficeBankAccountRepositoryIntegrationTest extends ContextBasedTestWithC
|
||||
}
|
||||
|
||||
@Nested
|
||||
class ListBankAccounts {
|
||||
class GetListOfBankAccounts {
|
||||
|
||||
@Test
|
||||
public void globalAdmin_canViewAllBankAccounts() {
|
||||
|
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user