Search in sources :

Example 1 with ViaModel

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

the class ViaTest method testProjectionToResource.

@Test
public void testProjectionToResource() {
    String value = RandomStringUtils.randomAlphanumeric(10);
    ValueMap map = new ValueMapDecorator(Collections.<String, Object>singletonMap("firstProperty", value));
    when(resource.adaptTo(ValueMap.class)).thenReturn(map);
    ViaModel model = factory.getAdapter(request, ViaModel.class);
    assertNotNull(model);
    assertEquals(value, model.getFirstProperty());
}
Also used : ChildResourceViaModel(org.apache.sling.models.testmodels.classes.ChildResourceViaModel) ViaModel(org.apache.sling.models.testmodels.classes.ViaModel) 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 ViaModel (org.apache.sling.models.testmodels.classes.ViaModel)1 Test (org.junit.Test)1