Search in sources :

Example 1 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 structuredNonExistingVariation.

@Test
void structuredNonExistingVariation() {
    when(fragmentRenderService.render(any(Resource.class))).thenReturn(MAIN_CONTENT);
    ContentFragment fragment = getModelInstanceUnderTest(CF_STRUCTURED_NON_EXISTING_VARIATION);
    assertContentFragment(fragment, TITLE, DESCRIPTION, STRUCTURED_TYPE, STRUCTURED_NAME, ASSOCIATED_CONTENT, MAIN, SECOND_STRUCTURED);
    Utils.testJSONExport(fragment, Utils.getTestExporterJSONPath(TEST_BASE, CF_STRUCTURED_NON_EXISTING_VARIATION));
}
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 2 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 structuredNoPath.

@Test
void structuredNoPath() {
    ContentFragment fragment = getModelInstanceUnderTest(CF_STRUCTURED_NO_PATH);
    assertNotNull(fragment, "Model shouldn't be null when no path is set");
}
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 3 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 structuredNestedModel.

@Test
void structuredNestedModel() {
    ContentFragment fragment = getModelInstanceUnderTest(CF_STRUCTURED_NESTED_MODEL);
    assertContentFragment(fragment, TITLE, DESCRIPTION, STRUCTURED_TYPE_NESTED, STRUCTURED_NESTED_NAME, ASSOCIATED_CONTENT, MAIN, SECOND_STRUCTURED);
    Utils.testJSONExport(fragment, Utils.getTestExporterJSONPath(TEST_BASE, CF_STRUCTURED_NESTED_MODEL));
}
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 4 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 getParagraphOfSingleTextDisplayMode.

@Test
void getParagraphOfSingleTextDisplayMode() {
    when(fragmentRenderService.render(any(Resource.class))).thenReturn(MAIN_CONTENT);
    ContentFragment contentFragment = getModelInstanceUnderTest(CF_STRUCTURED_SINGLE_ELEMENT_MAIN);
    assertArrayEquals(new String[] { MAIN_CONTENT }, contentFragment.getParagraphs());
}
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 5 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 structuredWithVariationGetEditorJSON.

@Test
void structuredWithVariationGetEditorJSON() {
    ContentFragment fragment = getModelInstanceUnderTest(CF_STRUCTURED_VARIATION);
    String expectedJSON = "{\"title\":\"Test Content Fragment\",\"path\":\"/content/dam/contentfragments/structured\"," + "\"variation\":\"teaser\",\"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