1
0

Taiga#457: improve bookingitem resource mapping error message (#218)

Co-authored-by: Michael Hoennig <michael@hoennig.de>
Reviewed-on: https://dev.hostsharing.net/hostsharing/hs.hsadmin.ng/pulls/218
Reviewed-by: Marc Sandlus <hsh-marcsandlus@noreply.dev.hostsharing.net>
This commit is contained in:
Michael Hoennig
2026-03-19 09:40:14 +01:00
parent 69e2fc09a6
commit 79d4d8c7f2
13 changed files with 139 additions and 20 deletions
@@ -71,7 +71,7 @@ class HsBookingItemEntityPatcherUnitTest extends PatchUnitTestBase<
final var entity = new HsBookingItemRbacEntity();
entity.setUuid(INITIAL_BOOKING_ITEM_UUID);
entity.setProject(PROJECT_TEST_ENTITY);
entity.getResources().putAll(KeyValueMap.from(INITIAL_RESOURCES));
entity.getResources().putAll(KeyValueMap.from("resources", INITIAL_RESOURCES));
entity.setCaption(INITIAL_CAPTION);
entity.setValidity(Range.closedInfinite(GIVEN_VALID_FROM));
return entity;
@@ -71,7 +71,7 @@ class HsHostingAssetEntityPatcherUnitTest extends PatchUnitTestBase<
final var entity = new HsHostingAssetRbacEntity();
entity.setUuid(INITIAL_BOOKING_ITEM_UUID);
entity.setBookingItem(CLOUD_SERVER_BOOKING_ITEM_REAL_ENTITY);
entity.getConfig().putAll(KeyValueMap.from(INITIAL_CONFIG));
entity.getConfig().putAll(KeyValueMap.from("config", INITIAL_CONFIG));
entity.setCaption(INITIAL_CAPTION);
entity.setAlarmContact(givenInitialContact);
return entity;
@@ -2,6 +2,7 @@ package net.hostsharing.hsadminng.mapper;
import org.junit.jupiter.api.Test;
import jakarta.validation.ValidationException;
import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
@@ -13,7 +14,7 @@ class KeyValueMapUnitTest {
@Test
void fromMap() {
final var result = KeyValueMap.from(Map.ofEntries(
final var result = KeyValueMap.from("propName", Map.ofEntries(
Map.entry("one", 1),
Map.entry("two", 2)
));
@@ -24,9 +25,10 @@ class KeyValueMapUnitTest {
@Test
void fromNonMap() {
final var exception = catchThrowable( () ->
KeyValueMap.from("not a map")
KeyValueMap.from("propMap", "not a map")
);
assertThat(exception).isInstanceOf(ClassCastException.class);
assertThat(exception).isInstanceOf(ValidationException.class);
assertThat(exception.getMessage()).isEqualTo("propMap: Map expected, but got: not a map");
}
}