add micrometer @Timing annotations to Controllers+Repositories + ArchTest #128
@ -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<List<HsOfficeDebitorResource>> 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<HsOfficeDebitorResource> 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<HsOfficeDebitorResource> 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<Void> 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<HsOfficeDebitorResource> patchDebitor(
|
||||
final String currentSubject,
|
||||
final String assumedRoles,
|
||||
|
@ -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<HsOfficeDebitorEntity, UUID> {
|
||||
|
||||
@Timed("app.debitors.repo.findByUuid")
|
||||
Optional<HsOfficeDebitorEntity> findByUuid(UUID id);
|
||||
|
||||
@Query("""
|
||||
@ -19,6 +21,7 @@ public interface HsOfficeDebitorRepository extends Repository<HsOfficeDebitorEnt
|
||||
WHERE partner.partnerNumber = :partnerNumber
|
||||
AND debitor.debitorNumberSuffix = :debitorNumberSuffix
|
||||
""")
|
||||
@Timed("app.debitors.repo.findDebitorByDebitorNumber")
|
||||
List<HsOfficeDebitorEntity> findDebitorByDebitorNumber(int partnerNumber, String debitorNumberSuffix);
|
||||
|
||||
default List<HsOfficeDebitorEntity> findDebitorByDebitorNumber(int debitorNumber) {
|
||||
@ -46,11 +49,15 @@ public interface HsOfficeDebitorRepository extends Repository<HsOfficeDebitorEnt
|
||||
OR person.givenName like concat(cast(:name as text), '%')
|
||||
OR contact.caption like concat(cast(:name as text), '%')
|
||||
""")
|
||||
@Timed("app.debitors.repo.findDebitorByOptionalNameLike")
|
||||
List<HsOfficeDebitorEntity> 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);
|
||||
}
|
||||
|
@ -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<List<HsOfficePartnerResource>> listPartners(
|
||||
@Timed("app.partners.api.getListOfPartners")
|
||||
public ResponseEntity<List<HsOfficePartnerResource>> getListOfPartners(
|
||||
final String currentSubject,
|
||||
final String assumedRoles,
|
||||
final String name) {
|
||||
@ -64,7 +66,8 @@ public class HsOfficePartnerController implements HsOfficePartnersApi {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public ResponseEntity<HsOfficePartnerResource> addPartner(
|
||||
@Timed("app.partners.api.postNewPartner")
|
||||
public ResponseEntity<HsOfficePartnerResource> 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<HsOfficePartnerResource> getPartnerByUuid(
|
||||
@Timed("app.partners.api.getSinglePartnerByUuid")
|
||||
public ResponseEntity<HsOfficePartnerResource> 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<Void> 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<HsOfficePartnerResource> patchPartner(
|
||||
final String currentSubject,
|
||||
final String assumedRoles,
|
||||
|
@ -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<HsOfficePartnerEntity, UUID> {
|
||||
|
||||
@Timed("app.partners.repo.findByUuid")
|
||||
Optional<HsOfficePartnerEntity> findByUuid(UUID id);
|
||||
|
||||
List<HsOfficePartnerEntity> findAll(); // TODO.impl: move to a repo in test sources
|
||||
@Timed("app.partners.repo.findAll")
|
||||
List<HsOfficePartnerEntity> 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<HsOfficePartnerEnt
|
||||
OR person.givenName like concat(cast(:name as text), '%')
|
||||
OR person.familyName like concat(cast(:name as text), '%')
|
||||
""")
|
||||
@Timed("app.partners.repo.findPartnerByOptionalNameLike")
|
||||
List<HsOfficePartnerEntity> 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);
|
||||
}
|
||||
|
@ -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'
|
||||
|
@ -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'
|
||||
|
@ -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);
|
||||
|
@ -91,7 +91,7 @@ class HsOfficePartnerControllerRestTest {
|
||||
}
|
||||
|
||||
@Nested
|
||||
class AddPartner {
|
||||
class PostNewPartner {
|
||||
|
||||
@Test
|
||||
void respondBadRequest_ifPersonUuidIsInvalid() throws Exception {
|
||||
|
Loading…
Reference in New Issue
Block a user