booking-item-to-related-hosting-asset-just-1-to-1 #61

Merged
hsh-michaelhoennig merged 8 commits from booking-item-to-related-hosting-asset-just-1-to-1 into master 2024-06-18 13:53:11 +02:00
2 changed files with 5 additions and 9 deletions
Showing only changes of commit b1cf2ed04a - Show all commits

View File

@ -284,7 +284,7 @@ class HsBookingItemControllerAcceptanceTest extends ContextBasedTestWithCleanup
@Test @Test
void globalAdmin_canPatchAllUpdatablePropertiesOfBookingItem() { void globalAdmin_canPatchAllUpdatablePropertiesOfBookingItem() {
final var givenBookingItem = givenSomeNewBookingItem(1000111, MANAGED_WEBSPACE, final var givenBookingItem = givenSomeNewBookingItem("D-1000111 default project", MANAGED_WEBSPACE,
resource("HDD", 100), resource("SSD", 50), resource("Traffic", 250)); resource("HDD", 100), resource("SSD", 50), resource("Traffic", 250));
RestAssured // @formatter:off RestAssured // @formatter:off
@ -339,7 +339,7 @@ class HsBookingItemControllerAcceptanceTest extends ContextBasedTestWithCleanup
@Test @Test
void globalAdmin_canDeleteArbitraryBookingItem() { void globalAdmin_canDeleteArbitraryBookingItem() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenBookingItem = givenSomeNewBookingItem(1000111, MANAGED_WEBSPACE, final var givenBookingItem = givenSomeNewBookingItem("D-1000111 default project", MANAGED_WEBSPACE,
resource("HDD", 100), resource("SSD", 50), resource("Traffic", 250)); resource("HDD", 100), resource("SSD", 50), resource("Traffic", 250));
RestAssured // @formatter:off RestAssured // @formatter:off
@ -358,7 +358,7 @@ class HsBookingItemControllerAcceptanceTest extends ContextBasedTestWithCleanup
@Test @Test
void normalUser_canNotDeleteUnrelatedBookingItem() { void normalUser_canNotDeleteUnrelatedBookingItem() {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
final var givenBookingItem = givenSomeNewBookingItem(1000111, MANAGED_WEBSPACE, final var givenBookingItem = givenSomeNewBookingItem("D-1000111 default project", MANAGED_WEBSPACE,
resource("HDD", 100), resource("SSD", 50), resource("Traffic", 250)); resource("HDD", 100), resource("SSD", 50), resource("Traffic", 250));
RestAssured // @formatter:off RestAssured // @formatter:off
@ -376,14 +376,11 @@ class HsBookingItemControllerAcceptanceTest extends ContextBasedTestWithCleanup
} }
@SafeVarargs @SafeVarargs
private HsBookingItemEntity givenSomeNewBookingItem(final int debitorNumber, private HsBookingItemEntity givenSomeNewBookingItem(final String projectCaption,
final HsBookingItemType hsBookingItemType, final Map.Entry<String, Object>... resources) { final HsBookingItemType hsBookingItemType, final Map.Entry<String, Object>... resources) {
return jpaAttempt.transacted(() -> { return jpaAttempt.transacted(() -> {
context.define("superuser-alex@hostsharing.net"); context.define("superuser-alex@hostsharing.net");
// FIXME: use projectRepo directly final var givenProject = projectRepo.findByCaption(projectCaption).stream()
final var givenProject = debitorRepo.findDebitorByDebitorNumber(debitorNumber).stream()
.map(d -> projectRepo.findAllByDebitorUuid(d.getUuid()))
.flatMap(java.util.List::stream)
.findAny().orElseThrow(); .findAny().orElseThrow();
final var newBookingItem = HsBookingItemEntity.builder() final var newBookingItem = HsBookingItemEntity.builder()
.uuid(UUID.randomUUID()) .uuid(UUID.randomUUID())

View File

@ -63,7 +63,6 @@ public abstract class ContextBasedTestWithCleanup extends ContextBasedTest {
return merged; return merged;
} }
// FIXME: remove HsOfficeCoopAssetsTransactionRawEntity, which is not needed anymore after this change
public UUID toCleanup(final Class<? extends RbacObject> entityClass, final UUID uuidToCleanup) { public UUID toCleanup(final Class<? extends RbacObject> entityClass, final UUID uuidToCleanup) {
out.println("toCleanup(" + entityClass.getSimpleName() + ", " + uuidToCleanup + ")"); out.println("toCleanup(" + entityClass.getSimpleName() + ", " + uuidToCleanup + ")");
entitiesToCleanup.put(uuidToCleanup, entityClass); entitiesToCleanup.put(uuidToCleanup, entityClass);