Skip to content

Commit

Permalink
LPD-44292 Test - Take into account all PageElement types
Browse files Browse the repository at this point in the history
  • Loading branch information
ealonso authored and brianchandotcom committed Dec 17, 2024
1 parent 3bcd9aa commit 5c5e537
Showing 1 changed file with 189 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@
import com.liferay.arquillian.extension.junit.bridge.junit.Arquillian;
import com.liferay.headless.admin.site.client.dto.v1_0.PageElement;
import com.liferay.headless.admin.site.client.problem.Problem;
import com.liferay.headless.admin.site.dto.v1_0.DefaultFragmentReference;
import com.liferay.headless.admin.site.dto.v1_0.PageCollectionDefinition;
import com.liferay.headless.admin.site.dto.v1_0.PageCollectionItemDefinition;
import com.liferay.headless.admin.site.dto.v1_0.PageColumnDefinition;
import com.liferay.headless.admin.site.dto.v1_0.PageContainerDefinition;
import com.liferay.headless.admin.site.dto.v1_0.PageDropZoneDefinition;
import com.liferay.headless.admin.site.dto.v1_0.PageFormDefinition;
import com.liferay.headless.admin.site.dto.v1_0.PageFormStepContainerDefinition;
import com.liferay.headless.admin.site.dto.v1_0.PageFormStepDefinition;
import com.liferay.headless.admin.site.dto.v1_0.PageFragmentDropZoneDefinition;
import com.liferay.headless.admin.site.dto.v1_0.PageFragmentInstanceDefinition;
import com.liferay.headless.admin.site.dto.v1_0.PageRowDefinition;
import com.liferay.layout.page.template.model.LayoutPageTemplateStructure;
import com.liferay.layout.page.template.service.LayoutPageTemplateStructureLocalService;
import com.liferay.layout.test.util.LayoutTestUtil;
Expand Down Expand Up @@ -193,6 +205,27 @@ public void testPostSiteSiteByExternalReferenceCodePageElementFragmentCompositio
testPostSiteSiteByExternalReferenceCodePageElementFragmentComposition();
}

@Override
@Test
public void testPostSiteSiteByExternalReferenceCodePageExperiencePageElement()
throws Exception {

super.
testPostSiteSiteByExternalReferenceCodePageExperiencePageElement();

_testPostSiteSiteByExternalReferenceCodePageExperiencePageElementPageCollectionDefinition();
_testPostSiteSiteByExternalReferenceCodePageExperiencePageElementPageCollectionItemDefinition();
_testPostSiteSiteByExternalReferenceCodePageExperiencePageElementPageColumnDefinition();
_testPostSiteSiteByExternalReferenceCodePageExperiencePageElementPageContainerDefinition();
_testPostSiteSiteByExternalReferenceCodePageExperiencePageElementPageDropZoneDefinition();
_testPostSiteSiteByExternalReferenceCodePageExperiencePageElementPageFormDefinition();
_testPostSiteSiteByExternalReferenceCodePageExperiencePageElementPageFormStepDefinition();
_testPostSiteSiteByExternalReferenceCodePageExperiencePageElementPageFormStepContainerDefinition();
_testPostSiteSiteByExternalReferenceCodePageExperiencePageElementPageFragmentDropZoneDefinition();
_testPostSiteSiteByExternalReferenceCodePageExperiencePageElementPageFragmentInstanceDefinition();
_testPostSiteSiteByExternalReferenceCodePageExperiencePageElementPageRowDefinition();
}

@Override
@Test
public void testPutSiteSiteByExternalReferenceCodePageElement()
Expand Down Expand Up @@ -355,6 +388,19 @@ protected PageElement randomPageElement() throws Exception {
segmentsExperience.getExternalReferenceCode(), pageElement);
}

private void
_assertPostSiteSiteByExternalReferenceCodePageExperiencePageElement(
PageElement pageElement)
throws Exception {

PageElement postPageElement =
testPostSiteSiteByExternalReferenceCodePageExperiencePageElement_addPageElement(
pageElement);

assertEquals(pageElement, postPageElement);
assertValid(postPageElement);
}

private LayoutStructure _getLayoutStructure() {
LayoutPageTemplateStructure layoutPageTemplateStructure =
_layoutPageTemplateStructureLocalService.
Expand All @@ -378,6 +424,149 @@ private PageElement _randomPageElement(PageElement.Type type)
return pageElement;
}

private void _testPostSiteSiteByExternalReferenceCodePageExperiencePageElementPageCollectionDefinition()
throws Exception {

PageElement randomPageElement = _randomPageElement(
PageElement.Type.COLLECTION);

randomPageElement.setDefinition(new PageCollectionDefinition());

_assertPostSiteSiteByExternalReferenceCodePageExperiencePageElement(
randomPageElement);
}

private void _testPostSiteSiteByExternalReferenceCodePageExperiencePageElementPageCollectionItemDefinition()
throws Exception {

PageElement randomPageElement = _randomPageElement(
PageElement.Type.COLLECTION_ITEM);

randomPageElement.setDefinition(new PageCollectionItemDefinition());

_assertPostSiteSiteByExternalReferenceCodePageExperiencePageElement(
randomPageElement);
}

private void _testPostSiteSiteByExternalReferenceCodePageExperiencePageElementPageColumnDefinition()
throws Exception {

PageElement randomPageElement = _randomPageElement(
PageElement.Type.COLUMN);

randomPageElement.setDefinition(new PageColumnDefinition());

_assertPostSiteSiteByExternalReferenceCodePageExperiencePageElement(
randomPageElement);
}

private void _testPostSiteSiteByExternalReferenceCodePageExperiencePageElementPageContainerDefinition()
throws Exception {

PageElement randomPageElement = _randomPageElement(
PageElement.Type.CONTAINER);

randomPageElement.setDefinition(new PageContainerDefinition());

_assertPostSiteSiteByExternalReferenceCodePageExperiencePageElement(
randomPageElement);
}

private void _testPostSiteSiteByExternalReferenceCodePageExperiencePageElementPageDropZoneDefinition()
throws Exception {

PageElement randomPageElement = _randomPageElement(
PageElement.Type.DROP_ZONE);

randomPageElement.setDefinition(new PageDropZoneDefinition());

_assertPostSiteSiteByExternalReferenceCodePageExperiencePageElement(
randomPageElement);
}

private void _testPostSiteSiteByExternalReferenceCodePageExperiencePageElementPageFormDefinition()
throws Exception {

PageElement randomPageElement = _randomPageElement(
PageElement.Type.FORM);

randomPageElement.setDefinition(new PageFormDefinition());

_assertPostSiteSiteByExternalReferenceCodePageExperiencePageElement(
randomPageElement);
}

private void _testPostSiteSiteByExternalReferenceCodePageExperiencePageElementPageFormStepContainerDefinition()
throws Exception {

PageElement randomPageElement = _randomPageElement(
PageElement.Type.FORM_STEP_CONTAINER);

randomPageElement.setDefinition(new PageFormStepContainerDefinition());

_assertPostSiteSiteByExternalReferenceCodePageExperiencePageElement(
randomPageElement);
}

private void _testPostSiteSiteByExternalReferenceCodePageExperiencePageElementPageFormStepDefinition()
throws Exception {

PageElement randomPageElement = _randomPageElement(
PageElement.Type.FORM_STEP);

randomPageElement.setDefinition(new PageFormStepDefinition());

_assertPostSiteSiteByExternalReferenceCodePageExperiencePageElement(
randomPageElement);
}

private void _testPostSiteSiteByExternalReferenceCodePageExperiencePageElementPageFragmentDropZoneDefinition()
throws Exception {

PageElement randomPageElement = _randomPageElement(
PageElement.Type.FRAGMENT_DROP_ZONE);

randomPageElement.setDefinition(new PageFragmentDropZoneDefinition());

_assertPostSiteSiteByExternalReferenceCodePageExperiencePageElement(
randomPageElement);
}

private void _testPostSiteSiteByExternalReferenceCodePageExperiencePageElementPageFragmentInstanceDefinition()
throws Exception {

PageElement randomPageElement = _randomPageElement(
PageElement.Type.FRAGMENT);

randomPageElement.setDefinition(
new PageFragmentInstanceDefinition() {
{
setFragmentReference(
new DefaultFragmentReference() {
{
setDefaultFragmentKey(
() -> "BASIC_COMPONENT-heading");
}
});
}
});

_assertPostSiteSiteByExternalReferenceCodePageExperiencePageElement(
randomPageElement);
}

private void _testPostSiteSiteByExternalReferenceCodePageExperiencePageElementPageRowDefinition()
throws Exception {

PageElement randomPageElement = _randomPageElement(
PageElement.Type.ROW);

randomPageElement.setDefinition(new PageRowDefinition());

_assertPostSiteSiteByExternalReferenceCodePageExperiencePageElement(
randomPageElement);
}

private Layout _draftLayout;
private Layout _layout;

Expand Down

0 comments on commit 5c5e537

Please sign in to comment.