Search in sources :

Example 81 with Widget

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());
}
Also used : HashMap(java.util.HashMap) Widget(com.agiletec.aps.system.services.page.Widget) ActionSupport(com.opensymphony.xwork2.ActionSupport) List(java.util.List) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 82 with Widget

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());
}
Also used : HashMap(java.util.HashMap) Widget(com.agiletec.aps.system.services.page.Widget) ActionSupport(com.opensymphony.xwork2.ActionSupport) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 83 with Widget

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);
    }
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) Widget(com.agiletec.aps.system.services.page.Widget)

Example 84 with Widget

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);
}
Also used : NavigatorExpression(com.agiletec.aps.system.services.page.widget.NavigatorExpression) HashMap(java.util.HashMap) Widget(com.agiletec.aps.system.services.page.Widget) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 85 with Widget

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);
}
Also used : NavigatorExpression(com.agiletec.aps.system.services.page.widget.NavigatorExpression) HashMap(java.util.HashMap) Widget(com.agiletec.aps.system.services.page.Widget) ApsProperties(com.agiletec.aps.util.ApsProperties)

Aggregations

Widget (com.agiletec.aps.system.services.page.Widget)117 ApsProperties (com.agiletec.aps.util.ApsProperties)60 IPage (com.agiletec.aps.system.services.page.IPage)41 WidgetType (org.entando.entando.aps.system.services.widgettype.WidgetType)20 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)17 HashMap (java.util.HashMap)12 Lang (com.agiletec.aps.system.services.lang.Lang)10 Page (com.agiletec.aps.system.services.page.Page)7 PageModel (com.agiletec.aps.system.services.pagemodel.PageModel)7 ArrayList (java.util.ArrayList)7 PageMetadata (com.agiletec.aps.system.services.page.PageMetadata)6 NavigatorExpression (com.agiletec.aps.system.services.page.widget.NavigatorExpression)6 Properties (java.util.Properties)6 RequestContext (com.agiletec.aps.system.RequestContext)5 ActionSupport (com.opensymphony.xwork2.ActionSupport)4 JspException (javax.servlet.jsp.JspException)4 WidgetTypeParameter (org.entando.entando.aps.system.services.widgettype.WidgetTypeParameter)4 List (java.util.List)3 ServletRequest (javax.servlet.ServletRequest)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3