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"))));
}
Aggregations