Search in sources :

Example 1 with Style

use of com.day.cq.wcm.api.designer.Style in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class BreadcrumbImplTest method testStyleBasedBreadcrumb.

@Test
public void testStyleBasedBreadcrumb() throws Exception {
    Resource resource = context.currentResource(CURRENT_PAGE + "/jcr:content/header/breadcrumb-style-based");
    slingBindings.put(WCMBindings.PROPERTIES, resource.adaptTo(ValueMap.class));
    Style style = mock(Style.class);
    when(style.get(BreadcrumbImpl.PN_START_LEVEL, BreadcrumbImpl.PROP_START_LEVEL_DEFAULT)).thenReturn(3);
    when(style.get(BreadcrumbImpl.PN_HIDE_CURRENT, BreadcrumbImpl.PROP_SHOW_HIDDEN_DEFAULT)).thenReturn(false);
    when(style.get(BreadcrumbImpl.PN_SHOW_HIDDEN, BreadcrumbImpl.PROP_SHOW_HIDDEN_DEFAULT)).thenReturn(false);
    slingBindings.put(WCMBindings.CURRENT_STYLE, style);
    underTest = context.request().adaptTo(Breadcrumb.class);
    checkBreadcrumbConsistency(new String[] { "Devi Sleeveless Shirt" });
}
Also used : ValueMap(org.apache.sling.api.resource.ValueMap) Resource(org.apache.sling.api.resource.Resource) MockStyle(com.adobe.cq.wcm.core.components.context.MockStyle) Style(com.day.cq.wcm.api.designer.Style) Breadcrumb(com.adobe.cq.wcm.core.components.models.Breadcrumb) Test(org.junit.Test)

Example 2 with Style

use of com.day.cq.wcm.api.designer.Style in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class TitleImplTest method testGetTitleResourcePageStyleType.

@Test
public void testGetTitleResourcePageStyleType() {
    context.currentResource(TITLE_NOPROPS);
    Style style = Mockito.mock(Style.class);
    when(style.get(Title.PN_DESIGN_DEFAULT_TYPE, String.class)).thenReturn("h2");
    slingBindings.put(WCMBindings.CURRENT_STYLE, style);
    underTest = context.request().adaptTo(Title.class);
    assertEquals("h2", underTest.getType());
}
Also used : MockStyle(com.adobe.cq.wcm.core.components.context.MockStyle) Style(com.day.cq.wcm.api.designer.Style) Title(com.adobe.cq.wcm.core.components.models.Title) Test(org.junit.Test)

Example 3 with Style

use of com.day.cq.wcm.api.designer.Style in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class EmbedImplTest method testHtml.

@Test
void testHtml() {
    style = mock(Style.class);
    Mockito.when(style.get(Embed.PN_DESIGN_URL_DISABLED, false)).thenReturn(true);
    Mockito.when(style.get(Embed.PN_DESIGN_HTML_DISABLED, false)).thenReturn(false);
    Mockito.when(style.get(Embed.PN_DESIGN_EMBEDDABLES_DISABLED, false)).thenReturn(true);
    Embed embed = getEmbedUnderTest(PATH_EMBED_3);
    assertEquals(Embed.Type.HTML, embed.getType());
    assertNull(embed.getUrl());
    assertNull(embed.getEmbeddableResourceType());
    assertEquals("<div>html</div>", embed.getHtml());
    Utils.testJSONExport(embed, Utils.getTestExporterJSONPath(BASE, EMBED_3));
}
Also used : Embed(com.adobe.cq.wcm.core.components.models.Embed) Style(com.day.cq.wcm.api.designer.Style) Test(org.junit.jupiter.api.Test)

Example 4 with Style

use of com.day.cq.wcm.api.designer.Style in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class DownloadImplTest method testDownloadWithDefaultTitleType.

@Test
void testDownloadWithDefaultTitleType() {
    Resource mockResource = mock(Resource.class);
    Style mockStyle = new MockStyle(mockResource, new MockValueMap(mockResource));
    Download download = getDownloadUnderTest(DOWNLOAD_1, mockStyle);
    assertNull(download.getTitleType(), "Expected title type is not correct");
    Utils.testJSONExport(download, Utils.getTestExporterJSONPath(TEST_BASE, DOWNLOAD_FULLY_CONFIGURED));
}
Also used : MockValueMap(org.apache.sling.testing.resourceresolver.MockValueMap) Resource(org.apache.sling.api.resource.Resource) MockStyle(com.adobe.cq.wcm.core.components.testing.MockStyle) MockStyle(com.adobe.cq.wcm.core.components.testing.MockStyle) Style(com.day.cq.wcm.api.designer.Style) Download(com.adobe.cq.wcm.core.components.models.Download) Test(org.junit.jupiter.api.Test)

Example 5 with Style

use of com.day.cq.wcm.api.designer.Style in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class YouTubeImplTest method testGetStyleForWrappedResource.

@Test
public void testGetStyleForWrappedResource() {
    YouTubeImpl youTube = getYouTubeUnderTest(PATH_VIDEO_3, page);
    Resource resource = context.resourceResolver().getResource(PATH_VIDEO_3);
    if (resource == null) {
        throw new IllegalStateException("Did you forget to define test resource " + PATH_VIDEO_3 + "?");
    }
    context.contentPolicyMapping(resource.getResourceType(), Collections.singletonMap("test", "foo"));
    Style style = youTube.getStyleForWrappedResource(new ResourceWrapper(resource) {

        @Override
        public String getResourceType() {
            return "overriddenResourceType";
        }
    });
    assertEquals("foo", style.get("test", "bar"));
}
Also used : ResourceWrapper(org.apache.sling.api.resource.ResourceWrapper) Resource(org.apache.sling.api.resource.Resource) Style(com.day.cq.wcm.api.designer.Style) Test(org.junit.jupiter.api.Test)

Aggregations

Style (com.day.cq.wcm.api.designer.Style)15 Resource (org.apache.sling.api.resource.Resource)10 Test (org.junit.jupiter.api.Test)8 Designer (com.day.cq.wcm.api.designer.Designer)4 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)4 ValueMap (org.apache.sling.api.resource.ValueMap)4 MockStyle (com.adobe.cq.wcm.core.components.context.MockStyle)3 Embed (com.adobe.cq.wcm.core.components.models.Embed)3 Page (com.day.cq.wcm.api.Page)3 Template (com.day.cq.wcm.api.Template)3 ContentPolicy (com.day.cq.wcm.api.policies.ContentPolicy)3 LinkHandler (com.adobe.cq.wcm.core.components.internal.link.LinkHandler)2 CoreResourceWrapper (com.adobe.cq.wcm.core.components.internal.resource.CoreResourceWrapper)2 Download (com.adobe.cq.wcm.core.components.models.Download)2 Image (com.adobe.cq.wcm.core.components.models.Image)2 MockStyle (com.adobe.cq.wcm.core.components.testing.MockStyle)2 DownloadResource (com.day.cq.commons.DownloadResource)2 ImageResource (com.day.cq.commons.ImageResource)2 PageManager (com.day.cq.wcm.api.PageManager)2 ContentPolicyMapping (com.day.cq.wcm.api.policies.ContentPolicyMapping)2