use of com.adobe.cq.wcm.core.components.models.ExperienceFragment in project aem-core-wcm-components by Adobe-Marketing-Cloud.
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-Marketing-Cloud.
the class ExperienceFragmentImplTest method testValidXFInTemplateWithLocalizationWithSameCountryLanguage.
/**
* Site with country-language localization
* XF component is defined in the template
* XF component points to the same country-language branch as the page
*/
@Test
void testValidXFInTemplateWithLocalizationWithSameCountryLanguage() {
ExperienceFragment experienceFragment = getExperienceFragmentUnderTest(PRODUCT_PAGE_TEMPLATE + "/structure/jcr:content/xf-component-20a", US_EN_PAGE);
assertEquals(XF_NAME, experienceFragment.getName());
Utils.testJSONExport(experienceFragment, Utils.getTestExporterJSONPath(TEST_BASE, "xf20a"));
}
use of com.adobe.cq.wcm.core.components.models.ExperienceFragment in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ExperienceFragmentImplTest method testValidXFInPageWithLocalizationWithDifferentLivecopy.
/**
* Site with region localization (current page is a livecopy)
* XF component is defined in the page
* XF component points to a different region branch as the page
*/
@Test
void testValidXFInPageWithLocalizationWithDifferentLivecopy() {
ExperienceFragment experienceFragment = getExperienceFragmentUnderTest(LIVECOPY_PAGE + "/jcr:content/root/xf-component-61");
assertEquals(XF_NAME, experienceFragment.getName());
Utils.testJSONExport(experienceFragment, Utils.getTestExporterJSONPath(TEST_BASE, "xf61"));
}
use of com.adobe.cq.wcm.core.components.models.ExperienceFragment in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ExperienceFragmentImplTest method testValidXFInPageWithLocalizationWithDifferentCountryLanguage.
/**
* Site with country-language localization
* XF component is defined in the page
* XF component points to a different country-language branch as the page
*/
@Test
void testValidXFInPageWithLocalizationWithDifferentCountryLanguage() {
ExperienceFragment experienceFragment = getExperienceFragmentUnderTest(US_EN_PAGE + "/jcr:content/root/xf-component-21");
assertEquals(XF_NAME, experienceFragment.getName());
Utils.testJSONExport(experienceFragment, Utils.getTestExporterJSONPath(TEST_BASE, "xf21"));
}
use of com.adobe.cq.wcm.core.components.models.ExperienceFragment in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ExperienceFragmentImplTest method testValidXFInTemplateWithLocalizationWithDifferentLivecopy.
/**
* Site with region localization (current page is a livecopy)
* XF component is defined in the template
* XF component points to a different region branch as the page
*/
@Test
void testValidXFInTemplateWithLocalizationWithDifferentLivecopy() {
ExperienceFragment experienceFragment = getExperienceFragmentUnderTest(PRODUCT_PAGE_TEMPLATE + "/structure/jcr:content/xf-component-61a", LIVECOPY_PAGE);
assertEquals(XF_NAME, experienceFragment.getName());
Utils.testJSONExport(experienceFragment, Utils.getTestExporterJSONPath(TEST_BASE, "xf61a"));
}
Aggregations