Search in sources :

Example 1 with ResourcePropertyNameRegexMatcher

use of org.apache.sling.validation.impl.util.ResourcePropertyNameRegexMatcher in project sling by apache.

the class MergedValidationModelTest method testOverwritingChildrenAndResourceProperties.

@Test
public void testOverwritingChildrenAndResourceProperties() {
    modelBuilder.resourceProperty(propertyBuilder.nameRegex("overwrittenNameToOverwrite").build("nameToOverwrite"));
    modelBuilder.childResource(childResourceBuilder.nameRegex("overwrittenNameToOverwrite").build("nameToOverwrite"));
    ValidationModel baseValidationModel = modelBuilder.build("base", "some source");
    modelBuilder = new ValidationModelBuilder();
    modelBuilder.resourceProperty(propertyBuilder.nameRegex("originalNameToOverwrite").build("nameToOverwrite"));
    modelBuilder.childResource(childResourceBuilder.nameRegex("originalNameToOverwrite").build("nameToOverwrite"));
    modelBuilder.resourceProperty(propertyBuilder.nameRegex("originalNameNotOverwritten").build("nameNotOverwritten"));
    modelBuilder.childResource(childResourceBuilder.nameRegex("originalNameNotOverwritten").build("nameNotOverwritten"));
    ValidationModel mergedModel = new MergedValidationModel(baseValidationModel, modelBuilder.build("superType", "some source"));
    Assert.assertThat(mergedModel.getResourceProperties(), Matchers.containsInAnyOrder(Arrays.asList(new ResourcePropertyNameRegexMatcher("overwrittenNameToOverwrite"), new ResourcePropertyNameRegexMatcher("originalNameNotOverwritten"))));
    Assert.assertThat(mergedModel.getChildren(), Matchers.containsInAnyOrder(Arrays.asList(new ChildResourceNameRegexMatcher("overwrittenNameToOverwrite"), new ChildResourceNameRegexMatcher("originalNameNotOverwritten"))));
}
Also used : ValidationModel(org.apache.sling.validation.model.ValidationModel) ResourcePropertyNameRegexMatcher(org.apache.sling.validation.impl.util.ResourcePropertyNameRegexMatcher) ChildResourceNameRegexMatcher(org.apache.sling.validation.impl.util.ChildResourceNameRegexMatcher) Test(org.junit.Test)

Aggregations

ChildResourceNameRegexMatcher (org.apache.sling.validation.impl.util.ChildResourceNameRegexMatcher)1 ResourcePropertyNameRegexMatcher (org.apache.sling.validation.impl.util.ResourcePropertyNameRegexMatcher)1 ValidationModel (org.apache.sling.validation.model.ValidationModel)1 Test (org.junit.Test)1