use of com.adobe.cq.wcm.core.components.models.ExperienceFragment in project aem-core-wcm-components by adobe.
the class ClientLibrariesImplTest method testUtilsGetXFResourceTypes.
//
// Below are tests for the specific methods in com.adobe.cq.wcm.core.components.internal.Utils
//
@Test
void testUtilsGetXFResourceTypes() {
Resource xfResource = context.currentResource(EXPERIENCE_FRAGMENT_PATH);
ModelFactory modelFactory = mock(ModelFactory.class);
doAnswer(invocation -> {
Object[] args = invocation.getArguments();
Resource resource = (Resource) args[1];
String fragmentPath = resource.getValueMap().get("fragmentVariationPath", String.class);
ExperienceFragment experienceFragment = mock(ExperienceFragment.class);
when(experienceFragment.getLocalizedFragmentVariationPath()).thenReturn(fragmentPath);
return experienceFragment;
}).when(modelFactory).getModelFromWrappedRequest(any(SlingHttpServletRequest.class), any(Resource.class), eq(ExperienceFragment.class));
Set<String> resourceTypes = Utils.getXFResourceTypes(xfResource, context.request(), modelFactory);
Set<String> expectedResourceTypes = new HashSet<>(Arrays.asList("core/wcm/components/page/v2/page", "cq:Page", "core/wcm/components/teaser/v1/teaser", "wcm/foundation/components/responsivegrid"));
assertEquals(expectedResourceTypes, resourceTypes);
}
use of com.adobe.cq.wcm.core.components.models.ExperienceFragment in project aem-core-wcm-components by adobe.
the class ExperienceFragmentImplTest method testValidXFInPageWithLocalizationWithSameCountrySiteLanguage.
/* ----------------- Tests for a site with country-language localization (eu/mysite/en) ----------------------- */
/**
* Site with country-language localization (optional): eu/mysite/en
* XF component is defined in the page
* XF component points to the same country-language branch as the page
*/
@Test
void testValidXFInPageWithLocalizationWithSameCountrySiteLanguage() {
ExperienceFragment experienceFragment = getExperienceFragmentUnderTest(CH_MYSITE_FR_PAGE + "/jcr:content/root/xf-component-30");
assertEquals(XF_NAME, experienceFragment.getName());
Utils.testJSONExport(experienceFragment, Utils.getTestExporterJSONPath(TEST_BASE, "xf30"));
}
use of com.adobe.cq.wcm.core.components.models.ExperienceFragment in project aem-core-wcm-components by adobe.
the class ExperienceFragmentImplTest method testValidXFInPageWithoutLocalization.
/* ------------------------------- Tests for a site with no localization structure ----------------------------- */
/**
* No localization structure
* XF component is defined in the page
* fragmentVariationPath is valid
*/
@Test
void testValidXFInPageWithoutLocalization() {
ExperienceFragment experienceFragment = getExperienceFragmentUnderTest(NO_LOC_PAGE + "/jcr:content/root/xf-component-1");
assertEquals(XF_NAME, experienceFragment.getName());
Utils.testJSONExport(experienceFragment, Utils.getTestExporterJSONPath(TEST_BASE, "xf1"));
}
use of com.adobe.cq.wcm.core.components.models.ExperienceFragment in project aem-core-wcm-components by adobe.
the class ExperienceFragmentImplTest method testValidXFInPageWithLocalizationWithSameBlueprint.
/* ------------------------------- Tests for a site with blueprint / live copy ----------------- */
/**
* Site with region localization (current page is a blueprint)
* XF component is defined in the page
* XF component points to the same region branch as the page
*/
@Test
void testValidXFInPageWithLocalizationWithSameBlueprint() {
ExperienceFragment experienceFragment = getExperienceFragmentUnderTest(BLUEPRINT_PAGE + "/jcr:content/root/xf-component-50");
assertEquals(XF_NAME, experienceFragment.getName());
Utils.testJSONExport(experienceFragment, Utils.getTestExporterJSONPath(TEST_BASE, "xf50"));
}
use of com.adobe.cq.wcm.core.components.models.ExperienceFragment in project aem-core-wcm-components by adobe.
the class ExperienceFragmentImplTest method testEmptyXFInPageWithLocalization.
/**
* Site with language localization
* XF component is defined in the page
* fragmentVariationPath is empty
*/
@Test
void testEmptyXFInPageWithLocalization() {
ExperienceFragment experienceFragment = getExperienceFragmentUnderTest(EN_PAGE + "/jcr:content/root/xf-component-13");
Utils.testJSONExport(experienceFragment, Utils.getTestExporterJSONPath(TEST_BASE, "xf13"));
}
Aggregations