use of org.apache.sling.models.testmodels.classes.implextend.SampleServiceInterface in project sling by apache.
the class ImplementsExtendsTest method testImplementsInterfaceModel.
/**
* Try to adapt to interface, with an different implementation class that has the @Model annotation
*/
@Test
public void testImplementsInterfaceModel() {
Resource res = getMockResourceWithProps();
SampleServiceInterface model = factory.getAdapter(res, SampleServiceInterface.class);
assertNotNull(model);
assertEquals(ImplementsInterfacePropertyModel.class, model.getClass());
assertEquals("first-value|null|third-value", model.getAllProperties());
assertTrue(factory.canCreateFromAdaptable(res, SampleServiceInterface.class));
}
use of org.apache.sling.models.testmodels.classes.implextend.SampleServiceInterface in project sling by apache.
the class ImplementsExtendsTest method testImplementsNoPickerWithAdapterEqualsImplementation.
/**
* Try to adapt in a case where there is no picker available.
* This causes the extend adaptation to fail.
*/
@Test
public void testImplementsNoPickerWithAdapterEqualsImplementation() {
factory.unbindImplementationPicker(firstImplementationPicker, firstImplementationPickerProps);
Resource res = getMockResourceWithProps();
SampleServiceInterface model = factory.getAdapter(res, ImplementsInterfacePropertyModel.class);
assertNotNull(model);
assertEquals("first-value|null|third-value", model.getAllProperties());
assertTrue(factory.canCreateFromAdaptable(res, ImplementsInterfacePropertyModel.class));
}
use of org.apache.sling.models.testmodels.classes.implextend.SampleServiceInterface in project sling by apache.
the class ImplementsExtendsTest method testImplementsInterfaceModelWithPickLastImplementationPicker.
/**
* Try to adapt to interface, with an different implementation class that has the @Model annotation
*/
@Test
public void testImplementsInterfaceModelWithPickLastImplementationPicker() {
factory.bindImplementationPicker(new AdapterImplementationsTest.LastImplementationPicker(), new ServicePropertiesMap(3, 1));
Resource res = getMockResourceWithProps();
SampleServiceInterface model = factory.getAdapter(res, SampleServiceInterface.class);
assertNotNull(model);
assertEquals(ImplementsInterfacePropertyModel2.class, model.getClass());
assertEquals("first-value|null|third-value", model.getAllProperties());
assertTrue(factory.canCreateFromAdaptable(res, SampleServiceInterface.class));
}
Aggregations