Search in sources :

Example 71 with Image

use of com.adobe.cq.wcm.core.components.models.Image in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class ImageImplTest method testDMImageOneSmartSize.

protected void testDMImageOneSmartSize(String resourceType) {
    context.contentPolicyMapping(resourceType, new HashMap<String, Object>() {

        {
            put(Image.PN_DESIGN_DYNAMIC_MEDIA_ENABLED, true);
            put(Image.PN_DESIGN_ALLOWED_RENDITION_WIDTHS, new int[] { 600 });
        }
    });
    Image image = getImageUnderTest(IMAGE32_PATH);
    assertTrue(image.isDmImage());
    Utils.testJSONExport(image, Utils.getTestExporterJSONPath(testBase, IMAGE32_PATH + "-one-smart-size"));
}
Also used : Image(com.adobe.cq.wcm.core.components.models.Image)

Example 72 with Image

use of com.adobe.cq.wcm.core.components.models.Image in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class ImageImplTest method testGetDataLayerJson.

protected void testGetDataLayerJson(String resourceType) {
    Image image = getImageUnderTest(IMAGE6_PATH);
    assertNotNull(image.getData());
    String expected = "{\"image-db7ae5b54e\":{\"@type\":\"" + resourceType + "\",\"repo:modifyDate\":\"2017-03-20T08:33:42Z\",\"dc:title\":\"Adobe Systems Logo and Wordmark\",\"xdm:linkURL\":\"/core/content/test-image.html\",\"image\":{\"repo:id\":\"60a1a56e-f3f4-4021-a7bf-ac7a51f0ffe5\",\"repo:modifyDate\":\"2017-03-20T10:20:39Z\",\"@type\":\"image/gif\",\"repo:path\":\"/content/dam/core/images/Adobe_Systems_logo_and_wordmark.gif\",\"xdm:smartTags\":{\"nature\":0.74,\"lake\":0.79,\"water\":0.78,\"landscape\":0.75}}}}";
    assertEquals(Json.createReader(new StringReader(expected)).read(), Json.createReader(new StringReader(image.getData().getJson())).read());
}
Also used : StringReader(java.io.StringReader) Image(com.adobe.cq.wcm.core.components.models.Image)

Example 73 with Image

use of com.adobe.cq.wcm.core.components.models.Image in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class ImageImplTest method testImageWithOneSmartSize.

@Test
@Override
protected void testImageWithOneSmartSize() {
    context.contentPolicyMapping(resourceType, "allowedRenditionWidths", new int[] { 600 });
    Image image = getImageUnderTest(AbstractImageTest.IMAGE3_PATH);
    assertArrayEquals(new int[] { 600 }, image.getWidths());
    assertFalse(image.isLazyEnabled());
    Utils.testJSONExport(image, Utils.getTestExporterJSONPath(testBase, AbstractImageTest.IMAGE3_PATH));
}
Also used : Image(com.adobe.cq.wcm.core.components.models.Image) AbstractImageTest(com.adobe.cq.wcm.core.components.internal.models.v1.AbstractImageTest) Test(org.junit.jupiter.api.Test)

Example 74 with Image

use of com.adobe.cq.wcm.core.components.models.Image in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class ImageImplTest method testDMImageWithImageModifiers.

protected void testDMImageWithImageModifiers(String resourceType) {
    context.contentPolicyMapping(resourceType, Image.PN_DESIGN_DYNAMIC_MEDIA_ENABLED, true);
    Image image = getImageUnderTest(IMAGE34_PATH);
    assertTrue(image.isDmImage());
    Utils.testJSONExport(image, Utils.getTestExporterJSONPath(testBase, IMAGE34_PATH));
}
Also used : Image(com.adobe.cq.wcm.core.components.models.Image)

Example 75 with Image

use of com.adobe.cq.wcm.core.components.models.Image in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class ImageImplTest method testDMImageWithImagePresetTwoSmartSizes.

protected void testDMImageWithImagePresetTwoSmartSizes(String resourceType) {
    context.contentPolicyMapping(resourceType, new HashMap<String, Object>() {

        {
            put(Image.PN_DESIGN_DYNAMIC_MEDIA_ENABLED, true);
            put(Image.PN_DESIGN_ALLOWED_RENDITION_WIDTHS, new int[] { 600, 800 });
        }
    });
    Image image = getImageUnderTest(IMAGE33_PATH);
    assertTrue(image.isDmImage());
    Utils.testJSONExport(image, Utils.getTestExporterJSONPath(testBase, IMAGE33_PATH + "-two-smart-sizes"));
}
Also used : Image(com.adobe.cq.wcm.core.components.models.Image)

Aggregations

Image (com.adobe.cq.wcm.core.components.models.Image)84 Test (org.junit.jupiter.api.Test)57 AbstractImageTest (com.adobe.cq.wcm.core.components.internal.models.v1.AbstractImageTest)46 Test (org.junit.Test)5 Matchers.anyString (org.mockito.Matchers.anyString)5 Page (com.day.cq.wcm.api.Page)3 PageManager (com.day.cq.wcm.api.PageManager)3 Resource (org.apache.sling.api.resource.Resource)3 Link (com.adobe.cq.wcm.core.components.commons.link.Link)2 LinkHandler (com.adobe.cq.wcm.core.components.internal.link.LinkHandler)2 CoreResourceWrapper (com.adobe.cq.wcm.core.components.internal.resource.CoreResourceWrapper)2 ImageArea (com.adobe.cq.wcm.core.components.models.ImageArea)2 Teaser (com.adobe.cq.wcm.core.components.models.Teaser)2 DownloadResource (com.day.cq.commons.DownloadResource)2 ImageResource (com.day.cq.commons.ImageResource)2 Template (com.day.cq.wcm.api.Template)2 Style (com.day.cq.wcm.api.designer.Style)2 StringReader (java.io.StringReader)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2