hierarchical-validation-baseline #59

Merged
hsh-michaelhoennig merged 18 commits from hierarchical-validation-baseline into master 2024-06-14 16:48:01 +02:00
2 changed files with 8 additions and 8 deletions
Showing only changes of commit f379ae5cb2 - Show all commits

View File

@ -21,6 +21,8 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
import static net.hostsharing.hsadminng.hs.hosting.asset.validators.HsHostingAssetEntityValidatorRegistry.validated;
@RestController @RestController
public class HsHostingAssetController implements HsHostingAssetsApi { public class HsHostingAssetController implements HsHostingAssetsApi {
@ -61,8 +63,7 @@ public class HsHostingAssetController implements HsHostingAssetsApi {
final var entityToSave = mapper.map(body, HsHostingAssetEntity.class, RESOURCE_TO_ENTITY_POSTMAPPER); final var entityToSave = mapper.map(body, HsHostingAssetEntity.class, RESOURCE_TO_ENTITY_POSTMAPPER);
final HsHostingAssetEntity persistentEntity = assetRepo.save(entityToSave); final var saved = validated(assetRepo.save(entityToSave));
final var saved = HsHostingAssetEntityValidatorRegistry.validated(persistentEntity);
final var uri = final var uri =
MvcUriComponentsBuilder.fromController(getClass()) MvcUriComponentsBuilder.fromController(getClass())
@ -117,8 +118,7 @@ public class HsHostingAssetController implements HsHostingAssetsApi {
new HsHostingAssetEntityPatcher(current).apply(body); new HsHostingAssetEntityPatcher(current).apply(body);
final HsHostingAssetEntity persistentEntity = assetRepo.save(current); final var saved = validated(assetRepo.save(current));
final var saved = HsHostingAssetEntityValidatorRegistry.validated(persistentEntity);
final var mapped = mapper.map(saved, HsHostingAssetResource.class); final var mapped = mapper.map(saved, HsHostingAssetResource.class);
return ResponseEntity.ok(mapped); return ResponseEntity.ok(mapped);
} }

View File

@ -38,10 +38,10 @@ class HsBookingItemEntityValidatorUnitTest {
// then // then
assertThat(result).isInstanceOf(ValidationException.class) assertThat(result).isInstanceOf(ValidationException.class)
.hasMessageContaining( .hasMessageContaining(
"D-12345:test project:Test-Server.resources.CPUs' is required but missing", "'D-12345:test project:Test-Server.resources.CPUs' is required but missing",
"D-12345:test project:Test-Server.resources.RAM' is required but missing", "'D-12345:test project:Test-Server.resources.RAM' is required but missing",
"D-12345:test project:Test-Server.resources.SSD' is required but missing", "'D-12345:test project:Test-Server.resources.SSD' is required but missing",
"D-12345:test project:Test-Server.resources.Traffic' is required but missing"); "'D-12345:test project:Test-Server.resources.Traffic' is required but missing");
} }
@Test @Test