Search in sources :

Example 1 with EvenSimplerPropertyModel

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

the class ImplementsExtendsTest method testExtendsClassModel.

/**
     * Test to adapt to a superclass of the implementation class with the appropriate mapping in the @Model annotation.
     */
@Test
public void testExtendsClassModel() {
    Resource res = getMockResourceWithProps();
    // this is not having a model annotation nor does implement an interface/extend a class with a model annotation
    SimplePropertyModel model = factory.getAdapter(res, SimplePropertyModel.class);
    assertNotNull(model);
    assertEquals("!first-value|null|third-value!", model.getAllProperties());
    assertTrue(factory.canCreateFromAdaptable(res, SimplePropertyModel.class));
    EvenSimplerPropertyModel simplerModel = factory.getAdapter(res, EvenSimplerPropertyModel.class);
    assertNotNull(simplerModel);
    assertEquals("first-value", model.getFirst());
    assertTrue(factory.canCreateFromAdaptable(res, EvenSimplerPropertyModel.class));
}
Also used : SimplePropertyModel(org.apache.sling.models.testmodels.classes.implextend.SimplePropertyModel) EvenSimplerPropertyModel(org.apache.sling.models.testmodels.classes.implextend.EvenSimplerPropertyModel) Resource(org.apache.sling.api.resource.Resource) Test(org.junit.Test)

Aggregations

Resource (org.apache.sling.api.resource.Resource)1 EvenSimplerPropertyModel (org.apache.sling.models.testmodels.classes.implextend.EvenSimplerPropertyModel)1 SimplePropertyModel (org.apache.sling.models.testmodels.classes.implextend.SimplePropertyModel)1 Test (org.junit.Test)1