Package org.apache.sling.api.wrappers

Examples of org.apache.sling.api.wrappers.ValueMapDecorator


            ValidationModel vm = validationService.getValidationModel("sling/validation/test", "/apps/validation/1/resource");
            HashMap<String, Object> hashMap = new HashMap<String, Object>() {{
                put("field1", "HelloWorld");
                put("field2", "HelloWorld");
            }};
            ValueMap map = new ValueMapDecorator(hashMap);
            ValidationResult vr = validationService.validate(map, vm);
            assertFalse(vr.isValid());
            // check for correct error message
            Map<String, List<String>> expectedFailureMessages = new HashMap<String, List<String>>();
            expectedFailureMessages.put("field2", Arrays.asList("Property does not match the pattern " + TEST_REGEX));
View Full Code Here


        this.jobId = jobId;
        this.path = (String)properties.remove(PROPERTY_RESOURCE_PATH);
        this.isBridgedEvent = properties.get(PROPERTY_BRIDGED_EVENT) != null;
        this.readErrorList = (List<Exception>) properties.remove(ResourceHelper.PROPERTY_MARKER_READ_ERROR_LIST);

        this.properties = new ValueMapDecorator(properties);
        this.properties.put(NotificationConstants.NOTIFICATION_PROPERTY_JOB_ID, jobId);
        final int lastPos = jobId.lastIndexOf('_');
        this.counter = Long.valueOf(jobId.substring(lastPos + 1));
    }
View Full Code Here

        assertEquals(Integer.valueOf(1), valueMap.get("sample", Integer.class));
        assertEquals("1", valueMap.get("sample", String.class));
    }

    @Test public void test_getValueMap_direct() {
        final ValueMap valueMap = new ValueMapDecorator(new HashMap<String, Object>());
        valueMap.put("sample", true);
        final Resource resource = new SyntheticResource(null, "/", "sample") {
            @Override
            @SuppressWarnings("unchecked")
            public <Type> Type adaptTo(Class<Type> type) {
                if (type == ValueMap.class) {
View Full Code Here

    @Before
    public void setup() {
        when(listPage.getProperties()).thenAnswer(new Answer<ValueMap>() {
            @SuppressWarnings("serial")
            public ValueMap answer(InvocationOnMock invocation) throws Throwable {
                return new ValueMapDecorator(new HashMap<String, Object>() {
                    {
                        put(NameConstants.NN_TEMPLATE, GenericListImpl.TMPL_GENERIC_LIST);

                    }
                });
            }
        });
        when(listPage.getContentResource()).thenReturn(contentResource);
        when(contentResource.getChild("list")).thenReturn(listResource);
        when(listResource.listChildren()).thenReturn(Arrays.asList(resourceOne, resourceTwo).iterator());

        when(resourceOne.adaptTo(ValueMap.class)).thenAnswer(new Answer<ValueMap>() {
            @SuppressWarnings("serial")
            public ValueMap answer(InvocationOnMock invocation) throws Throwable {
                return new ValueMapDecorator(new HashMap<String, Object>() {
                    {
                        put(NameConstants.PN_TITLE, "titleone");
                        put(GenericListImpl.PN_VALUE, "valueone");

                    }
                });
            }
        });
        when(resourceTwo.adaptTo(ValueMap.class)).thenAnswer(new Answer<ValueMap>() {
            @SuppressWarnings("serial")
            public ValueMap answer(InvocationOnMock invocation) throws Throwable {
                return new ValueMapDecorator(new HashMap<String, Object>() {
                    {
                        put(NameConstants.PN_TITLE, "titletwo");
                        put(GenericListImpl.PN_VALUE, "valuetwo");
                        put(NameConstants.PN_TITLE + "." + "fr", "french_title");
                        put(NameConstants.PN_TITLE + "." + "fr_ch", "swiss_french_title");
View Full Code Here

        Page wrongPage = mock(Page.class);

        when(wrongPage.getProperties()).thenAnswer(new Answer<ValueMap>() {
            @SuppressWarnings("serial")
            public ValueMap answer(InvocationOnMock invocation) throws Throwable {
                return new ValueMapDecorator(new HashMap<String, Object>() {
                    {
                        put(NameConstants.NN_TEMPLATE, "/wrong");

                    }
                });
View Full Code Here

    @Test
    public void test_that_adapting_page_with_null_template_returns_null() {
        Page wrongPage = mock(Page.class);
        when(wrongPage.getProperties()).thenAnswer(new Answer<ValueMap>() {
            public ValueMap answer(InvocationOnMock invocation) throws Throwable {
                return new ValueMapDecorator(new HashMap<String, Object>());
            }
        });

        GenericList section = adaptToGenericList(wrongPage);
        assertNull(section);
View Full Code Here

        reset(layer);
    }

    @Test
    public void testTransform() throws Exception {
        ValueMap properties = new ValueMapDecorator(map);

        transformer.transform(layer, properties);

        verify(layer, times(1)).grayscale();
        verifyNoMoreInteractions(layer);
View Full Code Here

        verifyNoMoreInteractions(layer);
    }

    @Test
    public void testTransform_emptyParams() throws Exception {
        ValueMap properties = new ValueMapDecorator(map);

        transformer.transform(layer, properties);

        verify(layer, times(1)).grayscale();
        verifyZeroInteractions(layer);
View Full Code Here

        final Integer brightness = 100;
        final Float contrast = 0.05F;

        map.put("brightness", brightness.toString());
        map.put("contrast", contrast.toString());
        ValueMap properties = new ValueMapDecorator(map);

        transformer.transform(layer, properties);

        verify(layer, times(1)).adjust(brightness, contrast);
        verifyNoMoreInteractions(layer);
View Full Code Here

        verifyNoMoreInteractions(layer);
    }

    @Test
    public void testTransform_noParams() throws Exception {
        ValueMap properties = new ValueMapDecorator(map);

        transformer.transform(layer, properties);

        verifyZeroInteractions(layer);
    }
View Full Code Here

TOP

Related Classes of org.apache.sling.api.wrappers.ValueMapDecorator

Copyright © 2018 www.massapicom. 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.