amend test data+assertions to new validation rules
This commit is contained in:
parent
0ed7264fc1
commit
4a3af3f6fe
@ -257,7 +257,7 @@ class HsHostingAssetControllerAcceptanceTest extends ContextBasedTestWithCleanup
|
|||||||
.type(HsBookingItemType.DOMAIN_SETUP)
|
.type(HsBookingItemType.DOMAIN_SETUP)
|
||||||
.caption("some temp domain setup booking item")
|
.caption("some temp domain setup booking item")
|
||||||
.resources(Map.ofEntries(
|
.resources(Map.ofEntries(
|
||||||
entry("domainName", "example.org")))
|
entry("domainName", "example.com")))
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -18,17 +18,22 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
|
|
||||||
class HsDomainSetupHostingAssetValidatorUnitTest {
|
class HsDomainSetupHostingAssetValidatorUnitTest {
|
||||||
|
|
||||||
static HsHostingAssetRbacEntity.HsHostingAssetRbacEntityBuilder<?, ?> validEntityBuilder() {
|
|
||||||
|
static HsHostingAssetRbacEntity.HsHostingAssetRbacEntityBuilder<?, ?> validEntityBuilder(final String domainName) {
|
||||||
final HsBookingItemRealEntity bookingItem = HsBookingItemRealEntity.builder()
|
final HsBookingItemRealEntity bookingItem = HsBookingItemRealEntity.builder()
|
||||||
.type(HsBookingItemType.DOMAIN_SETUP)
|
.type(HsBookingItemType.DOMAIN_SETUP)
|
||||||
.resources(Map.ofEntries(
|
.resources(Map.ofEntries(
|
||||||
Map.entry("domainName", "example.org")
|
Map.entry("domainName", domainName)
|
||||||
))
|
))
|
||||||
.build();
|
.build();
|
||||||
return HsHostingAssetRbacEntity.builder()
|
return HsHostingAssetRbacEntity.builder()
|
||||||
.type(DOMAIN_SETUP)
|
.type(DOMAIN_SETUP)
|
||||||
.bookingItem(bookingItem)
|
.bookingItem(bookingItem)
|
||||||
.identifier("example.org");
|
.identifier(domainName);
|
||||||
|
}
|
||||||
|
|
||||||
|
static HsHostingAssetRbacEntity.HsHostingAssetRbacEntityBuilder<?, ?> validEntityBuilder() {
|
||||||
|
return validEntityBuilder("example.org");
|
||||||
}
|
}
|
||||||
|
|
||||||
enum InvalidDomainNameIdentifier {
|
enum InvalidDomainNameIdentifier {
|
||||||
@ -57,13 +62,13 @@ class HsDomainSetupHostingAssetValidatorUnitTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result).containsExactly(
|
assertThat(result).containsExactly(
|
||||||
"'identifier' expected to match '^((?!-)[A-Za-z0-9-]{1,63}(?<!-)\\.)+[A-Za-z]{2,12}', but is '"+testCase.domainName+"'"
|
"'identifier' expected to match 'example.org', but is '"+testCase.domainName+"'"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
enum ValidDomainNameIdentifier {
|
enum ValidDomainNameIdentifier {
|
||||||
SIMPLE("exampe.org"),
|
SIMPLE("example.org"),
|
||||||
MAX_LENGTH("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz01234568901.de"),
|
MAX_LENGTH("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz01234568901.de"),
|
||||||
WITH_DASH("example-test.com"),
|
WITH_DASH("example-test.com"),
|
||||||
SUBDOMAIN("test.example.com");
|
SUBDOMAIN("test.example.com");
|
||||||
@ -79,7 +84,7 @@ class HsDomainSetupHostingAssetValidatorUnitTest {
|
|||||||
@EnumSource(ValidDomainNameIdentifier.class)
|
@EnumSource(ValidDomainNameIdentifier.class)
|
||||||
void acceptsValidIdentifier(final ValidDomainNameIdentifier testCase) {
|
void acceptsValidIdentifier(final ValidDomainNameIdentifier testCase) {
|
||||||
// given
|
// given
|
||||||
final var givenEntity = validEntityBuilder().identifier(testCase.domainName).build();
|
final var givenEntity = validEntityBuilder(testCase.domainName).identifier(testCase.domainName).build();
|
||||||
final var validator = HostingAssetEntityValidatorRegistry.forType(givenEntity.getType());
|
final var validator = HostingAssetEntityValidatorRegistry.forType(givenEntity.getType());
|
||||||
|
|
||||||
// when
|
// when
|
||||||
|
Loading…
Reference in New Issue
Block a user