Search in sources :

Example 6 with InjectorSpecificAnnotationModel

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

the class InjectorSpecificAnnotationTest method testSimpleValueModelField.

@Test
public void testSimpleValueModelField() {
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("first", "first-value");
    map.put("second", "second-value");
    ValueMap vm = new ValueMapDecorator(map);
    Resource res = mock(Resource.class);
    when(res.adaptTo(ValueMap.class)).thenReturn(vm);
    when(request.getResource()).thenReturn(res);
    InjectorSpecificAnnotationModel model = factory.getAdapter(request, InjectorSpecificAnnotationModel.class);
    assertNotNull("Could not instanciate model", model);
    assertEquals("first-value", model.getFirst());
    assertEquals("second-value", model.getSecond());
}
Also used : InjectorSpecificAnnotationModel(org.apache.sling.models.testmodels.classes.InjectorSpecificAnnotationModel) 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) Test(org.junit.Test)

Aggregations

InjectorSpecificAnnotationModel (org.apache.sling.models.testmodels.classes.InjectorSpecificAnnotationModel)6 Test (org.junit.Test)6 Resource (org.apache.sling.api.resource.Resource)3 HashMap (java.util.HashMap)2 ValueMap (org.apache.sling.api.resource.ValueMap)2 ValueMapDecorator (org.apache.sling.api.wrappers.ValueMapDecorator)2 Logger (org.slf4j.Logger)2 SlingBindings (org.apache.sling.api.scripting.SlingBindings)1 SlingScriptHelper (org.apache.sling.api.scripting.SlingScriptHelper)1 ServiceReference (org.osgi.framework.ServiceReference)1