Search in sources :

Example 1 with PropertyModelWithDefaults

use of org.apache.sling.models.testmodels.interfaces.PropertyModelWithDefaults in project sling by apache.

the class DefaultTest method testDefaultStringValueOnInterfaceField.

@Test
public void testDefaultStringValueOnInterfaceField() {
    ValueMap vm = new ValueMapDecorator(Collections.<String, Object>singletonMap("first", "first value"));
    Resource res = mock(Resource.class);
    when(res.adaptTo(ValueMap.class)).thenReturn(vm);
    PropertyModelWithDefaults model = factory.getAdapter(res, PropertyModelWithDefaults.class);
    assertNotNull(model);
    assertEquals("first value", model.getFirst());
    assertEquals("second default", model.getSecond());
}
Also used : ValueMap(org.apache.sling.api.resource.ValueMap) ValueMapDecorator(org.apache.sling.api.wrappers.ValueMapDecorator) Resource(org.apache.sling.api.resource.Resource) PropertyModelWithDefaults(org.apache.sling.models.testmodels.interfaces.PropertyModelWithDefaults) Test(org.junit.Test)

Aggregations

Resource (org.apache.sling.api.resource.Resource)1 ValueMap (org.apache.sling.api.resource.ValueMap)1 ValueMapDecorator (org.apache.sling.api.wrappers.ValueMapDecorator)1 PropertyModelWithDefaults (org.apache.sling.models.testmodels.interfaces.PropertyModelWithDefaults)1 Test (org.junit.Test)1