use of org.apache.sling.testing.resourceresolver.MockResource in project sling by apache.
the class MergedResourceTest method testResourceTypeMixed.
@Test
public void testResourceTypeMixed() throws Exception {
final ValueMap vm1 = new ValueMapDecorator(Collections.singletonMap(ResourceResolver.PROPERTY_RESOURCE_TYPE, (Object) "vma"));
final MockResource r1 = new MockResource("/a", vm1, null) {
@Override
public String getResourceType() {
return "a";
}
};
final ValueMap vm2 = new ValueMapDecorator(Collections.singletonMap(ResourceResolver.PROPERTY_RESOURCE_TYPE, (Object) "vmb"));
final MockResource r2 = new MockResource("/b", vm2, null) {
@Override
public String getResourceType() {
return "b";
}
};
final ValueMap vm3 = new ValueMapDecorator(Collections.singletonMap(ResourceResolver.PROPERTY_RESOURCE_TYPE, (Object) "vmc"));
final MockResource r3 = new MockResource("/c", vm3, null) {
@Override
public String getResourceType() {
return "c";
}
};
final List<Resource> resources = new ArrayList<Resource>();
resources.add(r1);
resources.add(r2);
resources.add(r3);
final List<ValueMap> valueMaps = new ArrayList<ValueMap>();
valueMaps.add(vm1);
valueMaps.add(vm2);
valueMaps.add(vm3);
final MergedResource mr1 = new MergedResource(null, "/a", "a", resources, valueMaps);
assertEquals("c", mr1.getResourceType());
assertEquals("vmc", mr1.getResourceSuperType());
final MergedResource mr2 = new MergedResource(null, "/a", "a", resources, Collections.singletonList(vm2));
assertEquals("c", mr2.getResourceType());
assertEquals("vmb", mr2.getResourceSuperType());
}
use of org.apache.sling.testing.resourceresolver.MockResource in project sling by apache.
the class MergedResourceTest method testToString.
@Test
public void testToString() throws Exception {
final ValueMap vm = new ValueMapDecorator(Collections.singletonMap(ResourceResolver.PROPERTY_RESOURCE_TYPE, (Object) "vm"));
final Resource r = new MockResource("/innerResourcePath", vm, null) {
@Override
public String getResourceType() {
return "innerResource";
}
};
final Resource mr = new MergedResource(null, "/merged", "merged", Collections.singletonList(r), Collections.singletonList(vm));
assertTrue(mr.toString().contains("/innerResourcePath"));
}
Aggregations