use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.
the class TestNavigatorWidgetConfigAction method testFailureAddExpression_1.
public void testFailureAddExpression_1() throws Throwable {
Map<String, String> params = new HashMap<String, String>();
params.put("pageCode", "pagina_2");
params.put("frame", "3");
params.put("widgetTypeCode", "leftmenu");
params.put("navSpec", "parent.subtree(2)+abs(1).subtree(2)+current");
String result = this.executeAddExpression("admin", params);
assertEquals(Action.INPUT, result);
ActionSupport action = this.getAction();
Map<String, List<String>> fieldErrors = action.getFieldErrors();
assertEquals(1, fieldErrors.size());
assertEquals(1, fieldErrors.get("specId").size());
NavigatorWidgetConfigAction navAction = (NavigatorWidgetConfigAction) action;
Widget widget = navAction.getWidget();
assertNotNull(widget);
ApsProperties props = widget.getConfig();
assertEquals(0, props.size());
assertEquals("parent.subtree(2)+abs(1).subtree(2)+current", navAction.getNavSpec());
assertEquals(3, navAction.getExpressions().size());
}
use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.
the class TestNavigatorWidgetConfigAction method testFailureAddExpression_4.
public void testFailureAddExpression_4() throws Throwable {
Map<String, String> params = new HashMap<String, String>();
params.put("pageCode", "pagina_2");
params.put("frame", "3");
params.put("widgetTypeCode", "leftmenu");
params.put("navSpec", "");
params.put("specId", "5");
params.put("specCode", " ");
params.put("operatorId", "3");
params.put("operatorSubtreeLevel", "-1");
String result = this.executeAddExpression("admin", params);
assertEquals(Action.INPUT, result);
ActionSupport action = this.getAction();
assertEquals(2, action.getActionErrors().size());
NavigatorWidgetConfigAction navAction = (NavigatorWidgetConfigAction) action;
Widget widget = navAction.getWidget();
assertNotNull(widget);
ApsProperties props = widget.getConfig();
assertEquals(0, props.size());
assertEquals("", navAction.getNavSpec());
assertEquals(0, navAction.getExpressions().size());
}
use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.
the class TestNavigatorWidgetConfigAction method testFailureSaveEmptyExpression.
public void testFailureSaveEmptyExpression() throws Throwable {
String pageCode = "pagina_2";
int frame = 3;
IPage page = this._pageManager.getDraftPage(pageCode);
Widget widget = page.getWidgets()[frame];
assertNull(widget);
try {
this.setUserOnSession("admin");
this.initAction("/do/Page/SpecialWidget/Navigator", "saveNavigatorConfig");
this.addParameter("pageCode", pageCode);
this.addParameter("frame", String.valueOf(frame));
this.addParameter("widgetTypeCode", "leftmenu");
this.addParameter("navSpec", "");
String result = this.executeAction();
assertEquals("input", result);
NavigatorWidgetConfigAction action = (NavigatorWidgetConfigAction) this.getAction();
assertEquals(1, action.getActionErrors().size());
} catch (Throwable t) {
throw t;
} finally {
page = this._pageManager.getDraftPage(pageCode);
page.getWidgets()[frame] = null;
this._pageManager.updatePage(page);
}
}
use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.
the class TestNavigatorWidgetConfigAction method testExecuteMoveExpression_2.
public void testExecuteMoveExpression_2() throws Throwable {
Map<String, String> params = new HashMap<String, String>();
params.put("pageCode", "pagina_2");
params.put("frame", "0");
params.put("widgetTypeCode", "leftmenu");
params.put("navSpec", "parent.subtree(2)+abs(1).subtree(2)+current");
params.put("movement", ApsAdminSystemConstants.MOVEMENT_UP_CODE);
params.put("expressionIndex", "2");
String result = this.executeMoveExpression("admin", params);
assertEquals(Action.SUCCESS, result);
NavigatorWidgetConfigAction action = (NavigatorWidgetConfigAction) this.getAction();
Widget widget = action.getWidget();
assertNotNull(widget);
ApsProperties props = widget.getConfig();
assertEquals(1, props.size());
assertEquals("parent.subtree(2) + current + abs(1).subtree(2)", props.getProperty("navSpec"));
List<NavigatorExpression> expressions = action.getExpressions();
assertEquals(3, expressions.size());
NavigatorExpression expression1 = expressions.get(1);
assertEquals(NavigatorExpression.SPEC_CURRENT_PAGE_ID, expression1.getSpecId());
assertTrue(expression1.getOperatorId() < 0);
}
use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.
the class TestNavigatorWidgetConfigAction method testExecuteMoveExpression_3.
public void testExecuteMoveExpression_3() throws Throwable {
Map<String, String> params = new HashMap<String, String>();
params.put("pageCode", "pagina_2");
params.put("frame", "0");
params.put("widgetTypeCode", "leftmenu");
params.put("navSpec", "parent.subtree(2)+abs(1).subtree(2)+current");
params.put("movement", ApsAdminSystemConstants.MOVEMENT_UP_CODE);
// INDICE SUPERIORE AL SIZE
params.put("expressionIndex", "3");
String result = this.executeMoveExpression("admin", params);
assertEquals(Action.SUCCESS, result);
NavigatorWidgetConfigAction action = (NavigatorWidgetConfigAction) this.getAction();
Widget widget = action.getWidget();
assertNotNull(widget);
ApsProperties props = widget.getConfig();
assertEquals(1, props.size());
assertEquals("parent.subtree(2) + abs(1).subtree(2) + current", props.getProperty("navSpec"));
List<NavigatorExpression> expressions = action.getExpressions();
assertEquals(3, expressions.size());
NavigatorExpression expression2 = expressions.get(2);
assertEquals(NavigatorExpression.SPEC_CURRENT_PAGE_ID, expression2.getSpecId());
assertTrue(expression2.getOperatorId() < 0);
}
Aggregations