diff --git a/src/main/java/net/hostsharing/hsadminng/hs/booking/item/validators/HsBookingItemEntityValidator.java b/src/main/java/net/hostsharing/hsadminng/hs/booking/item/validators/HsBookingItemEntityValidator.java index 2e67a37c..d7e9fd1b 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/booking/item/validators/HsBookingItemEntityValidator.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/booking/item/validators/HsBookingItemEntityValidator.java @@ -56,12 +56,12 @@ public class HsBookingItemEntityValidator extends HsEntityValidator (maxValue * propDef.thresholdPercentage() / 100) - ? "total %s is %d%s exceeds max total %s %d%s, which is above threshold of %d%%" + ? "%s' total is %d%s, thus exceeds max total %s %d%s, which is above threshold of %d%%" .formatted(propName, totalValue, propUnit, propName, maxValue, propUnit, propDef.thresholdPercentage()) : null; } else { return totalValue > maxValue - ? "total %s is %d%s exceeds max total %s %d%s" + ? "%s' total is %d%s, thus exceeds max total %s %d%s" .formatted(propName, totalValue, propUnit, propName, maxValue, propUnit) : null; } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsHostingAssetEntityValidator.java b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsHostingAssetEntityValidator.java index 44d5fbfe..0757a3e3 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsHostingAssetEntityValidator.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsHostingAssetEntityValidator.java @@ -60,7 +60,7 @@ public class HsHostingAssetEntityValidator extends HsEntityValidator maxValue - ? "total %s is %d%s exceeds max total %s %d%s".formatted( + ? "%s' total is %d%s, thus exceeds max total %s %d%s".formatted( propName, totalValue, propUnit, propName, maxValue, propUnit) : null; } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/validation/BooleanProperty.java b/src/main/java/net/hostsharing/hsadminng/hs/validation/BooleanProperty.java index 416c65f5..9d664683 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/validation/BooleanProperty.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/validation/BooleanProperty.java @@ -33,7 +33,7 @@ public class BooleanProperty extends ValidatableProperty { if (falseIf != null && propValue) { final Object referencedValue = props.get(falseIf.getKey()); if (Objects.equals(referencedValue, falseIf.getValue())) { - result.add(propertyName + " is expected to be false because " + + result.add(propertyName + "' is expected to be false because " + falseIf.getKey() + "=" + referencedValue + " but is " + propValue); } } 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 9476e5bf..23e5ef61 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/validation/EnumerationProperty.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/validation/EnumerationProperty.java @@ -33,7 +33,7 @@ public class EnumerationProperty extends ValidatableProperty { @Override protected void validate(final ArrayList result, final String propValue, final Map props) { if (Arrays.stream(values).noneMatch(v -> v.equals(propValue))) { - result.add(propertyName + " is expected to be one of " + Arrays.toString(values) + " but is '" + 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 a8d24a3f..0244df74 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/validation/HsEntityValidator.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/validation/HsEntityValidator.java @@ -22,7 +22,8 @@ public abstract class HsEntityValidator { protected static List enrich(final String prefix, final List messages) { return messages.stream() - .map(message -> prefix + "." + message) + // FIXME: this is a bit hacky, I need to find the right place to add the prefix + .map(message -> message.startsWith("'") ? message : ("'" + prefix + "." + message)) .toList(); } @@ -42,7 +43,7 @@ public abstract class HsEntityValidator { final var result = new ArrayList(); properties.keySet().forEach( givenPropName -> { if (stream(propertyValidators).map(pv -> pv.propertyName).noneMatch(propName -> propName.equals(givenPropName))) { - result.add(givenPropName + " is not expected but is set to '" + properties.get(givenPropName) + "'"); + result.add(givenPropName + "' is not expected but is set to '" + properties.get(givenPropName) + "'"); } }); stream(propertyValidators).forEach(pv -> { diff --git a/src/main/java/net/hostsharing/hsadminng/hs/validation/IntegerProperty.java b/src/main/java/net/hostsharing/hsadminng/hs/validation/IntegerProperty.java index 27661ff0..a1658ff9 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/validation/IntegerProperty.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/validation/IntegerProperty.java @@ -39,13 +39,13 @@ public class IntegerProperty extends ValidatableProperty { @Override protected void validate(final ArrayList result, final Integer propValue, final Map props) { if (min != null && propValue < min) { - result.add(propertyName + " is expected to be >= " + min + " but is " + propValue); + result.add(propertyName + "' is expected to be >= " + min + " but is " + propValue); } if (max != null && propValue > max) { - result.add(propertyName + " is expected to be <= " + max + " but is " + propValue); + result.add(propertyName + "' is expected to be <= " + max + " but is " + propValue); } if (step != null && propValue % step != 0) { - result.add(propertyName + " is expected to be multiple of " + step + " but is " + propValue); + result.add(propertyName + "' is expected to be multiple of " + step + " but is " + propValue); } } 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 ae69f37e..7795d47d 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/validation/ValidatableProperty.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/validation/ValidatableProperty.java @@ -92,7 +92,7 @@ public abstract class ValidatableProperty { final var propValue = props.get(propertyName); if (propValue == null) { if (required) { - result.add(propertyName + " is required but missing"); + result.add(propertyName + "' is required but missing"); } } if (propValue != null){ @@ -100,7 +100,7 @@ public abstract class ValidatableProperty { //noinspection unchecked validate(result, (T) propValue, props); } else { - result.add(propertyName + " is expected to be of type " + type + ", " + + result.add(propertyName + "' is expected to be of type " + type + ", " + "but is of type '" + propValue.getClass().getSimpleName() + "'"); } } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/validators/HsBookingItemEntityValidatorUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/validators/HsBookingItemEntityValidatorUnitTest.java index 398e5330..0552e851 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/validators/HsBookingItemEntityValidatorUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/validators/HsBookingItemEntityValidatorUnitTest.java @@ -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 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 6a0f287e..cf10e3f9 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 @@ -45,7 +45,7 @@ class HsCloudServerBookingItemValidatorUnitTest { final var result = HsBookingItemEntityValidatorRegistry.doValidate(cloudServerBookingItemEntity); // then - assertThat(result).containsExactly("D-12345:Test-Project:Test-Server.resources.SLA-EMail is not expected but is set to 'true'"); + assertThat(result).containsExactly("'D-12345:Test-Project:Test-Server.resources.SLA-EMail' is not expected but is set to 'true'"); } @Test @@ -109,10 +109,10 @@ class HsCloudServerBookingItemValidatorUnitTest { // then assertThat(result).containsExactlyInAnyOrder( - "D-12345:Test-Project:Test Cloud-Server.parentItem.total CPUs is 5 exceeds max total CPUs 4", - "D-12345:Test-Project:Test Cloud-Server.parentItem.total RAM is 30 GB exceeds max total RAM 20 GB", - "D-12345:Test-Project:Test Cloud-Server.parentItem.total SSD is 150 GB exceeds max total SSD 100 GB", - "D-12345:Test-Project:Test Cloud-Server.parentItem.total Traffic is 5500 GB exceeds max total Traffic 5000 GB" + "'D-12345:Test-Project:Test Cloud-Server.parentItem.CPUs' total is 5, thus exceeds max total CPUs 4", + "'D-12345:Test-Project:Test Cloud-Server.parentItem.RAM' total is 30 GB, thus exceeds max total RAM 20 GB", + "'D-12345:Test-Project:Test Cloud-Server.parentItem.SSD' total is 150 GB, thus exceeds max total SSD 100 GB", + "'D-12345:Test-Project:Test Cloud-Server.parentItem.Traffic' total is 5500 GB, thus exceeds max total Traffic 5000 GB" ); } } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/validators/HsManagedServerBookingItemValidatorUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/validators/HsManagedServerBookingItemValidatorUnitTest.java index 5d915722..994f4ec9 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/validators/HsManagedServerBookingItemValidatorUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/validators/HsManagedServerBookingItemValidatorUnitTest.java @@ -53,7 +53,7 @@ class HsManagedServerBookingItemValidatorUnitTest { final var result = HsBookingItemEntityValidatorRegistry.doValidate(mangedServerBookingItemEntity); // then - assertThat(result).containsExactly("D-12345:Test-Project:null.resources.SLA-EMail is expected to be false because SLA-Platform=BASIC but is true"); + assertThat(result).containsExactly("'D-12345:Test-Project:null.resources.SLA-EMail' is expected to be false because SLA-Platform=BASIC but is true"); } @Test @@ -120,10 +120,10 @@ class HsManagedServerBookingItemValidatorUnitTest { // then assertThat(result).containsExactlyInAnyOrder( - "D-12345:Test-Project:null.parentItem.total CPUs is 5 exceeds max total CPUs 4", - "D-12345:Test-Project:null.parentItem.total RAM is 30 GB exceeds max total RAM 20 GB", - "D-12345:Test-Project:null.parentItem.total SSD is 150 GB exceeds max total SSD 100 GB", - "D-12345:Test-Project:null.parentItem.total Traffic is 5500 GB exceeds max total Traffic 5000 GB" + "'D-12345:Test-Project:null.parentItem.CPUs' total is 5, thus exceeds max total CPUs 4", + "'D-12345:Test-Project:null.parentItem.RAM' total is 30 GB, thus exceeds max total RAM 20 GB", + "'D-12345:Test-Project:null.parentItem.SSD' total is 150 GB, thus exceeds max total SSD 100 GB", + "'D-12345:Test-Project:null.parentItem.Traffic' total is 5500 GB, thus exceeds max total Traffic 5000 GB" ); } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/validators/HsManagedWebspaceBookingItemValidatorUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/validators/HsManagedWebspaceBookingItemValidatorUnitTest.java index c8db8a6f..dd9081ee 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/validators/HsManagedWebspaceBookingItemValidatorUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/validators/HsManagedWebspaceBookingItemValidatorUnitTest.java @@ -41,10 +41,10 @@ class HsManagedWebspaceBookingItemValidatorUnitTest { // then assertThat(result).containsExactlyInAnyOrder( - "D-12345:Test-Project:Test Managed-Webspace.resources.CPUs is not expected but is set to '2'", - "D-12345:Test-Project:Test Managed-Webspace.resources.RAM is not expected but is set to '25'", - "D-12345:Test-Project:Test Managed-Webspace.resources.SSD is required but missing", - "D-12345:Test-Project:Test Managed-Webspace.resources.SLA-EMail is not expected but is set to 'true'" + "'D-12345:Test-Project:Test Managed-Webspace.resources.CPUs' is not expected but is set to '2'", + "'D-12345:Test-Project:Test Managed-Webspace.resources.RAM' is not expected but is set to '25'", + "'D-12345:Test-Project:Test Managed-Webspace.resources.SSD' is required but missing", + "'D-12345:Test-Project:Test Managed-Webspace.resources.SLA-EMail' is not expected but is set to 'true'" ); } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/validators/HsPrivateCloudBookingItemValidatorTest.java b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/validators/HsPrivateCloudBookingItemValidatorTest.java index 40610fad..974f9d42 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/booking/item/validators/HsPrivateCloudBookingItemValidatorTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/booking/item/validators/HsPrivateCloudBookingItemValidatorTest.java @@ -91,10 +91,10 @@ class HsPrivateCloudBookingItemValidatorTest { // then assertThat(result).containsExactlyInAnyOrder( - "total CPUs is 5 exceeds max total CPUs 4", - "total RAM is 30 GB exceeds max total RAM 20 GB", - "total SSD is 150 GB exceeds max total SSD 100 GB", - "total Traffic is 5500 GB exceeds max total Traffic 5000 GB" + "CPUs' total is 5, thus exceeds max total CPUs 4", + "RAM' total is 30 GB, thus exceeds max total RAM 20 GB", + "SSD' total is 150 GB, thus exceeds max total SSD 100 GB", + "Traffic' total is 5500 GB, thus exceeds max total Traffic 5000 GB" ); } 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 3dc0a615..a2f1650c 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 @@ -279,10 +279,10 @@ class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup { "statusPhrase": "Bad Request", "message": "[ - <<= 10 but is 0, - <<= 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 @@ -334,7 +334,7 @@ class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup { "statusPhrase": "Bad Request", "message": "[ - <<= 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_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'"); } } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsManagedWebspaceHostingAssetValidatorUnitTest.java b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsManagedWebspaceHostingAssetValidatorUnitTest.java index 6e530bb3..d2e74894 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsManagedWebspaceHostingAssetValidatorUnitTest.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/hosting/asset/validators/HsManagedWebspaceHostingAssetValidatorUnitTest.java @@ -73,7 +73,7 @@ class HsManagedWebspaceHostingAssetValidatorUnitTest { final var result = validator.validate(mangedWebspaceHostingAssetEntity); // then - assertThat(result).containsExactly("MANAGED_WEBSPACE:abc00.config.unknown is not expected but is set to 'some value'"); + assertThat(result).containsExactly("'MANAGED_WEBSPACE:abc00.config.unknown' is not expected but is set to 'some value'"); } @Test