Search in sources :

Example 1 with SubClassModel

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

the class InterfaceInheritanceTest method testSimplePropertyModel.

@Test
public void testSimplePropertyModel() {
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("superClassString", "first-value");
    map.put("subClassString", "second-value");
    ValueMap vm = new ValueMapDecorator(map);
    Resource res = mock(Resource.class);
    when(res.adaptTo(ValueMap.class)).thenReturn(vm);
    SubClassModel model = factory.getAdapter(res, SubClassModel.class);
    assertNotNull(model);
    assertEquals("first-value", model.getSuperClassString());
    assertEquals("second-value", model.getSubClassString());
}
Also used : HashMap(java.util.HashMap) ValueMap(org.apache.sling.api.resource.ValueMap) ValueMapDecorator(org.apache.sling.api.wrappers.ValueMapDecorator) Resource(org.apache.sling.api.resource.Resource) SubClassModel(org.apache.sling.models.testmodels.interfaces.SubClassModel) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)1 Resource (org.apache.sling.api.resource.Resource)1 ValueMap (org.apache.sling.api.resource.ValueMap)1 ValueMapDecorator (org.apache.sling.api.wrappers.ValueMapDecorator)1 SubClassModel (org.apache.sling.models.testmodels.interfaces.SubClassModel)1 Test (org.junit.Test)1