fixing issues from code-review
This commit is contained in:
parent
8163c1e338
commit
f379ae5cb2
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user