Search in sources :

Example 11 with ContentFragment

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 textOnlySingleElement.

@Test
void textOnlySingleElement() {
    ContentFragment fragment = getModelInstanceUnderTest(CF_TEXT_ONLY_SINGLE_ELEMENT);
    assertContentFragment(fragment, TITLE, DESCRIPTION, TEXT_ONLY_TYPE, TEXT_ONLY_NAME, ASSOCIATED_CONTENT, SECOND_TEXT_ONLY);
    Utils.testJSONExport(fragment, Utils.getTestExporterJSONPath(TEST_BASE, CF_TEXT_ONLY_SINGLE_ELEMENT));
}
Also used : DAMContentFragment(com.adobe.cq.wcm.core.components.models.contentfragment.DAMContentFragment) ContentFragment(com.adobe.cq.wcm.core.components.models.contentfragment.ContentFragment) Test(org.junit.jupiter.api.Test)

Example 12 with ContentFragment

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 structuredSingleElementMain.

@Test
void structuredSingleElementMain() {
    when(fragmentRenderService.render(any(Resource.class))).thenReturn(MAIN_CONTENT);
    ContentFragment fragment = getModelInstanceUnderTest(CF_STRUCTURED_SINGLE_ELEMENT_MAIN);
    assertContentFragment(fragment, TITLE, DESCRIPTION, STRUCTURED_TYPE, STRUCTURED_NAME, ASSOCIATED_CONTENT, MAIN);
    Utils.testJSONExport(fragment, Utils.getTestExporterJSONPath(TEST_BASE, CF_STRUCTURED_SINGLE_ELEMENT_MAIN));
}
Also used : DAMContentFragment(com.adobe.cq.wcm.core.components.models.contentfragment.DAMContentFragment) ContentFragment(com.adobe.cq.wcm.core.components.models.contentfragment.ContentFragment) Resource(org.apache.sling.api.resource.Resource) Test(org.junit.jupiter.api.Test)

Example 13 with ContentFragment

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 getElements.

@Test
void getElements() {
    ContentFragment fragment = getModelInstanceUnderTest(CF_TEXT_ONLY);
    final Map<String, DAMContentFragment.DAMContentElement> elements = fragment.getExportedElements();
    assertNotNull(elements);
    assertEquals(2, elements.size());
    assertTrue(elements.containsKey("main"));
    assertTrue(elements.containsKey("second"));
}
Also used : DAMContentFragment(com.adobe.cq.wcm.core.components.models.contentfragment.DAMContentFragment) ContentFragment(com.adobe.cq.wcm.core.components.models.contentfragment.ContentFragment) Test(org.junit.jupiter.api.Test)

Example 14 with ContentFragment

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 getExportedType.

@Test
void getExportedType() {
    ContentFragment fragment = getModelInstanceUnderTest(CF_TEXT_ONLY);
    assertEquals(ContentFragmentImpl.RESOURCE_TYPE, fragment.getExportedType());
}
Also used : DAMContentFragment(com.adobe.cq.wcm.core.components.models.contentfragment.DAMContentFragment) ContentFragment(com.adobe.cq.wcm.core.components.models.contentfragment.ContentFragment) Test(org.junit.jupiter.api.Test)

Example 15 with ContentFragment

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 structuredGetEditorJSON.

@Test
void structuredGetEditorJSON() {
    ContentFragment fragment = getModelInstanceUnderTest(CF_STRUCTURED_MULTIPLE_ELEMENTS);
    String expectedJSON = "{\"title\":\"Test Content Fragment\",\"path\":\"/content/dam/contentfragments/structured\"," + "\"elements\":[\"second\",\"non-existing\",\"main\"],\"associatedContent\":[{\"title\":\"Test Collection\"" + ",\"path\":\"/content/dam/collections/X/X7v6pJAcy5qtkUdXdIxR/test\"}]}";
    assertEquals(fragment.getEditorJSON(), expectedJSON);
}
Also used : DAMContentFragment(com.adobe.cq.wcm.core.components.models.contentfragment.DAMContentFragment) ContentFragment(com.adobe.cq.wcm.core.components.models.contentfragment.ContentFragment) Test(org.junit.jupiter.api.Test)

Aggregations

ContentFragment (com.adobe.cq.wcm.core.components.models.contentfragment.ContentFragment)26 DAMContentFragment (com.adobe.cq.wcm.core.components.models.contentfragment.DAMContentFragment)26 Test (org.junit.jupiter.api.Test)26 Resource (org.apache.sling.api.resource.Resource)3 ComponentExporter (com.adobe.cq.export.json.ComponentExporter)1 StringReader (java.io.StringReader)1