amending other tests to improved error messages

This commit is contained in:
Michael Hoennig 2024-06-19 18:10:54 +02:00
parent c6e0bd8606
commit c565606edf
4 changed files with 30 additions and 21 deletions

View File

@ -60,7 +60,7 @@ public class HsBookingItemEntityValidator extends HsEntityValidator<HsBookingIte
final var totalValue = ofNullable(bookingItem.getSubBookingItems()).orElse(emptyList()) final var totalValue = ofNullable(bookingItem.getSubBookingItems()).orElse(emptyList())
.stream() .stream()
.map(subItem -> propDef.getValue(subItem.getResources())) .map(subItem -> propDef.getValue(subItem.getResources()))
.map(v -> v instanceof Boolean ? BooleanUtils.toInteger((Boolean)v) : v) // FIXME: remove? .map(HsBookingItemEntityValidator::convertBooleanToInteger)
.map(HsBookingItemEntityValidator::toIntegerWithDefault0) .map(HsBookingItemEntityValidator::toIntegerWithDefault0)
.reduce(0, Integer::sum); .reduce(0, Integer::sum);
final var maxValue = getIntegerValueWithDefault0(propDef, bookingItem.getResources()); final var maxValue = getIntegerValueWithDefault0(propDef, bookingItem.getResources());
@ -76,4 +76,8 @@ public class HsBookingItemEntityValidator extends HsEntityValidator<HsBookingIte
: null; : null;
} }
} }
private static Object convertBooleanToInteger(final Object value) {
return value instanceof Boolean ? BooleanUtils.toInteger((Boolean)value) : value;
}
} }

View File

@ -110,10 +110,10 @@ class HsCloudServerBookingItemValidatorUnitTest {
// then // then
assertThat(result).containsExactlyInAnyOrder( assertThat(result).containsExactlyInAnyOrder(
"'D-12345:Test-Project:Test Cloud.resources.CPUs' maximum total is 4, but actual total CPUs 5", "'D-12345:Test-Project:Test Cloud.resources.CPUs' maximum total is 4, but actual total CPUs is 5",
"'D-12345:Test-Project:Test Cloud.resources.RAM' maximum total is 20 GB, but actual total RAM 30 GB", "'D-12345:Test-Project:Test Cloud.resources.RAM' maximum total is 20 GB, but actual total RAM is 30 GB",
"'D-12345:Test-Project:Test Cloud.resources.SSD' maximum total is 100 GB, but actual total SSD 150 GB", "'D-12345:Test-Project:Test Cloud.resources.SSD' maximum total is 100 GB, but actual total SSD is 150 GB",
"'D-12345:Test-Project:Test Cloud.resources.Traffic' maximum total is 5000 GB, but actual total Traffic 5500 GB" "'D-12345:Test-Project:Test Cloud.resources.Traffic' maximum total is 5000 GB, but actual total Traffic is 5500 GB"
); );
} }
} }

View File

@ -120,10 +120,10 @@ class HsManagedServerBookingItemValidatorUnitTest {
// then // then
assertThat(result).containsExactlyInAnyOrder( assertThat(result).containsExactlyInAnyOrder(
"'D-12345:Test-Project:null.resources.CPUs' maximum total is 4, but actual total CPUs 5", "'D-12345:Test-Project:null.resources.CPUs' maximum total is 4, but actual total CPUs is 5",
"'D-12345:Test-Project:null.resources.RAM' maximum total is 20 GB, but actual total RAM 30 GB", "'D-12345:Test-Project:null.resources.RAM' maximum total is 20 GB, but actual total RAM is 30 GB",
"'D-12345:Test-Project:null.resources.SSD' maximum total is 100 GB, but actual total SSD 150 GB", "'D-12345:Test-Project:null.resources.SSD' maximum total is 100 GB, but actual total SSD is 150 GB",
"'D-12345:Test-Project:null.resources.Traffic' maximum total is 5000 GB, but actual total Traffic 5500 GB" "'D-12345:Test-Project:null.resources.Traffic' maximum total is 5000 GB, but actual total Traffic is 5500 GB"
); );
} }

View File

@ -111,15 +111,6 @@ class HsHostingAssetPropsControllerAcceptanceTest {
"defaultValue": 10, "defaultValue": 10,
"isTotalsValidator": false "isTotalsValidator": false
}, },
{
"type": "integer",
"propertyName": "fastcgi_small",
"min": 0,
"max": 16,
"required": false,
"defaultValue": 4,
"isTotalsValidator": false
},
{ {
"type": "boolean", "type": "boolean",
"propertyName": "software-pgsql", "propertyName": "software-pgsql",
@ -205,13 +196,27 @@ class HsHostingAssetPropsControllerAcceptanceTest {
"type": "boolean", "type": "boolean",
"propertyName": "software-php-8.1", "propertyName": "software-php-8.1",
"required": false, "required": false,
"defaultValue": true, "defaultValue": false,
"isTotalsValidator": false "isTotalsValidator": false
}, },
{ {
"type": "boolean", "type": "boolean",
"propertyName": "software-php-8.2", "propertyName": "software-php-8.2",
"required": false, "required": false,
"defaultValue": true,
"isTotalsValidator": false
},
{
"type": "boolean",
"propertyName": "software-postfix-tls-1.0",
"required": false,
"defaultValue": false,
"isTotalsValidator": false
},
{
"type": "boolean",
"propertyName": "software-dovecot-tls-1.0",
"required": false,
"defaultValue": false, "defaultValue": false,
"isTotalsValidator": false "isTotalsValidator": false
}, },
@ -238,9 +243,9 @@ class HsHostingAssetPropsControllerAcceptanceTest {
}, },
{ {
"type": "boolean", "type": "boolean",
"propertyName": "software-imagick-ghostscript", "propertyName": "software-imagemagick-ghostscript",
"required": false, "required": false,
"defaultValue": true, "defaultValue": false,
"isTotalsValidator": false "isTotalsValidator": false
} }
] ]