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 testCaching.
/**
* Tests that methods that cache results return the same object on subsequent calls.
*/
@Test
void testCaching() {
ExperienceFragment experienceFragment = getExperienceFragmentUnderTest(NO_LOC_PAGE + "/jcr:content/root/xf-component-1");
assertNotNull(experienceFragment.getName());
assertSame(experienceFragment.getName(), experienceFragment.getName());
assertNotNull(experienceFragment.getCssClassNames());
assertSame(experienceFragment.getCssClassNames(), experienceFragment.getCssClassNames());
assertNotNull(experienceFragment.getExportedItems());
assertSame(experienceFragment.getExportedItems(), experienceFragment.getExportedItems());
assertNotNull(experienceFragment.getLocalizedFragmentVariationPath());
assertSame(experienceFragment.getLocalizedFragmentVariationPath(), experienceFragment.getLocalizedFragmentVariationPath());
}
use of com.adobe.cq.wcm.core.components.models.ExperienceFragment in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ExperienceFragmentImplTest method testUndefinedXFInTemplateWithLocalizationWithDifferentCountryLanguage.
/**
* Site with country-language localization
* XF component is defined in the template
* fragmentVariationPath is undefined
*/
@Test
void testUndefinedXFInTemplateWithLocalizationWithDifferentCountryLanguage() {
ExperienceFragment experienceFragment = getExperienceFragmentUnderTest(PRODUCT_PAGE_TEMPLATE + "/structure/jcr:content/xf-component-22a", US_EN_PAGE);
Utils.testJSONExport(experienceFragment, Utils.getTestExporterJSONPath(TEST_BASE, "xf22a"));
}
use of com.adobe.cq.wcm.core.components.models.ExperienceFragment in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ExperienceFragmentImplTest method testUndefinedXFInTemplateWithLocalization.
/**
* Site with language localization
* XF component is defined in the template
* fragmentVariationPath is undefined
*/
@Test
void testUndefinedXFInTemplateWithLocalization() {
ExperienceFragment experienceFragment = getExperienceFragmentUnderTest(PRODUCT_PAGE_TEMPLATE + "/structure/jcr:content/xf-component-12a", EN_PAGE);
Utils.testJSONExport(experienceFragment, Utils.getTestExporterJSONPath(TEST_BASE, "xf12a"));
}
use of com.adobe.cq.wcm.core.components.models.ExperienceFragment in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ExperienceFragmentImplTest method testValidXFInPageWithLocalizationWithSameCountryLanguage.
/* ------------------------------- Tests for a site with country/language localization (us/en) ----------------- */
/**
* Site with country-language localization
* XF component is defined in the page
* XF component points to the same country-language branch as the page
*/
@Test
void testValidXFInPageWithLocalizationWithSameCountryLanguage() {
ExperienceFragment experienceFragment = getExperienceFragmentUnderTest(US_EN_PAGE + "/jcr:content/root/xf-component-20");
assertEquals(XF_NAME, experienceFragment.getName());
Utils.testJSONExport(experienceFragment, Utils.getTestExporterJSONPath(TEST_BASE, "xf20"));
}
Aggregations