Search in sources :

Example 6 with Download

use of com.adobe.cq.wcm.core.components.models.Download 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 7 with Download

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

the class DownloadImplTest method testDisplayAllFileMetadata.

@Test
void testDisplayAllFileMetadata() {
    Download download = getDownloadUnderTest(DOWNLOAD_1, Download.PN_DISPLAY_FILENAME, true, Download.PN_DISPLAY_FORMAT, true, Download.PN_DISPLAY_SIZE, true);
    assertTrue(download.displayFilename(), "Display of filename is not enabled");
    assertTrue(download.displaySize(), "Display of file size is not enabled");
    assertTrue(download.displayFormat(), "Display of file format is not enabled");
    Utils.testJSONExport(download, Utils.getTestExporterJSONPath(TEST_BASE, DOWNLOAD_FULLY_CONFIGURED));
}
Also used : Download(com.adobe.cq.wcm.core.components.models.Download) Test(org.junit.jupiter.api.Test)

Example 8 with Download

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

the class DownloadImplTest method testDownloadWithHiddenTitleLink.

@Test
void testDownloadWithHiddenTitleLink() {
    Resource mockResource = mock(Resource.class);
    MockValueMap mockValueMap = new MockValueMap(mockResource);
    mockValueMap.put(Download.PN_HIDE_TITLE_LINK, true);
    Style mockStyle = new MockStyle(mockResource, mockValueMap);
    Download download = getDownloadUnderTest(DOWNLOAD_1, mockStyle);
    assertTrue(download.hideTitleLink(), "Expected title link to be hidden");
}
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 9 with Download

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

the class DownloadImplTest method testFullyConfiguredDownload_assetWithoutSizeProperty.

@Test
void testFullyConfiguredDownload_assetWithoutSizeProperty() {
    context.load().json(TEST_BASE + TEST_CONTENT_DAM_WITHOUT_SIZE_PROP_JSON, "/content/dam/core/documents_without_size");
    context.load().binaryFile(TEST_BASE + "/" + PDF_BINARY_NAME, PDF_ASSET_WITHOUT_SIZE_PROP_PATH + "/jcr:content/renditions/original");
    Download download = getDownloadUnderTest(DOWNLOAD_4);
    assertEquals(TITLE, download.getTitle());
    assertEquals(DESCRIPTION, download.getDescription());
    assertEquals(CONTEXT_PATH + PDF_ASSET_WITHOUT_SIZE_PROP_PATH + "." + DownloadServlet.SELECTOR + ".pdf", download.getUrl());
    assertEquals(PDF_FILENAME, download.getFilename());
    assertEquals(PDF_EXTENSION, download.getExtension());
    assertEquals(PDF_FILESIZE_STRING, download.getSize());
    assertEquals(PDF_FORMAT_STRING, download.getFormat());
    assertEquals(COMPONENT_ACTION_TEXT, download.getActionText());
}
Also used : Download(com.adobe.cq.wcm.core.components.models.Download) Test(org.junit.jupiter.api.Test)

Example 10 with Download

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

the class DownloadImplTest method testDownloadWithCustomActionText.

@Test
void testDownloadWithCustomActionText() {
    Download download = getDownloadUnderTest(DOWNLOAD_1, Download.PN_ACTION_TEXT, STYLE_ACTION_TEST);
    assertEquals(COMPONENT_ACTION_TEXT, download.getActionText(), "Expected action text is not correct");
    Utils.testJSONExport(download, Utils.getTestExporterJSONPath(TEST_BASE, DOWNLOAD_FULLY_CONFIGURED));
}
Also used : Download(com.adobe.cq.wcm.core.components.models.Download) Test(org.junit.jupiter.api.Test)

Aggregations

Download (com.adobe.cq.wcm.core.components.models.Download)10 Test (org.junit.jupiter.api.Test)10 MockStyle (com.adobe.cq.wcm.core.components.testing.MockStyle)2 Style (com.day.cq.wcm.api.designer.Style)2 Resource (org.apache.sling.api.resource.Resource)2 MockValueMap (org.apache.sling.testing.resourceresolver.MockValueMap)2