hierarchical-validation-baseline #59
@ -21,6 +21,8 @@ import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import static net.hostsharing.hsadminng.hs.hosting.asset.validators.HsHostingAssetEntityValidatorRegistry.validated;
|
||||
|
||||
@RestController
|
||||
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 HsHostingAssetEntity persistentEntity = assetRepo.save(entityToSave);
|
||||
final var saved = HsHostingAssetEntityValidatorRegistry.validated(persistentEntity);
|
||||
final var saved = validated(assetRepo.save(entityToSave));
|
||||
|
||||
final var uri =
|
||||
MvcUriComponentsBuilder.fromController(getClass())
|
||||
@ -117,8 +118,7 @@ public class HsHostingAssetController implements HsHostingAssetsApi {
|
||||
|
||||
new HsHostingAssetEntityPatcher(current).apply(body);
|
||||
|
||||
final HsHostingAssetEntity persistentEntity = assetRepo.save(current);
|
||||
final var saved = HsHostingAssetEntityValidatorRegistry.validated(persistentEntity);
|
||||
final var saved = validated(assetRepo.save(current));
|
||||
final var mapped = mapper.map(saved, HsHostingAssetResource.class);
|
||||
return ResponseEntity.ok(mapped);
|
||||
}
|
||||
|
@ -38,10 +38,10 @@ class HsBookingItemEntityValidatorUnitTest {
|
||||
// then
|
||||
assertThat(result).isInstanceOf(ValidationException.class)
|
||||
.hasMessageContaining(
|
||||
"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.SSD' is required but missing",
|
||||
"D-12345:test project:Test-Server.resources.Traffic' 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.SSD' is required but missing",
|
||||
"'D-12345:test project:Test-Server.resources.Traffic' is required but missing");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user