Search in sources :

Example 1 with ChildResourceViaModel

use of org.apache.sling.models.testmodels.classes.ChildResourceViaModel in project sling by apache.

the class ViaTest method testProjectionToChildResource.

@Test
public void testProjectionToChildResource() {
    String value = RandomStringUtils.randomAlphanumeric(10);
    ValueMap map = new ValueMapDecorator(Collections.<String, Object>singletonMap("firstProperty", value));
    when(childResource.adaptTo(ValueMap.class)).thenReturn(map);
    ChildResourceViaModel model = factory.getAdapter(resource, ChildResourceViaModel.class);
    assertNotNull(model);
    assertEquals(value, model.getFirstProperty());
}
Also used : ChildResourceViaModel(org.apache.sling.models.testmodels.classes.ChildResourceViaModel) ValueMap(org.apache.sling.api.resource.ValueMap) ValueMapDecorator(org.apache.sling.api.wrappers.ValueMapDecorator) Test(org.junit.Test)

Aggregations

ValueMap (org.apache.sling.api.resource.ValueMap)1 ValueMapDecorator (org.apache.sling.api.wrappers.ValueMapDecorator)1 ChildResourceViaModel (org.apache.sling.models.testmodels.classes.ChildResourceViaModel)1 Test (org.junit.Test)1