fix failing tests
This commit is contained in:
parent
afa7c9d0f7
commit
2f5d36becc
@ -58,7 +58,7 @@ class HsHostingAssetEntityUnitTest {
|
||||
void toStringContainsAllPropertiesAndResourcesSortedByKey() {
|
||||
|
||||
assertThat(givenWebspace.toString()).isEqualTo(
|
||||
"HsHostingAssetEntity(MANAGED_WEBSPACE, xyz00, some managed webspace, MANAGED_SERVER:vm1234, D-1000100:test project:test booking item, { CPUs: 2, HDD-storage: 2048, SSD-storage: 512 })");
|
||||
"HsHostingAssetEntity(MANAGED_WEBSPACE, xyz00, some managed webspace, MANAGED_SERVER:vm1234, D-1234500:test project:test booking item, { CPUs: 2, HDD-storage: 2048, SSD-storage: 512 })");
|
||||
|
||||
assertThat(givenUnixUser.toString()).isEqualTo(
|
||||
"HsHostingAssetEntity(UNIX_USER, xyz00-web, some unix-user, MANAGED_WEBSPACE:xyz00, { HDD-hard-quota: 512, HDD-soft-quota: 256, SSD-hard-quota: 256, SSD-soft-quota: 128 })");
|
||||
|
@ -18,10 +18,7 @@ class HsCloudServerHostingAssetValidatorUnitTest {
|
||||
final var cloudServerHostingAssetEntity = HsHostingAssetEntity.builder()
|
||||
.type(CLOUD_SERVER)
|
||||
.config(Map.ofEntries(
|
||||
entry("RAM", 2000),
|
||||
entry("SSD", 256),
|
||||
entry("Traffic", "250"),
|
||||
entry("SLA-Platform", "xxx")
|
||||
entry("RAM", 2000)
|
||||
))
|
||||
.build();
|
||||
final var validator = forType(cloudServerHostingAssetEntity.getType());
|
||||
@ -31,12 +28,7 @@ class HsCloudServerHostingAssetValidatorUnitTest {
|
||||
final var result = validator.validate(cloudServerHostingAssetEntity);
|
||||
|
||||
// then
|
||||
assertThat(result).containsExactlyInAnyOrder(
|
||||
"'config.SLA-Platform' is not expected but is set to 'xxx'",
|
||||
"'config.CPUs' is required but missing",
|
||||
"'config.RAM' is expected to be <= 128 but is 2000",
|
||||
"'config.SSD' is expected to be multiple of 25 but is 256",
|
||||
"'config.Traffic' is expected to be of type class java.lang.Integer, but is of type 'String'");
|
||||
assertThat(result).containsExactly("'config.RAM' is not expected but is set to '2000'");
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -45,11 +37,6 @@ class HsCloudServerHostingAssetValidatorUnitTest {
|
||||
final var validator = forType(CLOUD_SERVER);
|
||||
|
||||
// then
|
||||
assertThat(validator.properties()).map(Map::toString).containsExactlyInAnyOrder(
|
||||
"{type=integer, propertyName=CPUs, required=true, unit=null, min=1, max=32, step=null}",
|
||||
"{type=integer, propertyName=RAM, required=true, unit=GB, min=1, max=128, step=null}",
|
||||
"{type=integer, propertyName=SSD, required=true, unit=GB, min=25, max=1000, step=25}",
|
||||
"{type=integer, propertyName=HDD, required=false, unit=GB, min=0, max=4000, step=250}",
|
||||
"{type=integer, propertyName=Traffic, required=true, unit=GB, min=250, max=10000, step=250}");
|
||||
assertThat(validator.properties()).map(Map::toString).isEmpty();
|
||||
}
|
||||
}
|
||||
|
@ -18,10 +18,9 @@ class HsManagedServerHostingAssetValidatorUnitTest {
|
||||
final var mangedWebspaceHostingAssetEntity = HsHostingAssetEntity.builder()
|
||||
.type(MANAGED_SERVER)
|
||||
.config(Map.ofEntries(
|
||||
entry("RAM", 2000),
|
||||
entry("SSD", 256),
|
||||
entry("Traffic", "250"),
|
||||
entry("SLA-Platform", "xxx")
|
||||
entry("monit_max_hdd_usage", "90"),
|
||||
entry("monit_max_cpu_usage", 2),
|
||||
entry("monit_max_ram_usage", 101)
|
||||
))
|
||||
.build();
|
||||
final var validator = forType(mangedWebspaceHostingAssetEntity.getType());
|
||||
@ -31,10 +30,9 @@ class HsManagedServerHostingAssetValidatorUnitTest {
|
||||
|
||||
// then
|
||||
assertThat(result).containsExactlyInAnyOrder(
|
||||
"'config.SLA-Platform' is not expected but is set to 'xxx'",
|
||||
"'config.CPUs' is required but missing",
|
||||
"'config.RAM' is expected to be <= 128 but is 2000",
|
||||
"'config.SSD' is expected to be multiple of 25 but is 256",
|
||||
"'config.Traffic' is expected to be of type class java.lang.Integer, but is of type 'String'");
|
||||
"'config.monit_max_ssd_usage' is required but missing",
|
||||
"'config.monit_max_hdd_usage' is expected to be of type class java.lang.Integer, but is of type 'String'",
|
||||
"'config.monit_max_cpu_usage' is expected to be >= 10 but is 2",
|
||||
"'config.monit_max_ram_usage' is expected to be <= 100 but is 101");
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static java.util.Collections.emptyMap;
|
||||
import static java.util.Map.entry;
|
||||
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.MANAGED_SERVER;
|
||||
import static net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType.MANAGED_WEBSPACE;
|
||||
@ -36,11 +35,6 @@ class HsManagedWebspaceHostingAssetValidatorUnitTest {
|
||||
.type(MANAGED_WEBSPACE)
|
||||
.parentAsset(mangedServerAssetEntity)
|
||||
.identifier("xyz00")
|
||||
.config(Map.ofEntries(
|
||||
entry("HDD", 0),
|
||||
entry("SSD", 1),
|
||||
entry("Traffic", 10)
|
||||
))
|
||||
.build();
|
||||
|
||||
// when
|
||||
@ -50,28 +44,6 @@ class HsManagedWebspaceHostingAssetValidatorUnitTest {
|
||||
assertThat(result).containsExactly("'identifier' expected to match '^abc[0-9][0-9]$', but is 'xyz00'");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void validatesMissingProperties() {
|
||||
// given
|
||||
final var validator = HsHostingAssetEntityValidators.forType(MANAGED_WEBSPACE);
|
||||
final var mangedWebspaceHostingAssetEntity = HsHostingAssetEntity.builder()
|
||||
.type(MANAGED_WEBSPACE)
|
||||
.parentAsset(mangedServerAssetEntity)
|
||||
.identifier("abc00")
|
||||
.config(emptyMap())
|
||||
.build();
|
||||
|
||||
// when
|
||||
final var result = validator.validate(mangedWebspaceHostingAssetEntity);
|
||||
|
||||
// then
|
||||
assertThat(result).containsExactlyInAnyOrder(
|
||||
"'config.SSD' is required but missing",
|
||||
"'config.Traffic' is required but missing"
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void validatesUnknownProperties() {
|
||||
// given
|
||||
@ -81,9 +53,6 @@ class HsManagedWebspaceHostingAssetValidatorUnitTest {
|
||||
.parentAsset(mangedServerAssetEntity)
|
||||
.identifier("abc00")
|
||||
.config(Map.ofEntries(
|
||||
entry("HDD", 0),
|
||||
entry("SSD", 1),
|
||||
entry("Traffic", 10),
|
||||
entry("unknown", "some value")
|
||||
))
|
||||
.build();
|
||||
@ -96,18 +65,13 @@ class HsManagedWebspaceHostingAssetValidatorUnitTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void validatesValidProperties() {
|
||||
void validatesValidEntity() {
|
||||
// given
|
||||
final var validator = HsHostingAssetEntityValidators.forType(MANAGED_WEBSPACE);
|
||||
final var mangedWebspaceHostingAssetEntity = HsHostingAssetEntity.builder()
|
||||
.type(MANAGED_WEBSPACE)
|
||||
.parentAsset(mangedServerAssetEntity)
|
||||
.identifier("abc00")
|
||||
.config(Map.ofEntries(
|
||||
entry("HDD", 200),
|
||||
entry("SSD", 25),
|
||||
entry("Traffic", 250)
|
||||
))
|
||||
.build();
|
||||
|
||||
// when
|
||||
|
Loading…
Reference in New Issue
Block a user