Package com.day.cq.wcm.api

Examples of com.day.cq.wcm.api.Page


        assertEquals("valueone", items.get(0).getValue());
    }

    @Test
    public void test_that_adapting_page_with_wrong_template_returns_null() {
        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


        return adapterFactory.getAdapter(page, GenericList.class);
    }

    @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>());
            }
        });
View Full Code Here

        assertThat(TemplateUtil.hasTemplate(null, TMPL_FAKE), is(false));
    }

    @Test
    public void test_that_null_template_always_returns_false() {
        Page page = mock(Page.class);
        ValueMap properties = createTemplateValueMap(TMPL_FAKE);
        when(page.getProperties()).thenReturn(properties);
       
        assertThat(TemplateUtil.hasTemplate(page, null), is(false));
    }
View Full Code Here

        assertThat(TemplateUtil.hasTemplate(page, null), is(false));
    }

    @Test
    public void test_that_null_properties_always_returns_false() {
        Page page = mock(Page.class);
        // implicit page.getProperties() == null
       
        assertThat(TemplateUtil.hasTemplate(page, TMPL_FAKE), is(false));
    }
View Full Code Here

        assertThat(TemplateUtil.hasTemplate(page, TMPL_FAKE), is(false));
    }

    @Test
    public void test_that_correct_template_returns_true() {
        Page page = mock(Page.class);
        ValueMap properties = createTemplateValueMap(TMPL_FAKE);
        when(page.getProperties()).thenReturn(properties);
       
        assertThat(TemplateUtil.hasTemplate(page, TMPL_FAKE), is(true));
    }
View Full Code Here

        assertThat(TemplateUtil.hasTemplate(page, TMPL_FAKE), is(true));
    }

    @Test
    public void test_that_correct_template_returns_false() {
        Page page = mock(Page.class);
        ValueMap properties = createTemplateValueMap(TMPL_FAKE2);
        when(page.getProperties()).thenReturn(properties);
       
        assertThat(TemplateUtil.hasTemplate(page, TMPL_FAKE), is(false));
    }
View Full Code Here

        Resource payloadRes = mock(Resource.class);
        Resource jcrRes = mock(Resource.class);
        when(DamUtil.isAsset(payloadRes)).thenReturn(false);

        Page payloadPage = mock(Page.class);
        when(payloadRes.adaptTo(Page.class)).thenReturn(payloadPage);
        when(payloadPage.getContentResource()).thenReturn(jcrRes);

        // mock valueMap
        when(ResourceUtil.getValueMap(jcrRes)).thenReturn(vmap);
        Map<String, String> props = SendTemplatedEmailUtils.getPayloadProperties(payloadRes, sdf);
View Full Code Here

        PageManager pageManager = resourceResolver.adaptTo(PageManager.class);

        List<Resource> twitterResources = findTwitterResources(resourceResolver);

        for (Resource twitterResource : twitterResources) {
            Page page = pageManager.getContainingPage(twitterResource);
            if (page != null) {
                Twitter client = page.adaptTo(Twitter.class);
                if (client != null) {
                    try {
                        ValueMap properties = ResourceUtil.getValueMap(twitterResource);
                        String username = properties.get("username", String.class);
View Full Code Here

            Map<String, String> assetMetadata = getJcrKeyValuePairs(mdRes, sdf);
            emailParams.putAll(assetMetadata);

        } else {
            // check if the payload is a page
            Page payloadPage = payloadRes.adaptTo(Page.class);

            if (payloadPage != null) {
                Map<String, String> pageContent = getJcrKeyValuePairs(payloadPage.getContentResource(), sdf);
                emailParams.putAll(pageContent);
            }
        }

        return emailParams;
View Full Code Here

    private GenericList adaptToGenericList(@CheckForNull Object obj) {
        if (obj == null) {
            return null;
        }
        final Page page = (Page) obj;
        if (TemplateUtil.hasTemplate(page, GenericListImpl.TMPL_GENERIC_LIST)
                && page.getContentResource() != null
                && page.getContentResource().getChild("list") != null) {
            return new GenericListImpl(page.getContentResource().getChild("list"));
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of com.day.cq.wcm.api.Page

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.