fixing issues from code-review

This commit is contained in:
Michael Hoennig 2024-06-14 14:53:46 +02:00
parent 8163c1e338
commit f379ae5cb2
2 changed files with 8 additions and 8 deletions

View File

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

View File

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