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