From afbb51c4d8d4ee65b606c3cc68fa6c0fce1639d2 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Mon, 17 Jun 2024 06:26:30 +0200 Subject: [PATCH] Cloud, Server and Webspace BillingItems and HostingAssets --- .../hs/booking/item/HsBookingItemEntity.java | 2 - .../HsCloudServerBookingItemValidator.java | 14 +- .../HsPrivateCloudBookingItemValidator.java | 10 +- .../hosting/asset/HsHostingAssetEntity.java | 1 - .../HsManagedServerHostingAssetValidator.java | 44 ++++- .../hs/validation/EnumerationProperty.java | 22 ++- .../hs/validation/HsEntityValidator.java | 1 + .../hs/validation/ValidatableProperty.java | 4 + ...oudServerBookingItemValidatorUnitTest.java | 1 + ...sHostingAssetControllerAcceptanceTest.java | 73 ++++---- ...ingAssetPropsControllerAcceptanceTest.java | 173 ++++++++++++++++-- ...HostingAssetRepositoryIntegrationTest.java | 2 - ...HsHostingAssetEntityValidatorUnitTest.java | 7 +- ...edServerHostingAssetValidatorUnitTest.java | 1 - 14 files changed, 269 insertions(+), 86 deletions(-) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemEntity.java index 0856f866..9ac25a3e 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/booking/item/HsBookingItemEntity.java @@ -17,8 +17,6 @@ import net.hostsharing.hsadminng.rbac.rbacdef.RbacView.SQL; import net.hostsharing.hsadminng.rbac.rbacobject.RbacObject; import net.hostsharing.hsadminng.stringify.Stringify; import net.hostsharing.hsadminng.stringify.Stringifyable; -import org.hibernate.annotations.NotFound; -import org.hibernate.annotations.NotFoundAction; import org.hibernate.annotations.Type; import jakarta.persistence.CascadeType; diff --git a/src/main/java/net/hostsharing/hsadminng/hs/booking/item/validators/HsCloudServerBookingItemValidator.java b/src/main/java/net/hostsharing/hsadminng/hs/booking/item/validators/HsCloudServerBookingItemValidator.java index 07bb80da..acb82674 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/booking/item/validators/HsCloudServerBookingItemValidator.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/booking/item/validators/HsCloudServerBookingItemValidator.java @@ -2,6 +2,7 @@ package net.hostsharing.hsadminng.hs.booking.item.validators; +import static net.hostsharing.hsadminng.hs.validation.BooleanProperty.booleanProperty; import static net.hostsharing.hsadminng.hs.validation.EnumerationProperty.enumerationProperty; import static net.hostsharing.hsadminng.hs.validation.IntegerProperty.integerProperty; @@ -9,12 +10,13 @@ class HsCloudServerBookingItemValidator extends HsBookingItemEntityValidator { HsCloudServerBookingItemValidator() { super( - integerProperty("CPUs").min(1).max(32).required(), - integerProperty("RAM").unit("GB").min(1).max(128).required(), - integerProperty("SSD").unit("GB").min(25).max(1000).step(25).required(), - integerProperty("HDD").unit("GB").min(0).max(4000).step(250).withDefault(0), - integerProperty("Traffic").unit("GB").min(250).max(10000).step(250).required(), - enumerationProperty("SLA-Infrastructure").values("BASIC", "EXT8H", "EXT4H", "EXT2H").optional() + booleanProperty("active").withDefault(true), + integerProperty("CPUs").min(1).max(32).required(), + integerProperty("RAM").unit("GB").min(1).max(128).required(), + integerProperty("SSD").unit("GB").min(25).max(1000).step(25).required(), + integerProperty("HDD").unit("GB").min(0).max(4000).step(250).withDefault(0), + integerProperty("Traffic").unit("GB").min(250).max(10000).step(250).required(), + enumerationProperty("SLA-Infrastructure").values("BASIC", "EXT8H", "EXT4H", "EXT2H").optional() ); } } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/booking/item/validators/HsPrivateCloudBookingItemValidator.java b/src/main/java/net/hostsharing/hsadminng/hs/booking/item/validators/HsPrivateCloudBookingItemValidator.java index 317f2f0c..e9bf7f83 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/booking/item/validators/HsPrivateCloudBookingItemValidator.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/booking/item/validators/HsPrivateCloudBookingItemValidator.java @@ -7,11 +7,11 @@ class HsPrivateCloudBookingItemValidator extends HsBookingItemEntityValidator { HsPrivateCloudBookingItemValidator() { super( - integerProperty("CPUs").min(4).max(128).required().asTotalLimit(), - integerProperty("RAM").unit("GB").min(4).max(512).required().asTotalLimit(), - integerProperty("SSD").unit("GB").min(100).max(4000).step(25).required().asTotalLimit(), - integerProperty("HDD").unit("GB").min(0).max(16000).step(25).withDefault(0).asTotalLimit(), - integerProperty("Traffic").unit("GB").min(1000).max(40000).step(250).required().asTotalLimit(), + integerProperty("CPUs").min(1).max(128).required().asTotalLimit(), + integerProperty("RAM").unit("GB").min(1).max(512).required().asTotalLimit(), + integerProperty("SSD").unit("GB").min(25).max(4000).step(25).required().asTotalLimit(), + integerProperty("HDD").unit("GB").min(0).max(16000).step(250).withDefault(0).asTotalLimit(), + integerProperty("Traffic").unit("GB").min(250).max(40000).step(250).required().asTotalLimit(), enumerationProperty("SLA-Infrastructure").values("BASIC", "EXT8H", "EXT4H", "EXT2H").withDefault("BASIC") ); } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetEntity.java b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetEntity.java index 164e42d0..ed36c540 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetEntity.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetEntity.java @@ -142,7 +142,6 @@ public class HsHostingAssetEntity implements Stringifyable, RbacObject { dependsOnColumn("bookingItemUuid"), directlyFetchedByDependsOnColumn(), NULLABLE) - .toRole("bookingItem", AGENT).grantPermission(INSERT) .importEntityAlias("parentAsset", HsHostingAssetEntity.class, usingDefaultCase(), dependsOnColumn("parentAssetUuid"), diff --git a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsManagedServerHostingAssetValidator.java b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsManagedServerHostingAssetValidator.java index b2107866..9b3031eb 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsManagedServerHostingAssetValidator.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsManagedServerHostingAssetValidator.java @@ -1,18 +1,48 @@ package net.hostsharing.hsadminng.hs.hosting.asset.validators; +import static net.hostsharing.hsadminng.hs.validation.BooleanProperty.booleanProperty; +import static net.hostsharing.hsadminng.hs.validation.EnumerationProperty.enumerationProperty; import static net.hostsharing.hsadminng.hs.validation.IntegerProperty.integerProperty; class HsManagedServerHostingAssetValidator extends HsHostingAssetEntityValidator { public HsManagedServerHostingAssetValidator() { super( - integerProperty("monit_min_free_ssd").min(1).max(1000).optional(), - integerProperty("monit_min_free_hdd").min(1).max(4000).optional(), - integerProperty("monit_max_ssd_usage").unit("%").min(10).max(100).required(), - integerProperty("monit_max_hdd_usage").unit("%").min(10).max(100).optional(), - integerProperty("monit_max_cpu_usage").unit("%").min(10).max(100).required(), - integerProperty("monit_max_ram_usage").unit("%").min(10).max(100).required() - // TODO: stringProperty("monit_alarm_email").unit("GB").optional() + // monitoring + integerProperty("monit_max_cpu_usage").unit("%").min(10).max(100).withDefault(92), + integerProperty("monit_max_ram_usage").unit("%").min(10).max(100).withDefault(92), + integerProperty("monit_max_ssd_usage").unit("%").min(10).max(100).withDefault(98), + integerProperty("monit_min_free_ssd").min(1).max(1000).withDefault(5), + integerProperty("monit_max_hdd_usage").unit("%").min(10).max(100).withDefault(95), + integerProperty("monit_min_free_hdd").min(1).max(4000).withDefault(10), + // stringProperty("monit_alarm_email").unit("GB").optional() TODO.spec: via Contact? + + // other settings + integerProperty("fastcgi_small").min(0).max(16).withDefault(4), // TODO.spec: check limits + + // database software + booleanProperty("software-pgsql").withDefault(true), + booleanProperty("software-mariadb").withDefault(true), + + // PHP + enumerationProperty("php-default").valuesFromProperties("software-php-").withDefault("8.2"), + booleanProperty("software-php-5.6").withDefault(false), + booleanProperty("software-php-7.0").withDefault(false), + booleanProperty("software-php-7.1").withDefault(false), + booleanProperty("software-php-7.2").withDefault(false), + booleanProperty("software-php-7.3").withDefault(false), + booleanProperty("software-php-7.4").withDefault(true), + booleanProperty("software-php-8.0").withDefault(false), + booleanProperty("software-php-8.1").withDefault(true), + booleanProperty("software-php-8.2").withDefault(false), + + // other software + // TODO.spec: booleanProperty("software-postfix-tls-1.0").withDefault(false), + // TODO.spec: booleanProperty("software-dovecot-tls-1.0").withDefault(false), + booleanProperty("software-clamav").withDefault(true), + booleanProperty("software-collabora").withDefault(false), + booleanProperty("software-libreoffice").withDefault(false), + booleanProperty("software-imagick-ghostscript").withDefault(true) // TODO.spec: default ); } } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/validation/EnumerationProperty.java b/src/main/java/net/hostsharing/hsadminng/hs/validation/EnumerationProperty.java index 23e5ef61..adf2f6d8 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/validation/EnumerationProperty.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/validation/EnumerationProperty.java @@ -7,6 +7,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Map; +import static java.util.Arrays.stream; + @Setter public class EnumerationProperty extends ValidatableProperty { @@ -30,9 +32,27 @@ public class EnumerationProperty extends ValidatableProperty { return this; } + public void deferredInit(final ValidatableProperty[] allProperties) { + if (deferredInit != null) { + if (this.values != null) { + throw new IllegalStateException("property " + toString() + " already values"); + } + this.values = deferredInit.apply(allProperties); + } + } + + public ValidatableProperty valuesFromProperties(final String propertyNamePrefix) { + this.deferredInit = (ValidatableProperty[] allProperties) -> stream(allProperties) + .map(ValidatableProperty::propertyName) + .filter(name -> name.startsWith(propertyNamePrefix)) + .map(name -> name.substring(propertyNamePrefix.length())) + .toArray(String[]::new); + return this; + } + @Override protected void validate(final ArrayList result, final String propValue, final Map props) { - if (Arrays.stream(values).noneMatch(v -> v.equals(propValue))) { + if (stream(values).noneMatch(v -> v.equals(propValue))) { result.add(propertyName + "' is expected to be one of " + Arrays.toString(values) + " but is '" + propValue + "'"); } } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/validation/HsEntityValidator.java b/src/main/java/net/hostsharing/hsadminng/hs/validation/HsEntityValidator.java index c06ed140..cb53e997 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/validation/HsEntityValidator.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/validation/HsEntityValidator.java @@ -16,6 +16,7 @@ public abstract class HsEntityValidator { public HsEntityValidator(final ValidatableProperty... validators) { propertyValidators = validators; + stream(propertyValidators).forEach(p -> p.deferredInit(propertyValidators)); } protected static List enrich(final String prefix, final List messages) { diff --git a/src/main/java/net/hostsharing/hsadminng/hs/validation/ValidatableProperty.java b/src/main/java/net/hostsharing/hsadminng/hs/validation/ValidatableProperty.java index 7795d47d..9e8778e6 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/validation/ValidatableProperty.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/validation/ValidatableProperty.java @@ -31,6 +31,7 @@ public abstract class ValidatableProperty { private final String[] keyOrder; private Boolean required; private T defaultValue; + protected Function[], T[]> deferredInit; private boolean isTotalsValidator = false; @JsonIgnore private List>> asTotalLimitValidators; // TODO.impl: move to BookingItemIntegerProperty @@ -57,6 +58,9 @@ public abstract class ValidatableProperty { return this; } + public void deferredInit(final ValidatableProperty[] allProperties) { + } + public ValidatableProperty asTotalLimit() { isTotalsValidator = true; return this; diff --git a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/validators/HsCloudServerBookingItemValidatorUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/validators/HsCloudServerBookingItemValidatorUnitTest.java index 787b4c08..a5072eca 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/validators/HsCloudServerBookingItemValidatorUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/validators/HsCloudServerBookingItemValidatorUnitTest.java @@ -55,6 +55,7 @@ class HsCloudServerBookingItemValidatorUnitTest { // then assertThat(validator.properties()).map(Map::toString).containsExactlyInAnyOrder( + "{type=boolean, propertyName=active, required=false, defaultValue=true, isTotalsValidator=false}", "{type=integer, propertyName=CPUs, min=1, max=32, required=true, isTotalsValidator=false}", "{type=integer, propertyName=RAM, unit=GB, min=1, max=128, required=true, isTotalsValidator=false}", "{type=integer, propertyName=SSD, unit=GB, min=25, max=1000, step=25, required=true, isTotalsValidator=false}", diff --git a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerAcceptanceTest.java index 2ea554c6..0da54b89 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetControllerAcceptanceTest.java @@ -231,17 +231,17 @@ class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup .when() .post("http://localhost/api/hs/hosting/assets") .then().log().all().assertThat() - .statusCode(201) - .contentType(ContentType.JSON) - .body("", lenientlyEquals(""" - { - "type": "MANAGED_WEBSPACE", - "identifier": "fir90", - "caption": "some new ManagedWebspace in client's ManagedServer", - "config": {} - } - """)) - .header("Location", matchesRegex("http://localhost:[1-9][0-9]*/api/hs/hosting/assets/[^/]*")) + .statusCode(201) + .contentType(ContentType.JSON) + .body("", lenientlyEquals(""" + { + "type": "MANAGED_WEBSPACE", + "identifier": "fir90", + "caption": "some new ManagedWebspace in client's ManagedServer", + "config": {} + } + """)) + .header("Location", matchesRegex("http://localhost:[1-9][0-9]*/api/hs/hosting/assets/[^/]*")) .extract().header("Location"); // @formatter:on // finally, the new asset can be accessed under the generated UUID @@ -258,34 +258,33 @@ class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup RestAssured // @formatter:off .given() - .header("current-user", "superuser-alex@hostsharing.net") - .contentType(ContentType.JSON) - .body(""" - { - "bookingItemUuid": "%s", - "type": "MANAGED_SERVER", - "identifier": "vm1400", - "caption": "some new ManagedServer", - "config": { "monit_max_ssd_usage": 0, "monit_max_cpu_usage": 101, "extra": 42 } - } - """.formatted(givenBookingItem.getUuid())) - .port(port) + .header("current-user", "superuser-alex@hostsharing.net") + .contentType(ContentType.JSON) + .body(""" + { + "bookingItemUuid": "%s", + "type": "MANAGED_SERVER", + "identifier": "vm1400", + "caption": "some new ManagedServer", + "config": { "monit_max_ssd_usage": 0, "monit_max_cpu_usage": 101, "extra": 42 } + } + """.formatted(givenBookingItem.getUuid())) + .port(port) .when() - .post("http://localhost/api/hs/hosting/assets") + .post("http://localhost/api/hs/hosting/assets") .then().log().all().assertThat() - .statusCode(400) - .contentType(ContentType.JSON) - .body("", lenientlyEquals(""" - { - "statusPhrase": "Bad Request", - "message": "[ - <<<'MANAGED_SERVER:vm1400.config.extra' is not expected but is set to '42', - <<<'MANAGED_SERVER:vm1400.config.monit_max_ssd_usage' is expected to be >= 10 but is 0, - <<<'MANAGED_SERVER:vm1400.config.monit_max_cpu_usage' is expected to be <= 100 but is 101, - <<<'MANAGED_SERVER:vm1400.config.monit_max_ram_usage' is required but missing - <<<]" - } - """.replaceAll(" +<<<", ""))); // @formatter:on + .statusCode(400) + .contentType(ContentType.JSON) + .body("", lenientlyEquals(""" + { + "statusPhrase": "Bad Request", + "message": "[ + <<<'MANAGED_SERVER:vm1400.config.extra' is not expected but is set to '42', + <<<'MANAGED_SERVER:vm1400.config.monit_max_cpu_usage' is expected to be <= 100 but is 101, + <<<'MANAGED_SERVER:vm1400.config.monit_max_ssd_usage' is expected to be >= 10 but is 0 + <<<]" + } + """.replaceAll(" +<<<", ""))); // @formatter:on } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetPropsControllerAcceptanceTest.java b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetPropsControllerAcceptanceTest.java index e8195eeb..f25ec366 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetPropsControllerAcceptanceTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetPropsControllerAcceptanceTest.java @@ -55,18 +55,22 @@ class HsHostingAssetPropsControllerAcceptanceTest { [ { "type": "integer", - "propertyName": "monit_min_free_ssd", - "min": 1, - "max": 1000, + "propertyName": "monit_max_cpu_usage", + "unit": "%", + "min": 10, + "max": 100, "required": false, + "defaultValue": 92, "isTotalsValidator": false }, { "type": "integer", - "propertyName": "monit_min_free_hdd", - "min": 1, - "max": 4000, + "propertyName": "monit_max_ram_usage", + "unit": "%", + "min": 10, + "max": 100, "required": false, + "defaultValue": 92, "isTotalsValidator": false }, { @@ -75,7 +79,17 @@ class HsHostingAssetPropsControllerAcceptanceTest { "unit": "%", "min": 10, "max": 100, - "required": true, + "required": false, + "defaultValue": 98, + "isTotalsValidator": false + }, + { + "type": "integer", + "propertyName": "monit_min_free_ssd", + "min": 1, + "max": 1000, + "required": false, + "defaultValue": 5, "isTotalsValidator": false }, { @@ -85,29 +99,152 @@ class HsHostingAssetPropsControllerAcceptanceTest { "min": 10, "max": 100, "required": false, + "defaultValue": 95, "isTotalsValidator": false }, { "type": "integer", - "propertyName": "monit_max_cpu_usage", - "unit": "%", - "min": 10, - "max": 100, - "required": true, + "propertyName": "monit_min_free_hdd", + "min": 1, + "max": 4000, + "required": false, + "defaultValue": 10, "isTotalsValidator": false }, { "type": "integer", - "propertyName": "monit_max_ram_usage", - "unit": "%", - "min": 10, - "max": 100, - "required": true, + "propertyName": "fastcgi_small", + "min": 0, + "max": 16, + "required": false, + "defaultValue": 4, + "isTotalsValidator": false + }, + { + "type": "boolean", + "propertyName": "software-pgsql", + "required": false, + "defaultValue": true, + "isTotalsValidator": false + }, + { + "type": "boolean", + "propertyName": "software-mariadb", + "required": false, + "defaultValue": true, + "isTotalsValidator": false + }, + { + "type": "enumeration", + "propertyName": "php-default", + "values": [ + "5.6", + "7.0", + "7.1", + "7.2", + "7.3", + "7.4", + "8.0", + "8.1", + "8.2" + ], + "required": false, + "defaultValue": "8.2", + "isTotalsValidator": false + }, + { + "type": "boolean", + "propertyName": "software-php-5.6", + "required": false, + "defaultValue": false, + "isTotalsValidator": false + }, + { + "type": "boolean", + "propertyName": "software-php-7.0", + "required": false, + "defaultValue": false, + "isTotalsValidator": false + }, + { + "type": "boolean", + "propertyName": "software-php-7.1", + "required": false, + "defaultValue": false, + "isTotalsValidator": false + }, + { + "type": "boolean", + "propertyName": "software-php-7.2", + "required": false, + "defaultValue": false, + "isTotalsValidator": false + }, + { + "type": "boolean", + "propertyName": "software-php-7.3", + "required": false, + "defaultValue": false, + "isTotalsValidator": false + }, + { + "type": "boolean", + "propertyName": "software-php-7.4", + "required": false, + "defaultValue": true, + "isTotalsValidator": false + }, + { + "type": "boolean", + "propertyName": "software-php-8.0", + "required": false, + "defaultValue": false, + "isTotalsValidator": false + }, + { + "type": "boolean", + "propertyName": "software-php-8.1", + "required": false, + "defaultValue": true, + "isTotalsValidator": false + }, + { + "type": "boolean", + "propertyName": "software-php-8.2", + "required": false, + "defaultValue": false, + "isTotalsValidator": false + }, + { + "type": "boolean", + "propertyName": "software-clamav", + "required": false, + "defaultValue": true, + "isTotalsValidator": false + }, + { + "type": "boolean", + "propertyName": "software-collabora", + "required": false, + "defaultValue": false, + "isTotalsValidator": false + }, + { + "type": "boolean", + "propertyName": "software-libreoffice", + "required": false, + "defaultValue": false, + "isTotalsValidator": false + }, + { + "type": "boolean", + "propertyName": "software-imagick-ghostscript", + "required": false, + "defaultValue": true, "isTotalsValidator": false } ] """)); // @formatter:on } - } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRepositoryIntegrationTest.java b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRepositoryIntegrationTest.java index 480f9416..f4abe06c 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRepositoryIntegrationTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/HsHostingAssetRepositoryIntegrationTest.java @@ -24,8 +24,6 @@ import jakarta.servlet.http.HttpServletRequest; import java.util.Arrays; import java.util.List; import java.util.Map; -import java.util.concurrent.TimeUnit; -import java.util.function.Supplier; import static java.util.Map.entry; import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.CLOUD_SERVER; diff --git a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsHostingAssetEntityValidatorUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsHostingAssetEntityValidatorUnitTest.java index b92e5dc9..ddceba8e 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsHostingAssetEntityValidatorUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsHostingAssetEntityValidatorUnitTest.java @@ -3,7 +3,6 @@ package net.hostsharing.hsadminng.hs.hosting.asset.validators; import net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetEntity; import org.junit.jupiter.api.Test; -import jakarta.validation.ValidationException; import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.MANAGED_SERVER; import static org.assertj.core.api.Assertions.assertThat; @@ -23,10 +22,6 @@ class HsHostingAssetEntityValidatorUnitTest { final var result = catchThrowable( ()-> HsHostingAssetEntityValidatorRegistry.validated(managedServerHostingAssetEntity)); // then - assertThat(result).isInstanceOf(ValidationException.class) - .hasMessageContaining( - "'MANAGED_SERVER:vm1234.config.monit_max_ssd_usage' is required but missing", - "'MANAGED_SERVER:vm1234.config.monit_max_cpu_usage' is required but missing", - "'MANAGED_SERVER:vm1234.config.monit_max_ram_usage' is required but missing"); + assertThat(result).isNull(); // all required properties have defaults } } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsManagedServerHostingAssetValidatorUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsManagedServerHostingAssetValidatorUnitTest.java index b8e75436..d22ef590 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsManagedServerHostingAssetValidatorUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsManagedServerHostingAssetValidatorUnitTest.java @@ -32,7 +32,6 @@ class HsManagedServerHostingAssetValidatorUnitTest { assertThat(result).containsExactlyInAnyOrder( "'MANAGED_SERVER:vm1234.config.monit_max_cpu_usage' is expected to be >= 10 but is 2", "'MANAGED_SERVER:vm1234.config.monit_max_ram_usage' is expected to be <= 100 but is 101", - "'MANAGED_SERVER:vm1234.config.monit_max_ssd_usage' is required but missing", "'MANAGED_SERVER:vm1234.config.monit_max_hdd_usage' is expected to be of type class java.lang.Integer, but is of type 'String'"); } }