use of com.adobe.cq.wcm.core.components.models.contentfragment.ContentFragment in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ContentFragmentImplTest method textOnlyGetEditorJSON.
@Test
void textOnlyGetEditorJSON() {
ContentFragment fragment = getModelInstanceUnderTest(CF_TEXT_ONLY_MULTIPLE_ELEMENTS);
String expectedJSON = "{\"title\":\"Test Content Fragment\",\"path\":\"/content/dam/contentfragments/text-only\"" + ",\"elements\":[\"second\",\"non-existing\",\"main\"],\"associatedContent\":[{\"title\":\"Test Collection\"" + ",\"path\":\"/content/dam/collections/X/X7v6pJAcy5qtkUdXdIxR/test\"}]}";
assertEquals(fragment.getEditorJSON(), expectedJSON);
}
use of com.adobe.cq.wcm.core.components.models.contentfragment.ContentFragment in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ContentFragmentImplTest method testDataLayerJson.
@Test
void testDataLayerJson() {
Utils.enableDataLayer(context, true);
String expected = "{\"contentfragment-bb4058160c\":{\"@type\":\"core/wcm/components/contentfragment/v1/contentfragment\",\"dc:title\":\"Test Content Fragment\",\"elements\":[{\"xdm:text\":\"<p>Main content</p>\",\"xdm:title\":\"Main\"},{\"xdm:text\":\"Second content\",\"xdm:title\":\"Second\"}]}}";
ContentFragment fragment = getModelInstanceUnderTest(CF_TEXT_ONLY);
assertEquals(Json.createReader(new StringReader(expected)).read(), Json.createReader(new StringReader(fragment.getData().getJson())).read());
}
use of com.adobe.cq.wcm.core.components.models.contentfragment.ContentFragment in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ContentFragmentImplTest method structuredNonExistingPath.
@Test
void structuredNonExistingPath() {
ContentFragment fragment = getModelInstanceUnderTest(CF_STRUCTURED_NON_EXISTING_PATH);
assertNotNull(fragment, "Model shouldn't be null when the path does not exist");
assertNull(fragment.getTitle());
assertNull(fragment.getDescription());
assertNull(fragment.getType());
assertNull(fragment.getElements());
assertNull(fragment.getAssociatedContent());
assertTrue(fragment.getExportedElements().isEmpty());
assertEquals(0, fragment.getExportedElementsOrder().length);
}
use of com.adobe.cq.wcm.core.components.models.contentfragment.ContentFragment in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ContentFragmentImplTest method getElementsType.
@Test
void getElementsType() {
ContentFragment fragment = getModelInstanceUnderTest(CF_TEXT_ONLY);
final Map<String, ? extends ComponentExporter> elements = fragment.getExportedElements();
assertNotNull(elements);
final ComponentExporter mainElement = elements.get("main");
assertEquals("text/html", mainElement.getExportedType());
}
use of com.adobe.cq.wcm.core.components.models.contentfragment.ContentFragment in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ContentFragmentImplTest method textOnlyInvalidPath.
@Test
void textOnlyInvalidPath() {
ContentFragment fragment = getModelInstanceUnderTest(CF_TEXT_ONLY_INVALID_PATH);
assertNotNull(fragment, "Model shouldn't be null when the path is not a content fragment");
}
Aggregations