Search in sources :

Example 11 with ResourcePropertyBuilder

use of org.apache.sling.validation.impl.model.ResourcePropertyBuilder in project sling by apache.

the class ResourceValidationModelProviderImplTest method testGetValidationModels.

@Test
public void testGetValidationModels() throws Exception {
    // build two models manually (which are identical except for the applicable path)
    ResourcePropertyBuilder resourcePropertyBuilder = new ResourcePropertyBuilder();
    ValidationModel model1 = modelBuilder.resourceProperty(resourcePropertyBuilder.build("property1")).build("sling/validation/test", libsValidatorsRoot.getPath() + "/testValidationModel1");
    modelBuilder.setApplicablePath("/content/site2");
    ValidationModel model2 = modelBuilder.build("sling/validation/test", libsValidatorsRoot.getPath() + "/testValidationModel2");
    // build models in JCR
    createValidationModelResource(rr, libsValidatorsRoot.getPath(), "testValidationModel1", model1);
    createValidationModelResource(rr, libsValidatorsRoot.getPath(), "testValidationModel2", model2);
    // check that both models are returned
    Collection<ValidationModel> models = modelProvider.getValidationModels("sling/validation/test");
    Assert.assertThat(models, Matchers.containsInAnyOrder(model1, model2));
}
Also used : ValidationModel(org.apache.sling.validation.model.ValidationModel) ResourcePropertyBuilder(org.apache.sling.validation.impl.model.ResourcePropertyBuilder) Test(org.junit.Test)

Aggregations

ResourcePropertyBuilder (org.apache.sling.validation.impl.model.ResourcePropertyBuilder)11 ValidationModel (org.apache.sling.validation.model.ValidationModel)8 Test (org.junit.Test)8 ValidationModelBuilder (org.apache.sling.validation.impl.model.ValidationModelBuilder)6 HashMap (java.util.HashMap)4 ChildResource (org.apache.sling.validation.model.ChildResource)4 Resource (org.apache.sling.api.resource.Resource)3 ResourceProperty (org.apache.sling.validation.model.ResourceProperty)3 ArrayList (java.util.ArrayList)2 ModifiableValueMap (org.apache.sling.api.resource.ModifiableValueMap)2 ValueMap (org.apache.sling.api.resource.ValueMap)2 Before (org.junit.Before)2 List (java.util.List)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Matcher (java.util.regex.Matcher)1 Nonnull (javax.annotation.Nonnull)1 Session (javax.jcr.Session)1 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)1 ValueMapDecorator (org.apache.sling.api.wrappers.ValueMapDecorator)1