Search in sources :

Example 1 with Title

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

the class ComponentDataImplTest method getDataLayerJsonWhenDataLayerEnabled.

@Test
void getDataLayerJsonWhenDataLayerEnabled() {
    Title title = getTitleUnderTest(TITLE_RESOURCE_JCR_TITLE, true);
    assertNotNull(title.getData());
    String expected = "{\"title-7968bee19c\":{\"@type\":\"core/wcm/components/title/v1/title\",\"dc:title\":\"Hello World\",\"repo:modifyDate\":\"2016-01-13T15:14:51Z\"}}";
    assertEquals(Json.createReader(new StringReader(expected)).read(), Json.createReader(new StringReader(title.getData().getJson())).read());
    Utils.testJSONExport(title, Utils.getTestExporterJSONPath(TEST_BASE, TITLE_RESOURCE_JCR_TITLE));
}
Also used : StringReader(java.io.StringReader) Title(com.adobe.cq.wcm.core.components.models.Title) Test(org.junit.jupiter.api.Test)

Example 2 with Title

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

the class ComponentDataImplTest method getDataLayerJsonWhenDataLayerDisabled.

@Test
void getDataLayerJsonWhenDataLayerDisabled() {
    Title title = getTitleUnderTest(TITLE_RESOURCE_JCR_TITLE, false);
    assertNull(title.getData());
}
Also used : Title(com.adobe.cq.wcm.core.components.models.Title) Test(org.junit.jupiter.api.Test)

Example 3 with Title

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

the class TitleImplTest method testGetTitleFromCurrentPageWithWrongElementInfo.

@Test
protected void testGetTitleFromCurrentPageWithWrongElementInfo() {
    Title title = getTitleUnderTest(TITLE_WRONGTYPE);
    assertNull(title.getType());
    Utils.testJSONExport(title, Utils.getTestExporterJSONPath(testBase, TITLE_WRONGTYPE));
}
Also used : Title(com.adobe.cq.wcm.core.components.models.Title) Test(org.junit.jupiter.api.Test)

Example 4 with Title

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

the class TitleImplTest method testV2JSONExport.

@Test
@SuppressWarnings("deprecation")
protected void testV2JSONExport() {
    Title title = getTitleUnderTest(TITLE_RESOURCE_JCR_TITLE_V2);
    assertNull(title.getLinkURL());
    Utils.testJSONExport(title, Utils.getTestExporterJSONPath(testBase, TITLE_RESOURCE_JCR_TITLE_V2));
}
Also used : Title(com.adobe.cq.wcm.core.components.models.Title) Test(org.junit.jupiter.api.Test)

Example 5 with Title

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

the class TitleImplTest method testGetTitleFromResourceWithElementInfo.

@Test
protected void testGetTitleFromResourceWithElementInfo() {
    Title title = getTitleUnderTest(TITLE_RESOURCE_JCR_TITLE_TYPE);
    assertEquals("Hello World", title.getText());
    assertEquals("h2", title.getType());
    Utils.testJSONExport(title, Utils.getTestExporterJSONPath(testBase, TITLE_RESOURCE_JCR_TITLE_TYPE));
}
Also used : Title(com.adobe.cq.wcm.core.components.models.Title) Test(org.junit.jupiter.api.Test)

Aggregations

Title (com.adobe.cq.wcm.core.components.models.Title)17 Test (org.junit.jupiter.api.Test)17 Page (com.day.cq.wcm.api.Page)1 StringReader (java.io.StringReader)1 Resource (org.apache.sling.api.resource.Resource)1