Examples of ValueMap


Examples of org.apache.sling.api.resource.ValueMap

        final Resource viewRes = view.getResource();
        if (viewRes == null) {
            throw new IllegalStateException("viewRes must not be null");
        }
        final ValueMap valueMap = viewRes.adaptTo(ValueMap.class);
        if (valueMap == null) {
            throw new IllegalStateException("valueMap must not be null");
        }
        String leaderId = valueMap.get("leaderId", String.class);
        final Resource members = viewRes.getChild("members");
        if (members == null) {
            throw new IllegalStateException("members must not be null");
        }
        final Iterator<Resource> it1 = members
View Full Code Here

Examples of org.apache.sling.api.resource.ValueMap

        Map<String, Object> map = new HashMap<String, Object>();
        map.put("first", "first-value");
        map.put("third", "third-value");
        map.put("intProperty", new Integer(3));
        map.put("arrayProperty", new String[] { "three", "four" });
        ValueMap vm = new ValueMapDecorator(map);

        Resource res = mock(Resource.class);
        when(res.adaptTo(ValueMap.class)).thenReturn(vm);

        SimplePropertyModel model = factory.getAdapter(res, SimplePropertyModel.class);
View Full Code Here

Examples of org.apache.sling.api.resource.ValueMap

    @Test
    public void testCreatedNestedModel() {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("required", "required");
        ValueMap vm = new ValueMapDecorator(map);
        when(resource.adaptTo(ValueMap.class)).thenReturn(vm);

        NestedModel model = factory.createModel(resource, NestedModel.class);
        Assert.assertNotNull(model);
        Assert.assertEquals("required", model.getNestedModel().getRequired());
View Full Code Here

Examples of org.apache.sling.api.resource.ValueMap

    @Test(expected=MissingElementsException.class)
    public void testCreatedNestedModelWithMissingElements() {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("invalid", "required");
        ValueMap vm = new ValueMapDecorator(map);
        when(resource.adaptTo(ValueMap.class)).thenReturn(vm);

        factory.createModel(resource, NestedModel.class);
    }
View Full Code Here

Examples of org.apache.sling.api.resource.ValueMap

    private Resource getMockResourceWithProps() {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("first", "first-value");
        map.put("third", "third-value");
        ValueMap vm = new ValueMapDecorator(map);

        Resource res = mock(Resource.class);
        when(res.adaptTo(ValueMap.class)).thenReturn(vm);
        return res;
    }
View Full Code Here

Examples of org.apache.sling.api.resource.ValueMap

    }

    @Test
    public void testChildModel() {
        Object firstValue = RandomStringUtils.randomAlphabetic(10);
        ValueMap firstMap = new ValueMapDecorator(Collections.singletonMap("property", firstValue));

        final Resource firstChild = mock(Resource.class);
        when(firstChild.adaptTo(ValueMap.class)).thenReturn(firstMap);
        when(firstChild.adaptTo(ChildModel.class)).thenAnswer(new AdaptToChildModel());

        Object firstGrandChildValue = RandomStringUtils.randomAlphabetic(10);
        ValueMap firstGrandChildMap = new ValueMapDecorator(Collections.singletonMap("property", firstGrandChildValue));
        Object secondGrandChildValue = RandomStringUtils.randomAlphabetic(10);
        ValueMap secondGrandChildMap = new ValueMapDecorator(Collections.singletonMap("property", secondGrandChildValue));

        final Resource firstGrandChild = mock(Resource.class);
        when(firstGrandChild.adaptTo(ValueMap.class)).thenReturn(firstGrandChildMap);
        when(firstGrandChild.adaptTo(ChildModel.class)).thenAnswer(new AdaptToChildModel());
View Full Code Here

Examples of org.apache.sling.api.resource.ValueMap

    public void setup() {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("propertyContainingAPath", "/some/other/path");
        map.put("anotherPropertyContainingAPath", "/some/other/path2");

        ValueMap properties = new ValueMapDecorator(map);

        when(componentCtx.getBundleContext()).thenReturn(bundleContext);
        when(componentCtx.getProperties()).thenReturn(new Hashtable<String, Object>());

        when(adaptable.getResourceResolver()).thenReturn(resourceResolver);
View Full Code Here

Examples of org.apache.sling.api.resource.ValueMap

        if ( pos == -1 ) {
            return this.base;
        }
        final Resource rsrc = this.resolver.getResource(pathPrefix + name.substring(0, pos));
        if ( rsrc != null ) {
            final ValueMap vm = rsrc.adaptTo(ValueMap.class);
            if ( vm != null ) {
                return vm;
            }
        }
        return ValueMap.EMPTY; // fall back
View Full Code Here

Examples of org.apache.sling.api.resource.ValueMap

        if (resource == null && path != null) {
            String name = ResourceUtil.getName(path);
            String parentPath = ResourceUtil.getParent(path);
            Resource parentResource = getResourceInternal(parentPath);
            if (parentResource!=null) {
                ValueMap props = ResourceUtil.getValueMap(parentResource);
                if (props.containsKey(name)) {
                    return new MockPropertyResource(path, props, this);
                }
            }
        }
       
View Full Code Here

Examples of org.apache.sling.api.resource.ValueMap

        factory.bindInjector(new ChildResourceInjector(), new ServicePropertiesMap(1, 1));
    }

    @Test
    public void testFieldInjectionClass() {
        ValueMap vm = ValueMap.EMPTY;

        Resource res = mock(Resource.class);
        when(res.adaptTo(ValueMap.class)).thenReturn(vm);

        org.apache.sling.models.testmodels.classes.OptionalPrimitivesModel model
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.