Search in sources :

Example 31 with ActionSupport

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

the class TestRoleAction method testFailureSave.

public void testFailureSave() throws Throwable {
    this.executeNew("admin");
    String[] permissions = { "editContents" };
    // permessi non disponibili
    String result = this.executeSaveNew("developersConf", "roleName", "description", permissions);
    assertEquals("apslogin", result);
    // roleName giĆ  esistente
    result = this.executeSaveNew("admin", "editor", "description", permissions);
    assertEquals(Action.INPUT, result);
    ActionSupport action = this.getAction();
    Map<String, List<String>> fieldErrors = action.getFieldErrors();
    assertEquals(1, fieldErrors.size());
    List<String> errors = fieldErrors.get("name");
    assertEquals(1, errors.size());
    // description non valorizzato
    result = this.executeSaveNew("admin", "roleName", "", permissions);
    assertEquals(Action.INPUT, result);
    fieldErrors = this.getAction().getFieldErrors();
    assertEquals(1, fieldErrors.size());
    errors = fieldErrors.get("description");
    assertEquals(1, errors.size());
    // name e description non valorizzati
    result = this.executeSaveNew("admin", "", "", permissions);
    assertEquals(Action.INPUT, result);
    fieldErrors = this.getAction().getFieldErrors();
    assertEquals(2, fieldErrors.size());
    errors = fieldErrors.get("name");
    assertEquals(1, errors.size());
    errors = fieldErrors.get("description");
    assertEquals(1, errors.size());
    // name troppo lungo
    result = this.executeSaveNew("admin", "roleNameDecisamenteTroppoLungo", "description", permissions);
    assertEquals(Action.INPUT, result);
    fieldErrors = this.getAction().getFieldErrors();
    assertEquals(1, fieldErrors.size());
    errors = fieldErrors.get("name");
    assertEquals(1, errors.size());
}
Also used : ActionSupport(com.opensymphony.xwork2.ActionSupport) List(java.util.List)

Example 32 with ActionSupport

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

the class TestContentAction method testValidate_4.

/*
	 * We test, among other things the CheckBox attribute
	 */
public void testValidate_4() throws Throwable {
    String contentTypeCode = "RAH";
    String contentOnSessionMarker = this.extractSessionMarker(contentTypeCode, ApsAdminSystemConstants.ADD);
    String insertedDescr = "XXX Prova Validazione XXX";
    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("Monotext:email", "wrongEmailAddress");
        this.addParameter("Number:Numero", "wrongNumber");
        this.addParameter("CheckBox:Checkbox", "true");
        result = this.executeAction();
        assertEquals(Action.INPUT, result);
        ActionSupport action = this.getAction();
        Map<String, List<String>> fieldErros = action.getFieldErrors();
        assertEquals(2, fieldErros.size());
        List<String> emailFieldErrors = fieldErros.get("Monotext:email");
        assertEquals(1, emailFieldErrors.size());
        List<String> numberFieldErrors = fieldErros.get("Number:Numero");
        assertEquals(1, numberFieldErrors.size());
        Content content = this.getContentOnEdit(contentOnSessionMarker);
        assertNotNull(content);
        assertTrue(content.getAttributeMap().containsKey("Checkbox"));
        BooleanAttribute attribute = (BooleanAttribute) content.getAttribute("Checkbox");
        assertNotNull(attribute);
        assertEquals("CheckBox", attribute.getType());
        assertEquals(Boolean.TRUE, attribute.getValue());
        this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
        this.setUserOnSession("admin");
        this.addParameter("mainGroup", Group.FREE_GROUP_NAME);
        this.addParameter("descr", insertedDescr);
        this.addParameter("Monotext:email", "wrongEmailAddress");
        this.addParameter("Number:Numero", "wrongNumber");
        // LEAVING the Checkbox parameter will result in the checkbox attribute being later evaluated as 'false'
        result = this.executeAction();
        assertEquals(Action.INPUT, result);
        content = this.getContentOnEdit(contentOnSessionMarker);
        assertNotNull(content);
        assertTrue(content.getAttributeMap().containsKey("Checkbox"));
        attribute = (BooleanAttribute) content.getAttribute("Checkbox");
        assertNotNull(attribute);
        assertEquals("CheckBox", attribute.getType());
        assertEquals(Boolean.FALSE, attribute.getValue());
    } catch (Throwable t) {
        throw t;
    } finally {
        this.removeTestContent(insertedDescr);
    }
}
Also used : BooleanAttribute(com.agiletec.aps.system.common.entity.model.attribute.BooleanAttribute) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ActionSupport(com.opensymphony.xwork2.ActionSupport) List(java.util.List)

Example 33 with ActionSupport

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

the class TestContentAction method testValidate_6.

public void testValidate_6() throws Throwable {
    String contentId = "ART112";
    String contentOnSessionMarker = this.extractSessionMarker(contentId, ApsAdminSystemConstants.EDIT);
    try {
        this.initAction("/do/jacms/Content", "edit");
        this.setUserOnSession("admin");
        this.addParameter("contentId", contentId);
        String result = this.executeAction();
        assertEquals(Action.SUCCESS, result);
        Content contentOnEdit = this.getContentOnEdit(contentOnSessionMarker);
        assertNotNull(contentOnEdit);
        assertEquals("coach", contentOnEdit.getMainGroup());
        assertEquals(2, contentOnEdit.getGroups().size());
        assertTrue(contentOnEdit.getGroups().contains("customers"));
        assertTrue(contentOnEdit.getGroups().contains("helpdesk"));
        this.initContentAction("/do/jacms/Content", "removeGroup", contentOnSessionMarker);
        this.addParameter("extraGroupName", "customers");
        this.addParameter("descr", contentOnEdit.getDescription());
        result = this.executeAction();
        assertEquals(Action.SUCCESS, result);
        contentOnEdit = (Content) this.getRequest().getSession().getAttribute(ContentActionConstants.SESSION_PARAM_NAME_CURRENT_CONTENT_PREXIX + contentOnSessionMarker);
        assertEquals(1, contentOnEdit.getGroups().size());
    } catch (Throwable t) {
        throw t;
    }
    Content mainContent = this.getContentManager().loadContent(contentId, true);
    try {
        this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
        this.addParameter("descr", mainContent.getDescription());
        String result = this.executeAction();
        assertEquals(Action.INPUT, result);
        ActionSupport action = this.getAction();
        assertEquals(1, action.getFieldErrors().size());
        assertEquals(1, action.getFieldErrors().get("mainGroup").size());
    } catch (Throwable t) {
        this.getContentManager().insertOnLineContent(mainContent);
        throw t;
    }
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ActionSupport(com.opensymphony.xwork2.ActionSupport)

Example 34 with ActionSupport

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

the class TestContentAction method testValidate_2.

public void testValidate_2() throws Throwable {
    String insertedDescr = "XXX Prova Validazione XXX";
    try {
        Content contentForTest = this.getContentManager().loadContent("EVN191", true);
        String contentOnSessionMarker = AbstractContentAction.buildContentOnSessionMarker(contentForTest, ApsAdminSystemConstants.EDIT);
        contentForTest.setId(null);
        contentForTest.setDescription(insertedDescr);
        // Valorizzo il gruppo proprietario
        contentForTest.setMainGroup("coach");
        contentForTest.getGroups().add("customers");
        // AGGIUNGO LINK SU PAGINA COACH
        MonoListAttribute linksCorrelati = (MonoListAttribute) contentForTest.getAttribute("LinkCorrelati");
        LinkAttribute linkAttribute = (LinkAttribute) linksCorrelati.addAttribute();
        linkAttribute.setText("Descrizione link", "it");
        SymbolicLink symbolicLink = new SymbolicLink();
        // Contenuto di coach
        symbolicLink.setDestinationToContent("EVN103");
        linkAttribute.setSymbolicLink(symbolicLink);
        this.getRequest().getSession().setAttribute(ContentActionConstants.SESSION_PARAM_NAME_CURRENT_CONTENT_PREXIX + contentOnSessionMarker, contentForTest);
        this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
        this.setUserOnSession("admin");
        String result = this.executeAction();
        assertEquals(Action.INPUT, result);
        ActionSupport action = this.getAction();
        assertEquals(1, action.getFieldErrors().size());
        assertEquals(1, action.getFieldErrors().get("Monolist:Link:LinkCorrelati_0").size());
    } catch (Throwable t) {
        throw t;
    } finally {
        this.removeTestContent(insertedDescr);
    }
}
Also used : LinkAttribute(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute) MonoListAttribute(com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ActionSupport(com.opensymphony.xwork2.ActionSupport) SymbolicLink(com.agiletec.plugins.jacms.aps.system.services.content.model.SymbolicLink)

Example 35 with ActionSupport

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

the class TestContentGroupAction method testDeleteContents_2.

public void testDeleteContents_2() throws Throwable {
    this.setUserOnSession("supervisorCoach");
    // 2 CONTENUTI FREE, 1 Customers e 1 Coach
    String[] masterContentIds = { "ART180", "EVN20", "ART104", "ART102" };
    String[] newContentIds = null;
    try {
        newContentIds = this.addDraftContentsForTest(masterContentIds, false);
        for (int i = 0; i < newContentIds.length; i++) {
            Content content = this.getContentManager().loadContent(newContentIds[i], false);
            assertFalse(content.isOnLine());
        }
        this.initAction("/do/jacms/Content", "deleteContentGroup");
        this.addParameter("contentIds", newContentIds);
        String result = this.executeAction();
        assertEquals(Action.SUCCESS, result);
        int deletedContents = 0;
        for (int i = 0; i < newContentIds.length; i++) {
            Content content = this.getContentManager().loadContent(newContentIds[i], false);
            if (content == null) {
                ++deletedContents;
            } else {
                // Verifica che non si sono cancellati contenuti free
                String mainGroup = content.getMainGroup();
                assertTrue(Group.FREE_GROUP_NAME.equals(mainGroup));
            }
        }
        assertEquals(2, deletedContents);
        ActionSupport action = this.getAction();
        Collection<String> messages = action.getActionMessages();
        assertEquals(1, messages.size());
        Collection<String> errors = action.getActionErrors();
        assertEquals(2, errors.size());
    } catch (Throwable t) {
        throw t;
    } finally {
        this.deleteContents(newContentIds);
    }
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ActionSupport(com.opensymphony.xwork2.ActionSupport)

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