diff --git a/magnolia-builders/src/main/java/com/merkle/oss/magnolia/definition/builder/simple/AbstractConfiguredFieldDefinitionBuilder.java b/magnolia-builders/src/main/java/com/merkle/oss/magnolia/definition/builder/simple/AbstractConfiguredFieldDefinitionBuilder.java index e336a51..d59f72a 100644 --- a/magnolia-builders/src/main/java/com/merkle/oss/magnolia/definition/builder/simple/AbstractConfiguredFieldDefinitionBuilder.java +++ b/magnolia-builders/src/main/java/com/merkle/oss/magnolia/definition/builder/simple/AbstractConfiguredFieldDefinitionBuilder.java @@ -35,6 +35,7 @@ public abstract class AbstractConfiguredFieldDefinitionBuilder> converterClass; + @Nullable private List validators; protected AbstractConfiguredFieldDefinitionBuilder(final Provider factory) { diff --git a/magnolia-builders/src/main/java/com/merkle/oss/magnolia/definition/builder/validator/AbstractConfiguredFieldValidatorDefinitionBuilder.java b/magnolia-builders/src/main/java/com/merkle/oss/magnolia/definition/builder/validator/AbstractConfiguredFieldValidatorDefinitionBuilder.java new file mode 100644 index 0000000..d08516a --- /dev/null +++ b/magnolia-builders/src/main/java/com/merkle/oss/magnolia/definition/builder/validator/AbstractConfiguredFieldValidatorDefinitionBuilder.java @@ -0,0 +1,35 @@ +package com.merkle.oss.magnolia.definition.builder.validator; + +import info.magnolia.ui.field.ConfiguredFieldValidatorDefinition; + +import javax.annotation.Nullable; +import javax.inject.Provider; +import java.util.Optional; + +public abstract class AbstractConfiguredFieldValidatorDefinitionBuilder> { + private final Provider factory; + + @Nullable + private String errorMessage; + + protected AbstractConfiguredFieldValidatorDefinitionBuilder(final Provider factory) { + this.factory = factory; + } + + public B errorMessage(final String errorMessage) { + this.errorMessage = errorMessage; + return self(); + } + + @SuppressWarnings("unchecked") + protected B self() { + return (B) this; + } + + protected D build(final String name) { + final D definition = factory.get(); + definition.setName(name); + Optional.ofNullable(errorMessage).ifPresent(definition::setErrorMessage); + return definition; + } +} diff --git a/magnolia-builders/src/main/java/com/merkle/oss/magnolia/definition/builder/validator/EmailValidatorDefinitionBuilder.java b/magnolia-builders/src/main/java/com/merkle/oss/magnolia/definition/builder/validator/EmailValidatorDefinitionBuilder.java new file mode 100644 index 0000000..76bd13c --- /dev/null +++ b/magnolia-builders/src/main/java/com/merkle/oss/magnolia/definition/builder/validator/EmailValidatorDefinitionBuilder.java @@ -0,0 +1,17 @@ +package com.merkle.oss.magnolia.definition.builder.validator; + +import info.magnolia.ui.field.EmailValidatorDefinition; + +public class EmailValidatorDefinitionBuilder extends AbstractConfiguredFieldValidatorDefinitionBuilder{ + + public EmailValidatorDefinitionBuilder() { + super(EmailValidatorDefinition::new); + } + + public EmailValidatorDefinition build() { + return build("emailValidator"); + } + public EmailValidatorDefinition build(final String name) { + return super.build(name); + } +} diff --git a/magnolia-builders/src/main/java/com/merkle/oss/magnolia/definition/builder/validator/NodeNameValidatorDefinitionBuilder.java b/magnolia-builders/src/main/java/com/merkle/oss/magnolia/definition/builder/validator/NodeNameValidatorDefinitionBuilder.java new file mode 100644 index 0000000..4d832d1 --- /dev/null +++ b/magnolia-builders/src/main/java/com/merkle/oss/magnolia/definition/builder/validator/NodeNameValidatorDefinitionBuilder.java @@ -0,0 +1,40 @@ +package com.merkle.oss.magnolia.definition.builder.validator; + +import info.magnolia.ui.editor.validator.NodeNameValidatorDefinition; +import info.magnolia.ui.editor.validator.NodeNameValidatorDefinition.Mode; +import info.magnolia.ui.field.RegexpValidatorDefinition; + +import javax.annotation.Nullable; +import java.util.Optional; + +public class NodeNameValidatorDefinitionBuilder extends AbstractConfiguredFieldValidatorDefinitionBuilder{ + + @Nullable + private String pattern; + @Nullable + private Mode mode; + + public NodeNameValidatorDefinitionBuilder() { + super(NodeNameValidatorDefinition::new); + } + + public NodeNameValidatorDefinitionBuilder pattern(final String pattern) { + this.pattern = pattern; + return self(); + } + + public NodeNameValidatorDefinitionBuilder mode(final Mode mode) { + this.mode = mode; + return self(); + } + + public NodeNameValidatorDefinition build() { + return build("nodeNameValidator"); + } + public NodeNameValidatorDefinition build(final String name) { + final NodeNameValidatorDefinition definition = super.build(name); + Optional.ofNullable(mode).ifPresent(definition::setMode); + Optional.ofNullable(pattern).ifPresent(definition::setPattern); + return definition; + } +} \ No newline at end of file diff --git a/magnolia-builders/src/main/java/com/merkle/oss/magnolia/definition/builder/validator/RegexpValidatorDefinitionBuilder.java b/magnolia-builders/src/main/java/com/merkle/oss/magnolia/definition/builder/validator/RegexpValidatorDefinitionBuilder.java new file mode 100644 index 0000000..3bbc698 --- /dev/null +++ b/magnolia-builders/src/main/java/com/merkle/oss/magnolia/definition/builder/validator/RegexpValidatorDefinitionBuilder.java @@ -0,0 +1,30 @@ +package com.merkle.oss.magnolia.definition.builder.validator; + +import info.magnolia.ui.field.RegexpValidatorDefinition; + +import javax.annotation.Nullable; +import java.util.Optional; + +public class RegexpValidatorDefinitionBuilder extends AbstractConfiguredFieldValidatorDefinitionBuilder{ + + @Nullable + private String pattern; + + public RegexpValidatorDefinitionBuilder() { + super(RegexpValidatorDefinition::new); + } + + public RegexpValidatorDefinitionBuilder pattern(final String pattern) { + this.pattern = pattern; + return self(); + } + + public RegexpValidatorDefinition build() { + return build("regexpValidator"); + } + public RegexpValidatorDefinition build(final String name) { + final RegexpValidatorDefinition definition = super.build(name); + Optional.ofNullable(pattern).ifPresent(definition::setPattern); + return definition; + } +} diff --git a/magnolia-builders/src/main/java/com/merkle/oss/magnolia/definition/builder/validator/SafeHtmlValidatorDefinitionBuilder.java b/magnolia-builders/src/main/java/com/merkle/oss/magnolia/definition/builder/validator/SafeHtmlValidatorDefinitionBuilder.java new file mode 100644 index 0000000..1c83eda --- /dev/null +++ b/magnolia-builders/src/main/java/com/merkle/oss/magnolia/definition/builder/validator/SafeHtmlValidatorDefinitionBuilder.java @@ -0,0 +1,136 @@ +package com.merkle.oss.magnolia.definition.builder.validator; + +import info.magnolia.ui.field.SafeHtmlValidatorDefinition; +import info.magnolia.ui.field.SafeHtmlValidatorDefinition.Attribute; +import info.magnolia.ui.field.SafeHtmlValidatorDefinition.Protocol; + +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class SafeHtmlValidatorDefinitionBuilder extends AbstractConfiguredFieldValidatorDefinitionBuilder{ + + @Nullable + private List allowedTags; + @Nullable + private List globallyAllowedAttributes; + @Nullable + private List allowedAttributes; + @Nullable + private List allowedProtocols; + + public SafeHtmlValidatorDefinitionBuilder() { + super(SafeHtmlValidatorDefinition::new); + } + + public SafeHtmlValidatorDefinitionBuilder allowedTag(final String allowedTag) { + return item(this::allowedTags, allowedTags, allowedTag); + } + + public SafeHtmlValidatorDefinitionBuilder allowedTags(final List allowedTags) { + this.allowedTags = allowedTags; + return self(); + } + + public SafeHtmlValidatorDefinitionBuilder globallyAllowedAttribute(final String globallyAllowedAttribute) { + return item(this::globallyAllowedAttributes, globallyAllowedAttributes, globallyAllowedAttribute); + } + + public SafeHtmlValidatorDefinitionBuilder globallyAllowedAttributes(final List globallyAllowedAttributes) { + this.globallyAllowedAttributes = globallyAllowedAttributes; + return self(); + } + + public SafeHtmlValidatorDefinitionBuilder allowedAttribute(final String tag, final String... attributes) { + return allowedAttribute(new AttributeBuilder().attributes(List.of(attributes)).build(tag)); + } + + public SafeHtmlValidatorDefinitionBuilder allowedAttribute(final Attribute allowedAttribute) { + return item(this::allowedAttributes, allowedAttributes, allowedAttribute); + } + + public SafeHtmlValidatorDefinitionBuilder allowedAttributes(final List allowedAttributes) { + this.allowedAttributes = allowedAttributes; + return self(); + } + + public SafeHtmlValidatorDefinitionBuilder allowedProtocol(final String tag, final String attribute, final String... protocols) { + return allowedProtocol(new ProtocolBuilder().protocols(List.of(protocols)).build(tag, attribute)); + } + + public SafeHtmlValidatorDefinitionBuilder allowedProtocol(final Protocol allowedProtocol) { + return item(this::allowedProtocols, allowedProtocols, allowedProtocol); + } + + public SafeHtmlValidatorDefinitionBuilder allowedProtocols(final List allowedProtocols) { + this.allowedProtocols = allowedProtocols; + return self(); + } + + private SafeHtmlValidatorDefinitionBuilder item(final Consumer> consumer, final List items, final T item) { + consumer.accept(Stream.concat( + Stream.ofNullable(items).flatMap(Collection::stream), + Stream.of(item) + ).collect(Collectors.toList())); + return self(); + } + + public SafeHtmlValidatorDefinition build() { + return build("safeHtmlValidator"); + } + public SafeHtmlValidatorDefinition build(final String name) { + final SafeHtmlValidatorDefinition definition = super.build(name); + Stream.ofNullable(allowedTags).flatMap(Collection::stream).forEach(definition.getAllowedTags()::add); + Stream.ofNullable(globallyAllowedAttributes).flatMap(Collection::stream).forEach(definition.getGloballyAllowedAttributes()::add); + Stream.ofNullable(allowedAttributes).flatMap(Collection::stream).forEach(definition.getAllowedAttributes()::add); + Stream.ofNullable(allowedProtocols).flatMap(Collection::stream).forEach(definition.getAllowedProtocols()::add); + return definition; + } + + public static class AttributeBuilder { + private List attributes = new ArrayList<>(); + + public AttributeBuilder attribute(final String attribute) { + this.attributes.add(attribute); + return this; + } + + public AttributeBuilder attributes(final List attributes) { + this.attributes = attributes; + return this; + } + + public Attribute build(final String tag) { + final Attribute attribute = new Attribute(); + attribute.setTag(tag); + attribute.setAttributes(attributes.toArray(String[]::new)); + return attribute; + } + } + + public static class ProtocolBuilder { + private List protocols = new ArrayList<>(); + + public ProtocolBuilder protocol(final String protocol) { + this.protocols.add(protocol); + return this; + } + + public ProtocolBuilder protocols(final List protocols) { + this.protocols = protocols; + return this; + } + + public Protocol build(final String tag, final String attribute) { + final Protocol protocol = new Protocol(); + protocol.setTag(tag); + protocol.setAttribute(attribute); + protocol.setProtocols(protocols.toArray(String[]::new)); + return protocol; + } + } +} diff --git a/magnolia-builders/src/main/java/com/merkle/oss/magnolia/definition/builder/validator/SvgUploadValidatorDefinitionBuilder.java b/magnolia-builders/src/main/java/com/merkle/oss/magnolia/definition/builder/validator/SvgUploadValidatorDefinitionBuilder.java new file mode 100644 index 0000000..4a63df0 --- /dev/null +++ b/magnolia-builders/src/main/java/com/merkle/oss/magnolia/definition/builder/validator/SvgUploadValidatorDefinitionBuilder.java @@ -0,0 +1,17 @@ +package com.merkle.oss.magnolia.definition.builder.validator; + +import info.magnolia.ui.field.SvgUploadValidatorDefinition; + +public class SvgUploadValidatorDefinitionBuilder extends AbstractConfiguredFieldValidatorDefinitionBuilder{ + + public SvgUploadValidatorDefinitionBuilder() { + super(SvgUploadValidatorDefinition::new); + } + + public SvgUploadValidatorDefinition build() { + return build("svgUploadValidator"); + } + public SvgUploadValidatorDefinition build(final String name) { + return super.build(name); + } +} diff --git a/magnolia-builders/src/test/java/com/merkle/oss/magnolia/definition/builder/validator/AbstractConfiguredFieldValidatorDefinitionBuilderTestCase.java b/magnolia-builders/src/test/java/com/merkle/oss/magnolia/definition/builder/validator/AbstractConfiguredFieldValidatorDefinitionBuilderTestCase.java new file mode 100644 index 0000000..33b70b5 --- /dev/null +++ b/magnolia-builders/src/test/java/com/merkle/oss/magnolia/definition/builder/validator/AbstractConfiguredFieldValidatorDefinitionBuilderTestCase.java @@ -0,0 +1,20 @@ +package com.merkle.oss.magnolia.definition.builder.validator; + +import info.magnolia.ui.field.ConfiguredFieldValidatorDefinition; + +import java.util.function.BiFunction; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public abstract class AbstractConfiguredFieldValidatorDefinitionBuilderTestCase { + + public > B assertValidator(final B builder, final BiFunction buildFunction) { + final D definition = buildFunction.apply( + "someName", + builder + .errorMessage("someErrorMessage") + ); + assertEquals("someErrorMessage", definition.getErrorMessage()); + return builder; + } +} diff --git a/magnolia-builders/src/test/java/com/merkle/oss/magnolia/definition/builder/validator/EmailValidatorDefinitionBuilderTest.java b/magnolia-builders/src/test/java/com/merkle/oss/magnolia/definition/builder/validator/EmailValidatorDefinitionBuilderTest.java new file mode 100644 index 0000000..4b14bf5 --- /dev/null +++ b/magnolia-builders/src/test/java/com/merkle/oss/magnolia/definition/builder/validator/EmailValidatorDefinitionBuilderTest.java @@ -0,0 +1,18 @@ +package com.merkle.oss.magnolia.definition.builder.validator; + +import info.magnolia.ui.field.EmailValidatorDefinition; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class EmailValidatorDefinitionBuilderTest extends AbstractConfiguredFieldValidatorDefinitionBuilderTestCase { + @Test + void testBuilder() { + final EmailValidatorDefinition definition = super.assertValidator(new EmailValidatorDefinitionBuilder(), (name, builder) -> builder.build(name)) + .build("somEmailValidator"); + assertEquals("somEmailValidator", definition.getName()); + + final EmailValidatorDefinition emptyDefinition = new EmailValidatorDefinitionBuilder().build(); + assertEquals("emailValidator", emptyDefinition.getName()); + } +} diff --git a/magnolia-builders/src/test/java/com/merkle/oss/magnolia/definition/builder/validator/NodeNameValidatorDefinitionBuilderTest.java b/magnolia-builders/src/test/java/com/merkle/oss/magnolia/definition/builder/validator/NodeNameValidatorDefinitionBuilderTest.java new file mode 100644 index 0000000..60de78f --- /dev/null +++ b/magnolia-builders/src/test/java/com/merkle/oss/magnolia/definition/builder/validator/NodeNameValidatorDefinitionBuilderTest.java @@ -0,0 +1,24 @@ +package com.merkle.oss.magnolia.definition.builder.validator; + +import info.magnolia.ui.editor.validator.NodeNameValidatorDefinition; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class NodeNameValidatorDefinitionBuilderTest extends AbstractConfiguredFieldValidatorDefinitionBuilderTestCase { + @Test + void testBuilder() { + final NodeNameValidatorDefinition definition = super.assertValidator(new NodeNameValidatorDefinitionBuilder(), (name, builder) -> builder.build(name)) + .mode(NodeNameValidatorDefinition.Mode.ADD) + .pattern("somePattern") + .build("someNodeNameValidator"); + assertEquals("someNodeNameValidator", definition.getName()); + assertEquals("somePattern", definition.getPattern()); + assertEquals(NodeNameValidatorDefinition.Mode.ADD, definition.getMode()); + + final NodeNameValidatorDefinition emptyDefinition = new NodeNameValidatorDefinitionBuilder().build(); + assertEquals("nodeNameValidator", emptyDefinition.getName()); + assertEquals(".+", emptyDefinition.getPattern()); + assertEquals(NodeNameValidatorDefinition.Mode.EDIT, emptyDefinition.getMode()); + } +} diff --git a/magnolia-builders/src/test/java/com/merkle/oss/magnolia/definition/builder/validator/RegexpValidatorDefinitionBuilderTest.java b/magnolia-builders/src/test/java/com/merkle/oss/magnolia/definition/builder/validator/RegexpValidatorDefinitionBuilderTest.java new file mode 100644 index 0000000..af12f24 --- /dev/null +++ b/magnolia-builders/src/test/java/com/merkle/oss/magnolia/definition/builder/validator/RegexpValidatorDefinitionBuilderTest.java @@ -0,0 +1,22 @@ +package com.merkle.oss.magnolia.definition.builder.validator; + +import info.magnolia.ui.field.RegexpValidatorDefinition; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + +class RegexpValidatorDefinitionBuilderTest extends AbstractConfiguredFieldValidatorDefinitionBuilderTestCase { + @Test + void testBuilder() { + final RegexpValidatorDefinition definition = super.assertValidator(new RegexpValidatorDefinitionBuilder(), (name, builder) -> builder.build(name)) + .pattern("somePattern") + .build("someRegexpValidator"); + assertEquals("someRegexpValidator", definition.getName()); + assertEquals("somePattern", definition.getPattern()); + + final RegexpValidatorDefinition emptyDefinition = new RegexpValidatorDefinitionBuilder().build(); + assertEquals("regexpValidator", emptyDefinition.getName()); + assertNull(emptyDefinition.getPattern()); + } +} diff --git a/magnolia-builders/src/test/java/com/merkle/oss/magnolia/definition/builder/validator/SafeHtmlValidatorDefinitionBuilderTest.java b/magnolia-builders/src/test/java/com/merkle/oss/magnolia/definition/builder/validator/SafeHtmlValidatorDefinitionBuilderTest.java new file mode 100644 index 0000000..352a52c --- /dev/null +++ b/magnolia-builders/src/test/java/com/merkle/oss/magnolia/definition/builder/validator/SafeHtmlValidatorDefinitionBuilderTest.java @@ -0,0 +1,90 @@ +package com.merkle.oss.magnolia.definition.builder.validator; + +import com.merkle.oss.magnolia.definition.builder.validator.SafeHtmlValidatorDefinitionBuilder.AttributeBuilder; +import com.merkle.oss.magnolia.definition.builder.validator.SafeHtmlValidatorDefinitionBuilder.ProtocolBuilder; +import info.magnolia.ui.editor.validator.NodeNameValidatorDefinition; +import info.magnolia.ui.field.SafeHtmlValidatorDefinition; +import info.magnolia.ui.field.SafeHtmlValidatorDefinition.Attribute; +import info.magnolia.ui.field.SafeHtmlValidatorDefinition.Protocol; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.Equator; +import org.junit.jupiter.api.Test; + +import java.util.Arrays; +import java.util.List; +import java.util.Objects; +import java.util.function.BiFunction; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class SafeHtmlValidatorDefinitionBuilderTest extends AbstractConfiguredFieldValidatorDefinitionBuilderTestCase { + private final Equator attributeEquator = new Equator<>() { + @Override + public boolean equate(final Attribute a1, final Attribute a2) { + return Objects.equals(a1.getTag(), a2.getTag()) && Arrays.equals(a1.getAttributes(), a2.getAttributes()); + } + + @Override + public int hash(final Attribute a) { + return Objects.hash(a.getTag(), Arrays.hashCode(a.getAttributes())); + } + }; + private final Equator protocolEquator = new Equator<>() { + @Override + public boolean equate(final Protocol p1, final Protocol p2) { + return Objects.equals(p1.getTag(), p2.getTag()) && Objects.equals(p1.getAttribute(), p2.getAttribute()) && Arrays.equals(p1.getProtocols(), p2.getProtocols()); + } + + @Override + public int hash(final Protocol p) { + return Objects.hash(p.getTag(), p.getAttribute(), Arrays.hashCode(p.getProtocols())); + } + }; + + @Test + void testBuilder() { + final SafeHtmlValidatorDefinition definition = super.assertValidator(new SafeHtmlValidatorDefinitionBuilder(), (name, builder) -> builder.build(name)) + .allowedTag("tag1") + .allowedTag("tag2") + .globallyAllowedAttribute("globalAttribute1") + .globallyAllowedAttribute("globalAttribute2") + .allowedProtocol("protocol1", "attribute", "p1", "p2") + .allowedProtocol(new ProtocolBuilder().protocol("p1").build("protocol2", "attribute")) + .allowedAttribute("attribute1", "a1", "a2") + .allowedAttribute(new AttributeBuilder().attribute("a1").build("attribute2")) + .build("someSafeHtmlValidator"); + assertEquals("someSafeHtmlValidator", definition.getName()); + assertEquals(List.of("tag1", "tag2"), definition.getAllowedTags()); + assertEquals(List.of("globalAttribute1", "globalAttribute2"), definition.getGloballyAllowedAttributes()); + + + assertTrue( + CollectionUtils.isEqualCollection( + List.of( + new ProtocolBuilder().protocol("p1").protocol("p2").build("protocol1", "attribute"), + new ProtocolBuilder().protocol("p1").build("protocol2", "attribute") + ), + definition.getAllowedProtocols(), + protocolEquator + ) + ); + assertTrue( + CollectionUtils.isEqualCollection( + List.of( + new AttributeBuilder().attribute("a1").attribute("a2").build("attribute1"), + new AttributeBuilder().attribute("a1").build("attribute2") + ), + definition.getAllowedAttributes(), + attributeEquator + ) + ); + + final SafeHtmlValidatorDefinition emptyDefinition = new SafeHtmlValidatorDefinitionBuilder().build(); + assertEquals("safeHtmlValidator", emptyDefinition.getName()); + assertTrue(emptyDefinition.getAllowedTags().isEmpty()); + assertTrue(emptyDefinition.getGloballyAllowedAttributes().isEmpty()); + assertTrue(emptyDefinition.getAllowedProtocols().isEmpty()); + assertTrue(emptyDefinition.getAllowedAttributes().isEmpty()); + } +} diff --git a/magnolia-builders/src/test/java/com/merkle/oss/magnolia/definition/builder/validator/SvgUploadValidatorDefinitionBuilderTest.java b/magnolia-builders/src/test/java/com/merkle/oss/magnolia/definition/builder/validator/SvgUploadValidatorDefinitionBuilderTest.java new file mode 100644 index 0000000..33e1698 --- /dev/null +++ b/magnolia-builders/src/test/java/com/merkle/oss/magnolia/definition/builder/validator/SvgUploadValidatorDefinitionBuilderTest.java @@ -0,0 +1,20 @@ +package com.merkle.oss.magnolia.definition.builder.validator; + +import info.magnolia.ui.field.EmailValidatorDefinition; +import info.magnolia.ui.field.SvgUploadValidatorDefinition; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class SvgUploadValidatorDefinitionBuilderTest extends AbstractConfiguredFieldValidatorDefinitionBuilderTestCase { + @Test + void testBuilder() { + final SvgUploadValidatorDefinition definition = super.assertValidator(new SvgUploadValidatorDefinitionBuilder(), (name, builder) -> builder.build(name)) + .build("someSvgUploadValidator"); + assertEquals("someSvgUploadValidator", definition.getName()); + + + final SvgUploadValidatorDefinition emptyDefinition = new SvgUploadValidatorDefinitionBuilder().build(); + assertEquals("svgUploadValidator", emptyDefinition.getName()); + } +}