Search in sources :

Example 16 with ActionSupport

use of com.opensymphony.xwork2.ActionSupport in project entando-core by entando.

the class TestWidgetTypeAction method testUpdate_1.

public void testUpdate_1() throws Throwable {
    String widgetTypeCode = "test_widgetType_Upd1";
    assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
    List<String> fragmentCodes = this._guiFragmentManager.getGuiFragmentCodesByWidgetType(widgetTypeCode);
    assertEquals(0, fragmentCodes.size());
    try {
        WidgetType type = this.createNewLogicWidgetType(widgetTypeCode);
        this._widgetTypeManager.addWidgetType(type);
        String result = this.executeUpdate(widgetTypeCode, "", "english title", "admin", null);
        assertEquals(Action.INPUT, result);
        fragmentCodes = this._guiFragmentManager.getGuiFragmentCodesByWidgetType(widgetTypeCode);
        assertEquals(0, fragmentCodes.size());
        ActionSupport action = this.getAction();
        assertEquals(1, action.getFieldErrors().size());
        result = this.executeUpdate(widgetTypeCode, "Titolo modificato", "Modified title", "admin", null);
        assertEquals(Action.SUCCESS, result);
        WidgetType extracted = this._widgetTypeManager.getWidgetType(widgetTypeCode);
        assertNotNull(extracted);
        assertEquals("Titolo modificato", extracted.getTitles().get("it"));
        assertEquals("Modified title", extracted.getTitles().get("en"));
        fragmentCodes = this._guiFragmentManager.getGuiFragmentCodesByWidgetType(widgetTypeCode);
        assertEquals(0, fragmentCodes.size());
    } catch (Throwable t) {
        throw t;
    } finally {
        this.cleanDatabase(widgetTypeCode);
    }
}
Also used : ActionSupport(com.opensymphony.xwork2.ActionSupport) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType)

Example 17 with ActionSupport

use of com.opensymphony.xwork2.ActionSupport in project entando-core by entando.

the class TestNavigatorWidgetConfigAction method testFailureAddExpression_2.

public void testFailureAddExpression_2() 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");
    params.put("specId", "3");
    params.put("specSuperLevel", "-2");
    String result = this.executeAddExpression("admin", params);
    assertEquals(Action.INPUT, result);
    ActionSupport action = this.getAction();
    assertEquals(1, action.getActionErrors().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) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 18 with ActionSupport

use of com.opensymphony.xwork2.ActionSupport in project entando-core by entando.

the class TestContentAction method testValidate_3.

public void testValidate_3() throws Throwable {
    // Description maxlength
    String contentTypeCode = "ART";
    String contentOnSessionMarker = this.extractSessionMarker(contentTypeCode, ApsAdminSystemConstants.ADD);
    String marker = "__DESCR_TEST__";
    String insertedDescr = marker;
    while (insertedDescr.length() < 300) {
        insertedDescr += marker;
    }
    try {
        String result = this.executeCreateNewVoid(contentTypeCode, "descr", Content.STATUS_DRAFT, Group.FREE_GROUP_NAME, "admin");
        assertEquals(Action.SUCCESS, result);
        Content contentOnSession = this.getContentOnEdit(contentOnSessionMarker);
        assertNotNull(contentOnSession);
        this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
        this.setUserOnSession("admin");
        this.addParameter("descr", insertedDescr);
        result = this.executeAction();
        assertEquals(Action.INPUT, result);
        ActionSupport action = this.getAction();
        Map<String, List<String>> fieldErros = action.getFieldErrors();
        assertEquals(2, fieldErros.size());
        List<String> descrFieldsErrors = fieldErros.get("descr");
        assertEquals(1, descrFieldsErrors.size());
        List<String> titleFieldsErrors = fieldErros.get("Text:it_Titolo");
        assertEquals(1, titleFieldsErrors.size());
    } catch (Throwable t) {
        throw t;
    } finally {
        this.removeTestContent(insertedDescr);
    }
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ActionSupport(com.opensymphony.xwork2.ActionSupport) List(java.util.List)

Example 19 with ActionSupport

use of com.opensymphony.xwork2.ActionSupport in project entando-core by entando.

the class TestContentAction method testValidate_5.

public void testValidate_5() throws Throwable {
    String contentTypeCode = "RAH";
    String contentOnSessionMarker = this.extractSessionMarker(contentTypeCode, ApsAdminSystemConstants.ADD);
    String insertedDescr = "XXX Prova Validazione XXX";
    String shortTitle = "short";
    String longTitle = "Titolo che supera la lunghezza massima di cento caratteri; " + "Ripeto, Titolo che supera la lunghezza massima di cento caratteri";
    try {
        String result = this.executeCreateNewVoid(contentTypeCode, "descr", Content.STATUS_DRAFT, Group.FREE_GROUP_NAME, "admin");
        assertEquals(Action.SUCCESS, result);
        Content contentOnSession = this.getContentOnEdit(contentOnSessionMarker);
        assertNotNull(contentOnSession);
        this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
        this.setUserOnSession("admin");
        this.addParameter("descr", insertedDescr);
        this.addParameter("Text:it_Titolo", shortTitle);
        result = this.executeAction();
        assertEquals(Action.INPUT, result);
        ActionSupport action = this.getAction();
        Map<String, List<String>> fieldErros = action.getFieldErrors();
        assertEquals(1, fieldErros.size());
        List<String> titleItFieldErrors = fieldErros.get("Text:it_Titolo");
        assertEquals(1, titleItFieldErrors.size());
        this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
        this.setUserOnSession("admin");
        this.addParameter("mainGroup", Group.FREE_GROUP_NAME);
        this.addParameter("descr", insertedDescr);
        this.addParameter("Text:it_Titolo", longTitle);
        result = this.executeAction();
        assertEquals(Action.INPUT, result);
        action = this.getAction();
        fieldErros = action.getFieldErrors();
        assertEquals(1, fieldErros.size());
        titleItFieldErrors = fieldErros.get("Text:it_Titolo");
        assertEquals(1, titleItFieldErrors.size());
        this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
        this.setUserOnSession("admin");
        this.addParameter("mainGroup", Group.FREE_GROUP_NAME);
        this.addParameter("descr", insertedDescr);
        this.addParameter("Text:it_Titolo", "Right Title length");
        this.addParameter("Text:en_Titolo", longTitle);
        result = this.executeAction();
        assertEquals(Action.INPUT, result);
        action = this.getAction();
        fieldErros = action.getFieldErrors();
        assertEquals(1, fieldErros.size());
        titleItFieldErrors = fieldErros.get("Text:en_Titolo");
        assertEquals(1, titleItFieldErrors.size());
    } catch (Throwable t) {
        throw t;
    } finally {
        this.removeTestContent(insertedDescr);
    }
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ActionSupport(com.opensymphony.xwork2.ActionSupport) List(java.util.List)

Example 20 with ActionSupport

use of com.opensymphony.xwork2.ActionSupport in project entando-core by entando.

the class TestContentAction method testSaveContentWithPageReference.

public void testSaveContentWithPageReference() throws Throwable {
    String contentId = "ART111";
    this.executeEdit(contentId, "admin");
    Content master = this.getContentManager().loadContent(contentId, false);
    String contentOnSessionMarker = AbstractContentAction.buildContentOnSessionMarker(master, ApsAdminSystemConstants.EDIT);
    String groupToRemove = "customers";
    try {
        Content contentOnSession = this.getContentOnEdit(contentOnSessionMarker);
        assertNotNull(contentOnSession);
        assertEquals(2, contentOnSession.getGroups().size());
        assertTrue(contentOnSession.getGroups().contains(groupToRemove));
        this.initContentAction("/do/jacms/Content", "removeGroup", contentOnSessionMarker);
        this.addParameter("extraGroupName", groupToRemove);
        String result = this.executeAction();
        assertEquals(Action.SUCCESS, result);
        contentOnSession = this.getContentOnEdit(contentOnSessionMarker);
        assertNotNull(contentOnSession);
        assertEquals(1, contentOnSession.getGroups().size());
        assertFalse(contentOnSession.getGroups().contains(groupToRemove));
        this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
        this.addParameter("descr", master.getDescription());
        this.addParameter("mainGroup", master.getMainGroup());
        this.addParameter("descr", master.getDescription());
        result = this.executeAction();
        assertEquals(Action.INPUT, result);
        ActionSupport action = this.getAction();
        Map<String, List<String>> fieldErrors = action.getFieldErrors();
        assertEquals(1, fieldErrors.size());
        List<String> mainGroupFieldErrors = (List<String>) fieldErrors.get("mainGroup");
        assertEquals(2, mainGroupFieldErrors.size());
    } catch (Throwable t) {
        this.getContentManager().saveContent(master);
        throw t;
    }
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ActionSupport(com.opensymphony.xwork2.ActionSupport) List(java.util.List)

Aggregations

ActionSupport (com.opensymphony.xwork2.ActionSupport)56 List (java.util.List)28 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)14 Widget (com.agiletec.aps.system.services.page.Widget)4 ApsProperties (com.agiletec.aps.util.ApsProperties)4 HashMap (java.util.HashMap)4 WidgetType (org.entando.entando.aps.system.services.widgettype.WidgetType)4 IPage (com.agiletec.aps.system.services.page.IPage)3 ArrayList (java.util.ArrayList)3 IManager (com.agiletec.aps.system.common.IManager)2 IUserProfile (org.entando.entando.aps.system.services.userprofile.model.IUserProfile)2 BooleanAttribute (com.agiletec.aps.system.common.entity.model.attribute.BooleanAttribute)1 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)1 Lang (com.agiletec.aps.system.services.lang.Lang)1 PageMetadata (com.agiletec.aps.system.services.page.PageMetadata)1 PageModel (com.agiletec.aps.system.services.pagemodel.PageModel)1 SymbolicLink (com.agiletec.plugins.jacms.aps.system.services.content.model.SymbolicLink)1 LinkAttribute (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute)1 ActionProxyFactory (com.opensymphony.xwork2.ActionProxyFactory)1