use of com.adobe.cq.wcm.core.components.models.ExperienceFragment in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ExperienceFragmentImplTest method testValidXFInPageWithLocalizationWithDifferentCountrySiteLanguage.
/**
* Site with country-language localization (optional): eu/mysite/en
* XF component is defined in the page
* XF component points to a different country-language branch as the page
*/
@Test
void testValidXFInPageWithLocalizationWithDifferentCountrySiteLanguage() {
ExperienceFragment experienceFragment = getExperienceFragmentUnderTest(CH_MYSITE_FR_PAGE + "/jcr:content/root/xf-component-31");
assertEquals(XF_NAME, experienceFragment.getName());
Utils.testJSONExport(experienceFragment, Utils.getTestExporterJSONPath(TEST_BASE, "xf31"));
}
use of com.adobe.cq.wcm.core.components.models.ExperienceFragment in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ExperienceFragmentImplTest method testUndefinedXFInPageWithLocalizationWithDifferentCountrySiteLanguage.
/**
* Site with country-language localization (optional): eu/mysite/en
* XF component is defined in the page
* fragmentVariationPath is undefined
*/
@Test
void testUndefinedXFInPageWithLocalizationWithDifferentCountrySiteLanguage() {
ExperienceFragment experienceFragment = getExperienceFragmentUnderTest(CH_MYSITE_FR_PAGE + "/jcr:content/root/xf-component-32");
Utils.testJSONExport(experienceFragment, Utils.getTestExporterJSONPath(TEST_BASE, "xf32"));
}
use of com.adobe.cq.wcm.core.components.models.ExperienceFragment in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ExperienceFragmentImplTest method testXFWithItems.
/**
* XF with content
*/
@Test
void testXFWithItems() {
ExperienceFragment experienceFragment = getExperienceFragmentUnderTest(PRODUCT_PAGE_TEMPLATE + "/structure/jcr:content/xf-component-70", LIVECOPY_PAGE);
assertEquals("header", experienceFragment.getName());
Utils.testJSONExport(experienceFragment, Utils.getTestExporterJSONPath(TEST_BASE, "xf70"));
}
use of com.adobe.cq.wcm.core.components.models.ExperienceFragment in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ExperienceFragmentImplTest method testEmptyXFInPageWithoutLocalization.
/**
* No localization structure
* XF component is defined in the page
* fragmentVariationPath is empty
*/
@Test
void testEmptyXFInPageWithoutLocalization() {
ExperienceFragment experienceFragment = getExperienceFragmentUnderTest(NO_LOC_PAGE + "/jcr:content/root/xf-component-3");
Utils.testJSONExport(experienceFragment, Utils.getTestExporterJSONPath(TEST_BASE, "xf3"));
}
use of com.adobe.cq.wcm.core.components.models.ExperienceFragment in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ExperienceFragmentDataImpl method getLocalizedFragmentVariationPath.
/**
* Returns the localized path of the experience fragment variation if the experience fragment resource is defined
* in a template.
*
* @return Localized experience fragment variation path
* @see ExperienceFragment#getLocalizedFragmentVariationPath()
*/
@Nullable
public String getLocalizedFragmentVariationPath() {
if (localizedFragmentVariationPath != null) {
return localizedFragmentVariationPath;
}
// get the configured fragment variation path
String fragmentVariationPath = resource.getValueMap().get(ExperienceFragment.PN_FRAGMENT_VARIATION_PATH, String.class);
if (currentPage != null && inTemplate()) {
final Resource pageResource = Optional.ofNullable(currentPage).map(p -> p.adaptTo(Resource.class)).orElse(null);
final String currentPageRootPath = pageResource != null ? LocalizationUtils.getLocalizationRoot(pageResource, resourceResolver, languageManager, relationshipManager) : null;
// we should use getLocalizationRoot instead of getXfLocalizationRoot once the XF UI supports creating Live and Language Copies
String xfRootPath = getXfLocalizationRoot(fragmentVariationPath, currentPageRootPath);
if (StringUtils.isNotEmpty(currentPageRootPath) && StringUtils.isNotEmpty(xfRootPath)) {
String xfRelativePath = StringUtils.substring(fragmentVariationPath, xfRootPath.length());
String localizedXfRootPath = StringUtils.replace(currentPageRootPath, CONTENT_ROOT, ExperienceFragmentsConstants.CONTENT_PATH, 1);
localizedFragmentVariationPath = StringUtils.join(localizedXfRootPath, xfRelativePath, PATH_DELIMITER_CHAR, NN_CONTENT);
}
}
String xfContentPath = String.join(Character.toString(PATH_DELIMITER_CHAR), fragmentVariationPath, NN_CONTENT);
if (!resourceExists(localizedFragmentVariationPath) && resourceExists(xfContentPath)) {
localizedFragmentVariationPath = xfContentPath;
}
if (!isExperienceFragmentVariation(localizedFragmentVariationPath)) {
localizedFragmentVariationPath = null;
}
return localizedFragmentVariationPath;
}
Aggregations