add micrometer @Timing annotations to Controllers+Repositories + ArchTest (#128)

Co-authored-by: Michael Hoennig <michael@hoennig.de>
Reviewed-on: #128
Reviewed-by: Timotheus Pokorra <timotheus.pokorra@hostsharing.net>
This commit is contained in:
Michael Hoennig 2024-12-05 10:32:34 +01:00
parent 0832c90c82
commit ddba946d72
88 changed files with 461 additions and 136 deletions

View File

@ -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<HsBookingDebitorEntity, UUID> {
@Timed("app.booking.debitor.repo.findByUuid")
Optional<HsBookingDebitorEntity> findByUuid(UUID id);
@Timed("app.booking.debitor.repo.findByDebitorNumber")
List<HsBookingDebitorEntity> findByDebitorNumber(int debitorNumber);
}

View File

@ -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<BookingItemCreatedEventEntity, UUID> {
@Timed("app.booking.items.repo.save")
BookingItemCreatedEventEntity save(HsBookingItemRealEntity current);
@Timed("app.booking.items.repo.findByBookingItem")
BookingItemCreatedEventEntity findByBookingItem(HsBookingItemRealEntity newBookingItem);
}

View File

@ -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<List<HsBookingItemResource>> listBookingItemsByProjectUuid(
@Timed("app.bookingItems.api.getListOfBookingItemsByProjectUuid")
public ResponseEntity<List<HsBookingItemResource>> getListOfBookingItemsByProjectUuid(
final String currentSubject,
final String assumedRoles,
final UUID projectUuid) {
@ -65,7 +67,8 @@ public class HsBookingItemController implements HsBookingItemsApi {
@Override
@Transactional
public ResponseEntity<HsBookingItemResource> addBookingItem(
@Timed("app.bookingItems.api.postNewBookingItem")
public ResponseEntity<HsBookingItemResource> 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<HsBookingItemResource> getBookingItemByUuid(
@Timed("app.bookingItems.api.getSingleBookingItemByUuid")
public ResponseEntity<HsBookingItemResource> 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<Void> 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<HsBookingItemResource> patchBookingItem(
final String currentSubject,
final String assumedRoles,

View File

@ -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<HsBookingItemRbacEntity>,
Repository<HsBookingItemRbacEntity, UUID> {
@Timed("app.bookingItems.repo.findByUuid.rbac")
Optional<HsBookingItemRbacEntity> findByUuid(final UUID bookingItemUuid);
@Timed("app.bookingItems.repo.findByCaption.rbac")
List<HsBookingItemRbacEntity> findByCaption(String bookingItemCaption);
@Timed("app.bookingItems.repo.findAllByProjectUuid.rbac")
List<HsBookingItemRbacEntity> 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();
}

View File

@ -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<HsBookingItemRealEntity>,
Repository<HsBookingItemRealEntity, UUID> {
@Timed("app.bookingItems.repo.findByUuid.real")
Optional<HsBookingItemRealEntity> findByUuid(final UUID bookingItemUuid);
@Timed("app.bookingItems.repo.findByCaption.real")
List<HsBookingItemRealEntity> findByCaption(String bookingItemCaption);
@Timed("app.bookingItems.repo.findAllByProjectUuid.real")
List<HsBookingItemRealEntity> 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();
}

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.hs.booking.item;
import java.util.List;
import java.util.Optional;
import java.util.UUID;

View File

@ -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<List<HsBookingProjectResource>> listBookingProjectsByDebitorUuid(
@Timed("app.bookingProjects.api.getListOfBookingProjectsByDebitorUuid")
public ResponseEntity<List<HsBookingProjectResource>> getListOfBookingProjectsByDebitorUuid(
final String currentSubject,
final String assumedRoles,
final UUID debitorUuid) {
@ -49,7 +51,8 @@ public class HsBookingProjectController implements HsBookingProjectsApi {
@Override
@Transactional
public ResponseEntity<HsBookingProjectResource> addBookingProject(
@Timed("app.bookingProjects.api.postNewBookingProject")
public ResponseEntity<HsBookingProjectResource> 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<HsBookingProjectResource> 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<Void> 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<HsBookingProjectResource> patchBookingProject(
final String currentSubject,
final String assumedRoles,

View File

@ -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<HsBookingProjectRbacEntity>,
Repository<HsBookingProjectRbacEntity, UUID> {
@Timed("app.bookingProjects.repo.findByUuid.rbac")
Optional<HsBookingProjectRbacEntity> findByUuid(final UUID bookingProjectUuid);
@Timed("app.bookingProjects.repo.findByCaption.rbac")
List<HsBookingProjectRbacEntity> findByCaption(final String projectCaption);
@Timed("app.bookingProjects.repo.findAllByDebitorUuid.rbac")
List<HsBookingProjectRbacEntity> 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();
}

View File

@ -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<HsBookingProjectRealEntity>,
Repository<HsBookingProjectRealEntity, UUID> {
@Timed("app.bookingProjects.repo.findByUuid.real")
Optional<HsBookingProjectRealEntity> findByUuid(final UUID bookingProjectUuid);
@Timed("app.bookingProjects.repo.findByCaption.real")
List<HsBookingProjectRealEntity> findByCaption(final String projectCaption);
@Timed("app.bookingProjects.repo.findAllByDebitorUuid.real")
List<HsBookingProjectRealEntity> 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();
}

View File

@ -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<E extends HsBookingProject> {
Optional<E> findByUuid(final UUID bookingProjectUuid);
@Timed("app.booking.projects.repo.findByUuid")
Optional<E> findByUuid(final UUID findByUuid);
@Timed("app.booking.projects.repo.findByCaption")
List<E> findByCaption(final String projectCaption);
@Timed("app.booking.projects.repo.findAllByDebitorUuid")
List<E> 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();
}

View File

@ -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<List<HsHostingAssetResource>> listAssets(
@Timed("app.hosting.assets.api.getListOfHostingAssets")
public ResponseEntity<List<HsHostingAssetResource>> getListOfHostingAssets(
final String currentSubject,
final String assumedRoles,
final UUID debitorUuid,
@ -65,7 +67,8 @@ public class HsHostingAssetController implements HsHostingAssetsApi {
@Override
@Transactional
public ResponseEntity<HsHostingAssetResource> addAsset(
@Timed("app.hosting.assets.api.postNewHostingAsset")
public ResponseEntity<HsHostingAssetResource> 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<HsHostingAssetResource> getAssetByUuid(
@Timed("app.hosting.assets.api.getSingleHostingAssetByUuid")
public ResponseEntity<HsHostingAssetResource> getSingleHostingAssetByUuid(
final String currentSubject,
final String assumedRoles,
final UUID assetUuid) {
@ -109,7 +113,8 @@ public class HsHostingAssetController implements HsHostingAssetsApi {
@Override
@Transactional
public ResponseEntity<Void> deleteAssetUuid(
@Timed("app.hosting.assets.api.deleteHostingAssetByUuid")
public ResponseEntity<Void> deleteHostingAssetByUuid(
final String currentSubject,
final String assumedRoles,
final UUID assetUuid) {
@ -123,7 +128,8 @@ public class HsHostingAssetController implements HsHostingAssetsApi {
@Override
@Transactional
public ResponseEntity<HsHostingAssetResource> patchAsset(
@Timed("app.hosting.assets.api.patchHostingAsset")
public ResponseEntity<HsHostingAssetResource> patchHostingAsset(
final String currentSubject,
final String assumedRoles,
final UUID assetUuid,

View File

@ -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<List<String>> listAssetTypes() {
@Timed("app.hosting.assets.api.getListOfHostingAssetTypes")
public ResponseEntity<List<String>> getListOfHostingAssetTypes() {
final var resource = HostingAssetEntityValidatorRegistry.types().stream()
.map(Enum::name)
.toList();
@ -22,7 +24,8 @@ public class HsHostingAssetPropsController implements HsHostingAssetPropsApi {
}
@Override
public ResponseEntity<List<Object>> listAssetTypeProps(
@Timed("app.hosting.assets.api.getListOfHostingAssetTypeProps")
public ResponseEntity<List<Object>> getListOfHostingAssetTypeProps(
final HsHostingAssetTypeResource assetType) {
final Enum<HsHostingAssetType> type = HsHostingAssetType.of(assetType);

View File

@ -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<HsHostingAssetRbacEntity>, Repository<HsHostingAssetRbacEntity, UUID> {
@Timed("app.hostingAsset.repo.findByUuid.rbac")
Optional<HsHostingAssetRbacEntity> findByUuid(final UUID serverUuid);
@Timed("app.hostingAsset.repo.findByIdentifier.rbac")
List<HsHostingAssetRbacEntity> findByIdentifier(String assetIdentifier);
@Query(value = """
@ -32,16 +35,21 @@ public interface HsHostingAssetRbacRepository extends HsHostingAssetRepository<H
and (:parentAssetUuid is null or pha.uuid=:parentAssetUuid)
and (:type is null or :type=cast(ha.type as text))
""", nativeQuery = true)
@Timed("app.hostingAsset.repo.findAllByCriteriaImpl.rbac")
// The JPQL query did not generate "left join" but just "join".
// I also optimized the query by not using the _rv for hs_booking.item and hs_hosting.asset, only for hs_hosting.asset_rv.
List<HsHostingAssetRbacEntity> findAllByCriteriaImpl(UUID projectUuid, UUID parentAssetUuid, String type);
default List<HsHostingAssetRbacEntity> 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();
}

View File

@ -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<HsHostingAssetRealEntity>, Repository<HsHostingAssetRealEntity, UUID> {
@Timed("app.hostingAsset.repo.findByUuid.real")
Optional<HsHostingAssetRealEntity> findByUuid(final UUID serverUuid);
@Timed("app.hostingAsset.repo.findByIdentifier.real")
List<HsHostingAssetRealEntity> findByIdentifier(String assetIdentifier);
default List<HsHostingAssetRealEntity> findByTypeAndIdentifier(@NotNull HsHostingAssetType type, @NotNull String identifier) {
@ -24,6 +27,7 @@ public interface HsHostingAssetRealRepository extends HsHostingAssetRepository<H
where cast(ha.type as String) = :type
and ha.identifier = :identifier
""")
@Timed("app.hostingAsset.repo.findByTypeAndIdentifierImpl.real")
List<HsHostingAssetRealEntity> findByTypeAndIdentifierImpl(@NotNull String type, @NotNull String identifier);
@Query(value = """
@ -46,14 +50,19 @@ public interface HsHostingAssetRealRepository extends HsHostingAssetRepository<H
""", nativeQuery = true)
// The JPQL query did not generate "left join" but just "join".
// I also optimized the query by not using the _rv for hs_booking.item and hs_hosting.asset, only for hs_hosting.asset_rv.
@Timed("app.hostingAsset.repo.findAllByCriteriaImpl.real")
List<HsHostingAssetRealEntity> findAllByCriteriaImpl(UUID projectUuid, UUID parentAssetUuid, String type);
default List<HsHostingAssetRealEntity> 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();
}

View File

@ -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<E extends HsHostingAsset> {
@Timed("app.hosting.assets.repo.findByUuid")
Optional<E> findByUuid(final UUID serverUuid);
@Timed("app.hosting.assets.repo.findByIdentifier")
List<E> findByIdentifier(String assetIdentifier);
@Timed("app.hosting.assets.repo.findAllByCriteriaImpl")
List<E> findAllByCriteriaImpl(UUID projectUuid, UUID parentAssetUuid, String type);
default List<E> 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();
}

View File

@ -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.office.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.office.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.office.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.office.bankAccounts.api.deleteBankAccountByUuid")
public ResponseEntity<Void> deleteBankAccountByUuid(
final String currentSubject,
final String assumedRoles,

View File

@ -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<HsOfficeBankAccountEntity, UUID> {
@Timed("app.office.bankAccounts.repo.findByUuid")
Optional<HsOfficeBankAccountEntity> 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<HsOfficeBankAccountEntity> findByOptionalHolderLikeImpl(String holder);
default List<HsOfficeBankAccountEntity> findByOptionalHolderLike(String holder) {
return findByOptionalHolderLikeImpl(holder == null ? "" : holder);
}
@Timed("app.office.bankAccounts.repo.findByIbanOrderByIbanAsc")
List<HsOfficeBankAccountEntity> findByIbanOrderByIbanAsc(String iban);
@Timed("app.office.bankAccounts.repo.save")
<S extends HsOfficeBankAccountEntity> S save(S entity);
@Timed("app.office.bankAccounts.repo.deleteByUuid")
int deleteByUuid(final UUID uuid);
@Timed("app.office.bankAccounts.repo.count")
long count();
}

View File

@ -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<List<HsOfficeContactResource>> listContacts(
@Timed("app.office.contacts.api.getListOfContacts")
public ResponseEntity<List<HsOfficeContactResource>> getListOfContacts(
final String currentSubject,
final String assumedRoles,
final String caption) {
@ -47,7 +49,8 @@ public class HsOfficeContactController implements HsOfficeContactsApi {
@Override
@Transactional
public ResponseEntity<HsOfficeContactResource> addContact(
@Timed("app.office.contacts.api.postNewContact")
public ResponseEntity<HsOfficeContactResource> 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<HsOfficeContactResource> getContactByUuid(
@Timed("app.office.contacts.api.getSingleContactByUuid")
public ResponseEntity<HsOfficeContactResource> 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<Void> 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<HsOfficeContactResource> patchContact(
final String currentSubject,
final String assumedRoles,

View File

@ -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<HsOfficeContactRbacEntity, UUID> {
@Timed("app.office.contacts.repo.findByUuid.rbac")
Optional<HsOfficeContactRbacEntity> 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<HsOfficeContactRbacEntity> 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();
}

View File

@ -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<HsOfficeContactRealEntity, UUID> {
@Timed("app.office.contacts.repo.findByUuid.real")
Optional<HsOfficeContactRealEntity> 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<HsOfficeContactRealEntity> 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();
}

View File

@ -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<List<HsOfficeCoopAssetsTransactionResource>> 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<HsOfficeCoopAssetsTransactionResource> 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<HsOfficeCoopAssetsTransactionResource> getSingleCoopAssetTransactionByUuid(
final String currentSubject, final String assumedRoles, final UUID assetTransactionUuid) {

View File

@ -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<HsOfficeCoopAssetsTransactionEntity, UUID> {
@Timed("app.office.coopAssets.repo.findByUuid")
Optional<HsOfficeCoopAssetsTransactionEntity> findByUuid(UUID id);
@Query("""
@ -18,11 +20,14 @@ public interface HsOfficeCoopAssetsTransactionRepository extends Repository<HsOf
AND ( CAST(:fromValueDate AS java.time.LocalDate) IS NULL OR (at.valueDate >= :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<HsOfficeCoopAssetsTransactionEntity> 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();
}

View File

@ -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<List<HsOfficeCoopSharesTransactionResource>> 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<HsOfficeCoopSharesTransactionResource> 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<HsOfficeCoopSharesTransactionResource> getSingleCoopShareTransactionByUuid(
final String currentSubject, final String assumedRoles, final UUID shareTransactionUuid) {

View File

@ -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<HsOfficeCoopSharesTransactionEntity, UUID> {
@Timed("app.office.coopShares.repo.findByUuid")
Optional<HsOfficeCoopSharesTransactionEntity> findByUuid(UUID id);
@Query("""
@ -18,11 +20,14 @@ public interface HsOfficeCoopSharesTransactionRepository extends Repository<HsOf
AND ( CAST(:fromValueDate AS java.time.LocalDate) IS NULL OR (st.valueDate >= :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<HsOfficeCoopSharesTransactionEntity> 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();
}

View File

@ -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<List<HsOfficeDebitorResource>> 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<HsOfficeDebitorResource> 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<HsOfficeDebitorResource> 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<Void> 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<HsOfficeDebitorResource> patchDebitor(
final String currentSubject,
final String assumedRoles,

View File

@ -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.office.debitors.repo.findByUuid")
Optional<HsOfficeDebitorEntity> findByUuid(UUID id);
@Query("""
@ -19,12 +21,13 @@ public interface HsOfficeDebitorRepository extends Repository<HsOfficeDebitorEnt
WHERE partner.partnerNumber = :partnerNumber
AND debitor.debitorNumberSuffix = :debitorNumberSuffix
""")
List<HsOfficeDebitorEntity> findDebitorByDebitorNumber(int partnerNumber, String debitorNumberSuffix);
@Timed("app.office.debitors.repo.findDebitorByPartnerNumberAndDebitorNumberSuffix")
List<HsOfficeDebitorEntity> findDebitorByPartnerNumberAndDebitorNumberSuffix(int partnerNumber, String debitorNumberSuffix);
default List<HsOfficeDebitorEntity> 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<HsOfficeDebitorEnt
OR person.givenName like concat(cast(:name as text), '%')
OR contact.caption like concat(cast(:name as text), '%')
""")
@Timed("app.office.debitors.repo.findDebitorByOptionalNameLike")
List<HsOfficeDebitorEntity> 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);
}

View File

@ -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<List<HsOfficeMembershipResource>> 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<HsOfficeMembershipResource> 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<HsOfficeMembershipResource> 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<Void> 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<HsOfficeMembershipResource> patchMembership(
final String currentSubject,
final String assumedRoles,

View File

@ -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<HsOfficeMembershipEntity, UUID> {
@Timed("app.office.membership.repo.findByUuid")
Optional<HsOfficeMembershipEntity> findByUuid(UUID id);
@Timed("app.office.membership.repo.save")
HsOfficeMembershipEntity save(final HsOfficeMembershipEntity entity);
@Timed("app.office.membership.repo.findAll")
List<HsOfficeMembershipEntity> findAll();
@Query("""
@ -22,6 +26,7 @@ public interface HsOfficeMembershipRepository extends Repository<HsOfficeMembers
OR membership.partner.uuid = :partnerUuid )
ORDER BY membership.partner.partnerNumber, membership.memberNumberSuffix
""")
@Timed("app.office.membership.repo.findMembershipsByOptionalPartnerUuid")
List<HsOfficeMembershipEntity> findMembershipsByOptionalPartnerUuid(UUID partnerUuid);
@Query("""
@ -30,6 +35,7 @@ public interface HsOfficeMembershipRepository extends Repository<HsOfficeMembers
AND (membership.memberNumberSuffix = :suffix)
ORDER BY membership.memberNumberSuffix
""")
@Timed("app.office.membership.repo.findMembershipByPartnerNumberAndSuffix")
HsOfficeMembershipEntity findMembershipByPartnerNumberAndSuffix(
@NotNull Integer partnerNumber,
@NotNull String suffix);
@ -41,7 +47,9 @@ public interface HsOfficeMembershipRepository extends Repository<HsOfficeMembers
return result;
}
@Timed("app.office.membership.repo.count")
long count();
@Timed("app.office.membership.repo.deleteByUuid")
int deleteByUuid(UUID uuid);
}

View File

@ -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.office.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.office.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.office.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.office.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.office.partners.api.patchPartner")
public ResponseEntity<HsOfficePartnerResource> patchPartner(
final String currentSubject,
final String assumedRoles,

View File

@ -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.office.partners.repo.findByUuid")
Optional<HsOfficePartnerEntity> findByUuid(UUID id);
List<HsOfficePartnerEntity> findAll(); // TODO.impl: move to a repo in test sources
@Timed("app.office.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.office.partners.repo.findPartnerByOptionalNameLike")
List<HsOfficePartnerEntity> 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);
}

View File

@ -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<List<HsOfficePersonResource>> listPersons(
@Timed("app.office.persons.api.getListOfPersons")
public ResponseEntity<List<HsOfficePersonResource>> getListOfPersons(
final String currentSubject,
final String assumedRoles,
final String caption) {
@ -44,7 +46,8 @@ public class HsOfficePersonController implements HsOfficePersonsApi {
@Override
@Transactional
public ResponseEntity<HsOfficePersonResource> addPerson(
@Timed("app.office.persons.api.postNewPerson")
public ResponseEntity<HsOfficePersonResource> 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<HsOfficePersonResource> getPersonByUuid(
@Timed("app.office.persons.api.getSinglePersonByUuid")
public ResponseEntity<HsOfficePersonResource> 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<Void> 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<HsOfficePersonResource> patchPerson(
final String currentSubject,
final String assumedRoles,

View File

@ -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<HsOfficePersonEntity, UUID> {
@Timed("app.office.persons.repo.findByUuid.rbac")
Optional<HsOfficePersonEntity> findByUuid(UUID personUuid);
@Query("""
@ -17,12 +19,16 @@ public interface HsOfficePersonRepository extends Repository<HsOfficePersonEntit
OR p.tradeName like concat(cast(:name as text), '%')
OR p.givenName like concat(cast(:name as text), '%')
OR p.familyName like concat(cast(:name as text), '%')
""")
""")
@Timed("app.office.persons.repo.findPersonByOptionalNameLike.rbac")
List<HsOfficePersonEntity> 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();
}

View File

@ -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<List<HsOfficeRelationResource>> listRelations(
@Timed("app.office.relations.api.getListOfRelations")
public ResponseEntity<List<HsOfficeRelationResource>> getListOfRelations(
final String currentSubject,
final String assumedRoles,
final UUID personUuid,
@ -66,7 +67,8 @@ public class HsOfficeRelationController implements HsOfficeRelationsApi {
@Override
@Transactional
public ResponseEntity<HsOfficeRelationResource> addRelation(
@Timed("app.office.relations.api.postNewRelation")
public ResponseEntity<HsOfficeRelationResource> 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<HsOfficeRelationResource> getRelationByUuid(
@Timed("app.office.relations.api.getSingleRelationByUuid")
public ResponseEntity<HsOfficeRelationResource> 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<Void> 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<HsOfficeRelationResource> patchRelation(
final String currentSubject,
final String assumedRoles,

View File

@ -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<HsOfficeRelationRbacEntity, UUID> {
@Timed("app.office.relations.repo.findByUuid.rbac")
Optional<HsOfficeRelationRbacEntity> 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<HsOfficeRelationRbacEntity> findRelationRelatedToPersonUuid(@NotNull UUID personUuid);
/**
@ -51,16 +54,20 @@ public interface HsOfficeRelationRbacRepository extends Repository<HsOfficeRelat
OR lower(CAST(rel.contact.emailAddresses AS String)) LIKE :contactData
OR lower(CAST(rel.contact.phoneNumbers AS String)) LIKE :contactData )
""")
@Timed("app.office.relations.repo.findRelationRelatedToPersonUuidRelationTypePersonAndContactDataImpl.rbac")
List<HsOfficeRelationRbacEntity> 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) {

View File

@ -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<HsOfficeRelationRealEntity, UUID> {
@Timed("app.repo.relations.findByUuid.real")
Optional<HsOfficeRelationRealEntity> findByUuid(UUID id);
default List<HsOfficeRelationRealEntity> findRelationRelatedToPersonUuidAndRelationType(@NotNull UUID personUuid, HsOfficeRelationType relationType) {
@ -20,6 +22,7 @@ public interface HsOfficeRelationRealRepository extends Repository<HsOfficeRelat
SELECT p.* FROM hs_office.relation AS p
WHERE p.anchorUuid = :personUuid OR p.holderUuid = :personUuid
""", nativeQuery = true)
@Timed("app.repo.relations.findRelationRelatedToPersonUuid.real")
List<HsOfficeRelationRealEntity> findRelationRelatedToPersonUuid(@NotNull UUID personUuid);
@Query(value = """
@ -27,11 +30,15 @@ public interface HsOfficeRelationRealRepository extends Repository<HsOfficeRelat
WHERE (:relationType IS NULL OR p.type = cast(:relationType AS hs_office.RelationType))
AND ( p.anchorUuid = :personUuid OR p.holderUuid = :personUuid)
""", nativeQuery = true)
@Timed("app.repo.relations.findRelationRelatedToPersonUuidAndRelationTypeString.real")
List<HsOfficeRelationRealEntity> 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);
}

View File

@ -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.office.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.office.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.office.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.office.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.office.sepaMandates.api.patchSepaMandate")
public ResponseEntity<HsOfficeSepaMandateResource> patchSepaMandate(
final String currentSubject,
final String assumedRoles,

View File

@ -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.office.sepaMandates.repo.findByUuid")
Optional<HsOfficeSepaMandateEntity> findByUuid(UUID id);
@Query("""
@ -16,12 +18,16 @@ public interface HsOfficeSepaMandateRepository extends Repository<HsOfficeSepaMa
WHERE :iban is null
OR mandate.bankAccount.iban like concat(cast(:iban as text), '%')
ORDER BY mandate.bankAccount.iban
""")
""")
@Timed("app.office.sepaMandates.repo.findSepaMandateByOptionalIban")
List<HsOfficeSepaMandateEntity> 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);
}

View File

@ -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<RawRbacGrantEntity, UUID> {
List<RawRbacGrantEntity> findAll();
@Timed("app.rbac.grants.repo.findAll")
List<RawRbacGrantEntity> findAll(); // TODO.refa: move to test repo
@Timed("app.rbac.grants.repo.findByAscendingUuid")
List<RawRbacGrantEntity> findByAscendingUuid(UUID ascendingUuid);
@Timed("app.rbac.grants.repo.findByDescendantUuid")
List<RawRbacGrantEntity> findByDescendantUuid(UUID refUuid);
}

View File

@ -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<RbacGrantResource> getGrantById(
@Timed("app.rbac.grants.api.getListOfGrantsByUuid")
public ResponseEntity<RbacGrantResource> 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<List<RbacGrantResource>> listSubjectGrants(
@Timed("app.rbac.grants.api.getListOfSubjectGrants")
public ResponseEntity<List<RbacGrantResource>> getListOfSubjectGrants(
final String currentSubject,
final String assumedRoles) {
@ -61,7 +64,8 @@ public class RbacGrantController implements RbacGrantsApi {
@Override
@Transactional
public ResponseEntity<RbacGrantResource> grantRoleToSubject(
@Timed("app.rbac.grants.api.postNewRoleGrantToSubject")
public ResponseEntity<RbacGrantResource> postNewRoleGrantToSubject(
final String currentSubject,
final String assumedRoles,
final RbacGrantResource body) {
@ -82,7 +86,8 @@ public class RbacGrantController implements RbacGrantsApi {
@Override
@Transactional
public ResponseEntity<Void> revokeRoleFromSubject(
@Timed("app.rbac.grants.api.deleteRoleGrantFromSubject")
public ResponseEntity<Void> deleteRoleGrantFromSubject(
final String currentSubject,
final String assumedRoles,
final UUID grantedRoleUuid,

View File

@ -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<RbacGrantEntity, RbacGra
where g.grantedRoleUuid=:#{#rbacGrantId.grantedRoleUuid}
and g.granteeSubjectUuid=:#{#rbacGrantId.granteeSubjectUuid}
""")
@Timed("app.rbac.grants.repo.findById")
RbacGrantEntity findById(RbacGrantId rbacGrantId);
@Timed("app.rbac.grants.repo.count")
long count();
@Timed("app.rbac.grants.repo.findAll")
List<RbacGrantEntity> findAll();
@Timed("app.rbac.grants.repo.save")
RbacGrantEntity save(final RbacGrantEntity grant);
@Modifying
@ -27,5 +32,6 @@ public interface RbacGrantRepository extends Repository<RbacGrantEntity, RbacGra
where g.grantedRoleUuid=:#{#rbacGrantId.grantedRoleUuid}
and g.granteeSubjectUuid=:#{#rbacGrantId.granteeSubjectUuid}
""")
@Timed("app.rbac.grants.repo.deleteByRbacGrantId")
void deleteByRbacGrantId(RbacGrantId rbacGrantId);
}

View File

@ -1,5 +1,6 @@
package net.hostsharing.hsadminng.rbac.role;
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.RbacRolesApi;
@ -25,7 +26,8 @@ public class RbacRoleController implements RbacRolesApi {
@Override
@Transactional(readOnly = true)
public ResponseEntity<List<RbacRoleResource>> listRoles(
@Timed("app.rbac.roles.api.getListOfRoles")
public ResponseEntity<List<RbacRoleResource>> getListOfRoles(
final String currentSubject,
final String assumedRoles) {

View File

@ -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<RbacRoleEntity, UUID> {
/**
* @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<RbacRoleEntity> findAll();
@Timed("app.rbac.roles.repo.findAll")
List<RbacRoleEntity> findAll(); // TODO.refa: move to test sources
@Timed("app.rbac.roles.repo.findByRoleName")
RbacRoleEntity findByRoleName(String roleName);
}

View File

@ -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<RbacSubjectResource> createSubject(
@Timed("app.rbac.subjects.api.postNewSubject")
public ResponseEntity<RbacSubjectResource> 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<Void> deleteSubjectByUuid(
final String currentSubject,
final String assumedRoles,
@ -62,7 +65,8 @@ public class RbacSubjectController implements RbacSubjectsApi {
@Override
@Transactional(readOnly = true)
public ResponseEntity<RbacSubjectResource> getSubjectById(
@Timed("app.rbac.subjects.api.getSingleSubjectByUuid")
public ResponseEntity<RbacSubjectResource> 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<List<RbacSubjectResource>> listSubjects(
@Timed("app.rbac.subjects.api.getListOfSubjects")
public ResponseEntity<List<RbacSubjectResource>> 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<List<RbacSubjectPermissionResource>> listSubjectPermissions(
@Timed("app.rbac.subjects.api.getListOfSubjectPermissions")
public ResponseEntity<List<RbacSubjectPermissionResource>> getListOfSubjectPermissions(
final String currentSubject,
final String assumedRoles,
final UUID subjectUuid

View File

@ -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<RbacSubjectEntity, UUI
where :userName is null or u.name like concat(cast(:userName as text), '%')
order by u.name
""")
@Timed("app.rbac.subjects.repo.findByOptionalNameLike")
List<RbacSubjectEntity> 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<RbacSubjectPermission> findPermissionsOfUserByUuid(UUID subjectUuid);
/*
@ -32,6 +37,7 @@ public interface RbacSubjectRepository extends Repository<RbacSubjectEntity, UUI
*/
@Modifying
@Query(value = "insert into rbac.subject_rv (uuid, name) values( :#{#newUser.uuid}, :#{#newUser.name})", nativeQuery = true)
@Timed("app.rbac.subjects.repo.insert")
void insert(final RbacSubjectEntity newUser);
default RbacSubjectEntity create(final RbacSubjectEntity rbacSubjectEntity) {
@ -42,5 +48,6 @@ public interface RbacSubjectRepository extends Repository<RbacSubjectEntity, UUI
return rbacSubjectEntity;
}
@Timed("app.rbac.subjects.repo.deleteByUuid")
void deleteByUuid(UUID subjectUuid);
}

View File

@ -2,7 +2,7 @@ get:
tags:
- hs-booking-items
description: 'Fetch a single booking item its uuid, if visible for the current subject.'
operationId: getBookingItemByUuid
operationId: getSingleBookingItemByUuid
parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -3,7 +3,7 @@ get:
description: Returns the list of all booking items for a specified project which are visible to the current subject or any of it's assumed roles.
tags:
- hs-booking-items
operationId: listBookingItemsByProjectUuid
operationId: getListOfBookingItemsByProjectUuid
parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
@ -32,7 +32,7 @@ post:
summary: Adds a new booking item.
tags:
- hs-booking-items
operationId: addBookingItem
operationId: postNewBookingItem
parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -3,7 +3,7 @@ get:
description: Returns the list of all booking projects for a specified debitor which are visible to the current subject or any of it's assumed roles.
tags:
- hs-booking-projects
operationId: listBookingProjectsByDebitorUuid
operationId: getListOfBookingProjectsByDebitorUuid
parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
@ -32,7 +32,7 @@ post:
summary: Adds a new project as a container for booking items.
tags:
- hs-booking-projects
operationId: addBookingProject
operationId: postNewBookingProject
parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -3,7 +3,7 @@ get:
description: Returns the list of available properties and their validations for a given asset type.
tags:
- hs-hosting-asset-props
operationId: listAssetTypeProps
operationId: getListOfHostingAssetTypeProps
parameters:
- name: assetType
in: path

View File

@ -3,7 +3,7 @@ get:
description: Returns the list of asset types to enable an adaptive UI.
tags:
- hs-hosting-asset-props
operationId: listAssetTypes
operationId: getListOfHostingAssetTypes
responses:
"200":
description: OK

View File

@ -2,7 +2,7 @@ get:
tags:
- hs-hosting-assets
description: 'Fetch a single managed asset by its uuid, if visible for the current subject.'
operationId: getAssetByUuid
operationId: getSingleHostingAssetByUuid
parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
@ -30,7 +30,7 @@ patch:
tags:
- hs-hosting-assets
description: 'Updates a single hosting asset identified by its uuid, if permitted for the current subject.'
operationId: patchAsset
operationId: patchHostingAsset
parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
@ -61,7 +61,7 @@ delete:
tags:
- hs-hosting-assets
description: 'Delete a single hosting asset identified by its uuid, if permitted for the current subject.'
operationId: deleteAssetUuid
operationId: deleteHostingAssetByUuid
parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -3,7 +3,7 @@ get:
description: Returns the list of all hosting assets which match the given filters and are visible to the current subject or any of it's assumed roles.
tags:
- hs-hosting-assets
operationId: listAssets
operationId: getListOfHostingAssets
parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
@ -45,7 +45,7 @@ post:
summary: Adds a new hosting asset.
tags:
- hs-hosting-assets
operationId: addAsset
operationId: postNewHostingAsset
parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -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'

View File

@ -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'

View File

@ -2,7 +2,7 @@ get:
tags:
- hs-office-contacts
description: 'Fetch a single business contact by its uuid, if visible for the current subject.'
operationId: getContactByUuid
operationId: getSingleContactByUuid
parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -3,7 +3,7 @@ get:
description: Returns the list of (optionally filtered) contacts which are visible to the current subject or any of it's assumed roles.
tags:
- hs-office-contacts
operationId: listContacts
operationId: getListOfContacts
parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
@ -31,7 +31,7 @@ post:
summary: Adds a new contact.
tags:
- hs-office-contacts
operationId: addContact
operationId: postNewContact
parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -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'

View File

@ -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'

View File

@ -2,7 +2,7 @@ get:
tags:
- hs-office-persons
description: 'Fetch a single business person by its uuid, if visible for the current subject.'
operationId: getPersonByUuid
operationId: getSinglePersonByUuid
parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -3,7 +3,7 @@ get:
description: Returns the list of (optionally filtered) persons which are visible to the current subject or any of it's assumed roles.
tags:
- hs-office-persons
operationId: listPersons
operationId: getListOfPersons
parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
@ -31,7 +31,7 @@ post:
summary: Adds a new person.
tags:
- hs-office-persons
operationId: addPerson
operationId: postNewPerson
parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -2,7 +2,7 @@ get:
tags:
- hs-office-relations
description: 'Fetch a single person relation by its uuid, if visible for the current subject.'
operationId: getRelationByUuid
operationId: getSingleRelationByUuid
parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -5,7 +5,7 @@ get:
To match data, all given query parameters must be fulfilled ('and' / logical conjunction).
tags:
- hs-office-relations
operationId: listRelations
operationId: getListOfRelations
parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
@ -52,7 +52,7 @@ post:
summary: Adds a new person relation.
tags:
- hs-office-relations
operationId: addRelation
operationId: postNewRelation
parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -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'

View File

@ -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'

View File

@ -1,7 +1,7 @@
get:
tags:
- rbac-grants
operationId: getGrantById
operationId: getListOfGrantsByUuid
parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
@ -36,7 +36,7 @@ get:
delete:
tags:
- rbac-grants
operationId: revokeRoleFromSubject
operationId: deleteRoleGrantFromSubject
parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -1,7 +1,7 @@
get:
tags:
- rbac-grants
operationId: listSubjectGrants
operationId: getListOfSubjectGrants
parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
@ -18,7 +18,7 @@ get:
post:
tags:
- rbac-grants
operationId: grantRoleToSubject
operationId: postNewRoleGrantToSubject
parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -1,7 +1,7 @@
get:
tags:
- rbac-roles
operationId: listRoles
operationId: getListOfRoles
parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -2,7 +2,7 @@ get:
tags:
- rbac-subjects
description: 'List all visible permissions granted to the given subject; reduced '
operationId: listSubjectPermissions
operationId: getListOfSubjectPermissions
parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -2,7 +2,7 @@ get:
tags:
- rbac-subjects
description: 'Fetch a single subject by its id, if visible for the current subject.'
operationId: getSubjectById
operationId: getSingleSubjectByUuid
parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles'

View File

@ -2,7 +2,7 @@ get:
tags:
- rbac-subjects
description: List accessible RBAC subjects with optional filter by name.
operationId: listSubjects
operationId: getListOfSubjects
parameters:
- $ref: 'auth.yaml#/components/parameters/currentSubject'
- $ref: 'auth.yaml#/components/parameters/assumedRoles'
@ -29,7 +29,7 @@ post:
tags:
- rbac-subjects
description: Create a new RBAC subject (e.g. user).
operationId: createSubject
operationId: postNewSubject
requestBody:
required: true
content:

View File

@ -9,9 +9,11 @@ management:
web:
exposure:
include: info, health, metrics
observations:
annotations:
enabled: true
spring:
datasource:
driver-class-name: org.postgresql.Driver
password: password
@ -33,3 +35,11 @@ liquibase:
hsadminng:
postgres:
leakproof:
metrics:
distribution:
percentiles-histogram:
http:
server:
requests: true

View File

@ -10,6 +10,7 @@ import com.tngtech.archunit.lang.ArchCondition;
import com.tngtech.archunit.lang.ArchRule;
import com.tngtech.archunit.lang.ConditionEvents;
import com.tngtech.archunit.lang.SimpleConditionEvent;
import io.micrometer.core.annotation.Timed;
import net.hostsharing.hsadminng.HsadminNgApplication;
import net.hostsharing.hsadminng.hs.booking.item.HsBookingItem;
import net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetRbacEntity;
@ -20,7 +21,9 @@ import org.springframework.web.bind.annotation.RestController;
import jakarta.persistence.Table;
import static com.tngtech.archunit.core.domain.JavaModifier.ABSTRACT;
import java.lang.annotation.Annotation;
import static com.tngtech.archunit.core.domain.JavaModifier.PUBLIC;
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.*;
import static com.tngtech.archunit.library.dependencies.SlicesRuleDefinition.slices;
import static java.lang.String.format;
@ -98,7 +101,7 @@ public class ArchitectureTest {
@SuppressWarnings("unused")
public static final ArchRule testClassesAreProperlyNamed = classes()
.that().haveSimpleNameEndingWith("Test")
.and().doNotHaveModifier(ABSTRACT)
.and().doNotHaveModifier(JavaModifier.ABSTRACT)
.should().haveNameMatching(".*(UnitTest|RestTest|IntegrationTest|AcceptanceTest|ScenarioTest|ArchitectureTest)$");
@ArchTest
@ -346,11 +349,25 @@ public class ArchitectureTest {
static final ArchRule restControllerNaming =
classes().that().areAnnotatedWith(RestController.class).should().haveSimpleNameEndingWith("Controller");
@ArchTest
@SuppressWarnings("unused")
static final ArchRule restControllerMethods = classes()
.that().areAnnotatedWith(RestController.class)
.and().resideOutsideOfPackages("net.hostsharing.hsadminng.rbac.test", "net.hostsharing.hsadminng.rbac.test.*")
.should(haveAllPublicMethodsAnnotatedWith(Timed.class));
@ArchTest
@SuppressWarnings("unused")
static final ArchRule repositoryNaming =
classes().that().areAssignableTo(Repository.class).should().haveSimpleNameEndingWith("Repository");
@ArchTest
@SuppressWarnings("unused")
static final ArchRule repositoryMethods = classes()
.that().areAssignableTo(Repository.class)
.and().resideOutsideOfPackages("net.hostsharing.hsadminng.rbac.test", "net.hostsharing.hsadminng.rbac.test.*")
.should(haveAllPublicMethodsAnnotatedWith(Timed.class));
@ArchTest
@SuppressWarnings("unused")
static final ArchRule tableNamesOfRbacEntitiesShouldEndWith_rv =
@ -389,4 +406,35 @@ public class ArchitectureTest {
}
};
}
private static ArchCondition<JavaClass> haveAllPublicMethodsAnnotatedWith(Class<? extends Annotation> 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);
}
}

View File

@ -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);

View File

@ -84,7 +84,7 @@ class HsBookingItemControllerRestTest {
}
@Nested
class AddBookingItem {
class PostNewBookingItem {
@Test
void globalAdmin_canAddValidBookingItem() throws Exception {

View File

@ -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()

View File

@ -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() {

View File

@ -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)

View File

@ -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");

View File

@ -128,7 +128,7 @@ class HsOfficeBankAccountRepositoryIntegrationTest extends ContextBasedTestWithC
}
@Nested
class ListBankAccounts {
class GetListOfBankAccounts {
@Test
public void globalAdmin_canViewAllBankAccounts() {

View File

@ -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);

View File

@ -91,7 +91,7 @@ class HsOfficePartnerControllerRestTest {
}
@Nested
class AddPartner {
class PostNewPartner {
@Test
void respondBadRequest_ifPersonUuidIsInvalid() throws Exception {

View File

@ -52,7 +52,7 @@ class HsOfficePersonControllerAcceptanceTest extends ContextBasedTestWithCleanup
EntityManager em;
@Nested
class ListPersons {
class GetListOfPersons {
@Test
void globalAdmin_withoutAssumedRoles_canViewAllPersons_ifNoCriteriaGiven() {

View File

@ -54,7 +54,7 @@ class HsOfficeRelationControllerAcceptanceTest extends ContextBasedTestWithClean
JpaAttempt jpaAttempt;
@Nested
class ListRelations {
class GetListOfRelations {
@Test
void globalAdmin_withoutAssumedRoles_canViewAllRelationsOfGivenPersonAndType() {

View File

@ -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");

View File

@ -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;
}

View File

@ -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<RawRbacObjectEntity, UUID> {
@Timed("app.rbac.objects.repo.findAll.real")
List<RawRbacObjectEntity> findAll();
}

View File

@ -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<RawRbacRoleEntity, UUID> {
@Timed("app.rbac.roles.repo.findAll.real")
List<RawRbacRoleEntity> findAll();
}

View File

@ -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")

View File

@ -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