Search in sources :

Example 11 with ValueMapInjector

use of org.apache.sling.models.impl.injectors.ValueMapInjector in project sling by apache.

the class ViaTest method setup.

@Before
public void setup() {
    when(componentCtx.getBundleContext()).thenReturn(bundleContext);
    when(componentCtx.getProperties()).thenReturn(new Hashtable<String, Object>());
    when(request.getResource()).thenReturn(resource);
    when(resource.getChild("jcr:content")).thenReturn(childResource);
    factory = new ModelAdapterFactory();
    factory.activate(componentCtx);
    factory.bindInjector(new ValueMapInjector(), new ServicePropertiesMap(1, 1));
    factory.bindViaProvider(new BeanPropertyViaProvider(), null);
    factory.bindViaProvider(new ChildResourceViaProvider(), null);
    factory.adapterImplementations.addClassesAsAdapterAndImplementation(ViaModel.class);
    factory.adapterImplementations.addClassesAsAdapterAndImplementation(ChildResourceViaModel.class);
}
Also used : ValueMapInjector(org.apache.sling.models.impl.injectors.ValueMapInjector) ChildResourceViaProvider(org.apache.sling.models.impl.via.ChildResourceViaProvider) BeanPropertyViaProvider(org.apache.sling.models.impl.via.BeanPropertyViaProvider) Before(org.junit.Before)

Example 12 with ValueMapInjector

use of org.apache.sling.models.impl.injectors.ValueMapInjector in project sling by apache.

the class InterfaceInheritanceTest method setup.

@Before
public void setup() {
    when(componentCtx.getBundleContext()).thenReturn(bundleContext);
    when(componentCtx.getProperties()).thenReturn(new Hashtable<String, Object>());
    factory = new ModelAdapterFactory();
    factory.activate(componentCtx);
    ValueMapInjector valueMapInjector = new ValueMapInjector();
    factory.bindInjector(valueMapInjector, new ServicePropertiesMap(1, 2));
    factory.bindInjectAnnotationProcessorFactory(valueMapInjector, Collections.<String, Object>singletonMap(Constants.SERVICE_ID, 2L));
    factory.adapterImplementations.addClassesAsAdapterAndImplementation(SuperClassModel.class, SubClassModel.class);
}
Also used : ValueMapInjector(org.apache.sling.models.impl.injectors.ValueMapInjector) Before(org.junit.Before)

Aggregations

ValueMapInjector (org.apache.sling.models.impl.injectors.ValueMapInjector)12 Before (org.junit.Before)12 ChildResourceInjector (org.apache.sling.models.impl.injectors.ChildResourceInjector)6 SelfInjector (org.apache.sling.models.impl.injectors.SelfInjector)2 BeanPropertyViaProvider (org.apache.sling.models.impl.via.BeanPropertyViaProvider)2 URL (java.net.URL)1 Dictionary (java.util.Dictionary)1 HashMap (java.util.HashMap)1 Hashtable (java.util.Hashtable)1 Vector (java.util.Vector)1 ValueMap (org.apache.sling.api.resource.ValueMap)1 SlingBindings (org.apache.sling.api.scripting.SlingBindings)1 ValueMapDecorator (org.apache.sling.api.wrappers.ValueMapDecorator)1 BindingsInjector (org.apache.sling.models.impl.injectors.BindingsInjector)1 OSGiServiceInjector (org.apache.sling.models.impl.injectors.OSGiServiceInjector)1 RequestAttributeInjector (org.apache.sling.models.impl.injectors.RequestAttributeInjector)1 ResourcePathInjector (org.apache.sling.models.impl.injectors.ResourcePathInjector)1 ChildResourceViaProvider (org.apache.sling.models.impl.via.ChildResourceViaProvider)1 ExtendsClassPropertyModel (org.apache.sling.models.testmodels.classes.implextend.ExtendsClassPropertyModel)1 ImplementsInterfacePropertyModel (org.apache.sling.models.testmodels.classes.implextend.ImplementsInterfacePropertyModel)1