use of com.agiletec.aps.system.services.page.IPage in project entando-core by entando.
the class TestPageConfigAction method testJoinRemoveWidget.
private void testJoinRemoveWidget(String widgetTypeCode) throws Throwable {
String pageCode = "pagina_1";
int frame = 1;
IPage pagina_1 = this._pageManager.getDraftPage(pageCode);
try {
assertNull(pagina_1.getWidgets()[frame]);
String result = this.executeJoinWidget(pageCode, frame, widgetTypeCode, "pageManagerCoach");
assertEquals("pageTree", result);
result = this.executeJoinWidget(pageCode, frame, widgetTypeCode, "admin");
assertEquals(Action.SUCCESS, result);
pagina_1 = this._pageManager.getDraftPage(pageCode);
assertNotNull(pagina_1.getWidgets()[frame]);
assertEquals(widgetTypeCode, pagina_1.getWidgets()[frame].getType().getCode());
result = this.executeTrashWidget(pageCode, frame, "admin");
assertEquals(Action.SUCCESS, result);
pagina_1 = this._pageManager.getDraftPage(pageCode);
assertNotNull(pagina_1.getWidgets()[frame]);
result = this.executeDeleteWidget(pageCode, frame, "admin");
assertEquals(Action.SUCCESS, result);
pagina_1 = this._pageManager.getDraftPage(pageCode);
assertNull(pagina_1.getWidgets()[frame]);
} catch (Throwable t) {
throw t;
} finally {
pagina_1.getWidgets()[frame] = null;
this._pageManager.updatePage(pagina_1);
}
}
use of com.agiletec.aps.system.services.page.IPage in project entando-core by entando.
the class TestPageConfigAction method testJoinWidget.
public void testJoinWidget() throws Throwable {
String pageCode = "pagina_1";
int frame = 1;
IPage pagina_1 = this._pageManager.getDraftPage(pageCode);
try {
assertNull(pagina_1.getWidgets()[frame]);
String result = this.executeJoinWidget(pageCode, frame, "leftmenu", "admin");
assertEquals("configureSpecialWidget", result);
result = this.executeJoinWidget(pageCode, frame, "leftmenu", "pageManagerCoach");
assertEquals("pageTree", result);
assertEquals(1, this.getAction().getActionErrors().size());
} catch (Throwable t) {
throw t;
} finally {
pagina_1.getWidgets()[frame] = null;
this._pageManager.updatePage(pagina_1);
}
}
use of com.agiletec.aps.system.services.page.IPage in project entando-core by entando.
the class TestActivityStream method addPage.
private void addPage(String pageCode) throws Throwable {
assertNull(this.pageManager.getDraftPage(pageCode));
try {
IPage root = this.pageManager.getOnlineRoot();
Map<String, String> params = new HashMap<>();
params.put("strutsAction", String.valueOf(ApsAdminSystemConstants.ADD));
params.put("parentPageCode", root.getCode());
List<Lang> langs = this.langManager.getLangs();
for (Lang lang : langs) {
params.put("lang" + lang.getCode(), "Page " + lang.getDescr());
}
params.put("model", "home");
params.put("group", Group.FREE_GROUP_NAME);
params.put("pageCode", pageCode);
String result = this.executeSave(params, "admin");
assertEquals(Action.SUCCESS, result);
IPage addedPage = this.pageManager.getDraftPage(pageCode);
assertNotNull(addedPage);
} catch (Throwable t) {
throw t;
}
}
use of com.agiletec.aps.system.services.page.IPage in project entando-core by entando.
the class TestPageAction method testValidateSavePage.
public void testValidateSavePage() throws Throwable {
String pageCode = "pagina_test";
String longPageCode = "very_long_page_code__very_long_page_code";
assertNull(this._pageManager.getDraftPage(pageCode));
assertNull(this._pageManager.getDraftPage(longPageCode));
try {
IPage root = this._pageManager.getDraftRoot();
Map<String, String> params = new HashMap<String, String>();
params.put("strutsAction", String.valueOf(ApsAdminSystemConstants.ADD));
String result = this.executeSave(params, "admin");
assertEquals(Action.INPUT, result);
Map<String, List<String>> fieldErrors = this.getAction().getFieldErrors();
assertEquals(6, fieldErrors.size());
assertTrue(fieldErrors.containsKey("pageCode"));
assertTrue(fieldErrors.containsKey("parentPageCode"));
assertTrue(fieldErrors.containsKey("model"));
assertTrue(fieldErrors.containsKey("group"));
assertTrue(fieldErrors.containsKey("langit"));
assertTrue(fieldErrors.containsKey("langen"));
params.put("parentPageCode", root.getCode());
result = this.executeSave(params, "admin");
assertEquals(Action.INPUT, result);
fieldErrors = this.getAction().getFieldErrors();
assertEquals(5, fieldErrors.size());
assertTrue(fieldErrors.containsKey("pageCode"));
assertTrue(fieldErrors.containsKey("model"));
assertTrue(fieldErrors.containsKey("group"));
assertTrue(fieldErrors.containsKey("langit"));
assertTrue(fieldErrors.containsKey("langen"));
params.put("langit", "Pagina Test");
params.put("model", "home");
result = this.executeSave(params, "admin");
assertEquals(Action.INPUT, result);
fieldErrors = this.getAction().getFieldErrors();
assertEquals(3, fieldErrors.size());
assertTrue(fieldErrors.containsKey("pageCode"));
assertTrue(fieldErrors.containsKey("group"));
assertTrue(fieldErrors.containsKey("langen"));
assertNotNull(this._pageManager.getDraftPage("pagina_1"));
params.put("langen", "Test Page");
params.put("group", Group.FREE_GROUP_NAME);
// page already present
params.put("pageCode", "pagina_1");
result = this.executeSave(params, "admin");
assertEquals(Action.INPUT, result);
fieldErrors = this.getAction().getFieldErrors();
assertEquals(1, fieldErrors.size());
assertTrue(fieldErrors.containsKey("pageCode"));
params.put("pageCode", longPageCode);
result = this.executeSave(params, "admin");
assertEquals(Action.INPUT, result);
fieldErrors = this.getAction().getFieldErrors();
assertEquals(1, fieldErrors.size());
assertTrue(fieldErrors.containsKey("pageCode"));
// very long title
params.put("langen", String.join("", Collections.nCopies(71, "x")));
result = this.executeSave(params, "admin");
assertEquals(Action.INPUT, result);
fieldErrors = this.getAction().getFieldErrors();
assertEquals(2, fieldErrors.size());
assertTrue(fieldErrors.containsKey("pageCode"));
assertTrue(fieldErrors.containsKey("langen"));
} catch (Throwable t) {
this._pageManager.deletePage(pageCode);
this._pageManager.deletePage(longPageCode);
throw t;
}
}
use of com.agiletec.aps.system.services.page.IPage in project entando-core by entando.
the class TestPageAction method testSavePage_Draft_2.
public void testSavePage_Draft_2() throws Throwable {
String pageCode = "pagina_test_2";
assertNull(this._pageManager.getDraftPage(pageCode));
try {
IPage root = this._pageManager.getDraftRoot();
Map<String, String> params = new HashMap<String, String>();
params.put("strutsAction", String.valueOf(ApsAdminSystemConstants.ADD));
params.put("parentPageCode", root.getCode());
params.put("langit", "Pagina Test 2");
params.put("langen", "Test Page 2");
params.put("model", "internal");
params.put("group", Group.FREE_GROUP_NAME);
params.put("pageCode", pageCode);
String result = this.executeSave(params, "admin");
assertEquals(Action.SUCCESS, result);
IPage addedPage = this._pageManager.getDraftPage(pageCode);
assertNotNull(addedPage);
this.executeSetDefaultWidgets(params, "admin");
addedPage = this._pageManager.getDraftPage(pageCode);
assertNotNull(addedPage);
assertEquals("Pagina Test 2", addedPage.getMetadata().getTitles().getProperty("it"));
Widget[] showlets = addedPage.getWidgets();
assertEquals(addedPage.getMetadata().getModel().getFrames().length, showlets.length);
for (int i = 0; i < showlets.length; i++) {
Widget widget = showlets[i];
if (i == 3) {
assertNotNull(widget);
WidgetType type = widget.getType();
assertEquals("leftmenu", type.getCode());
assertEquals(1, type.getTypeParameters().size());
assertNull(type.getConfig());
ApsProperties config = widget.getConfig();
assertEquals(1, config.size());
assertEquals("code(homepage).subtree(1)", config.getProperty("navSpec"));
} else {
assertNull(widget);
}
}
} catch (Throwable t) {
throw t;
} finally {
this._pageManager.deletePage(pageCode);
}
}
Aggregations