Search in sources :

Example 21 with ActionSupport

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

the class TestContentGroupAction method testSuspendContents_2.

public void testSuspendContents_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, true);
        for (int i = 0; i < newContentIds.length; i++) {
            Content content = this.getContentManager().loadContent(newContentIds[i], false);
            assertTrue(content.isOnLine());
        }
        this.initAction("/do/jacms/Content", "suspendContentGroup");
        this.addParameter("contentIds", newContentIds);
        String result = this.executeAction();
        assertEquals(Action.SUCCESS, result);
        int suspendedContents = 0;
        for (int i = 0; i < newContentIds.length; i++) {
            Content content = this.getContentManager().loadContent(newContentIds[i], false);
            if (!Group.FREE_GROUP_NAME.equals(content.getMainGroup())) {
                assertFalse(content.isOnLine());
                ++suspendedContents;
            } else {
                assertTrue(content.isOnLine());
            }
        }
        assertEquals(2, suspendedContents);
        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)

Example 22 with ActionSupport

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

the class TestContentGroupAction method testInsertOnLineContents_1.

public void testInsertOnLineContents_1() throws Throwable {
    this.setUserOnSession("admin");
    // CONTENUTI FREE
    String[] masterContentIds = { "ART111", "EVN20" };
    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", "approveContentGroup");
        this.addParameter("contentIds", newContentIds);
        String result = this.executeAction();
        assertEquals(Action.SUCCESS, result);
        for (int i = 0; i < newContentIds.length; i++) {
            Content content = this.getContentManager().loadContent(newContentIds[i], false);
            assertTrue(content.isOnLine());
        }
        ActionSupport action = this.getAction();
        Collection<String> messages = action.getActionMessages();
        assertEquals(1, messages.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)

Example 23 with ActionSupport

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

the class TestIntroNewContentAction method testCreateNewVoid_2.

public void testCreateNewVoid_2() throws Throwable {
    this.initAction("/do/jacms/Content", "createNewVoid");
    this.setUserOnSession("admin");
    String result = this.executeAction();
    assertEquals(Action.INPUT, result);
    ActionSupport action = this.getAction();
    Map<String, List<String>> fieldErros = action.getFieldErrors();
    assertEquals(3, fieldErros.size());
}
Also used : ActionSupport(com.opensymphony.xwork2.ActionSupport) List(java.util.List)

Example 24 with ActionSupport

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

the class ApsAdminBaseTestCase method initAction.

/**
 * Created action class based on namespace and name
 *
 * @param namespace The namespace
 * @param name The name of the action
 * @throws java.lang.Exception In case of error
 */
protected void initAction(String namespace, String name) throws Exception {
    // create a proxy class which is just a wrapper around the action call.
    // The proxy is created by checking the namespace and name against the
    // struts.xml configuration
    ActionProxyFactory proxyFactory = (ActionProxyFactory) this._dispatcher.getContainer().getInstance(ActionProxyFactory.class);
    this._proxy = proxyFactory.createActionProxy(namespace, name, null, null, true, false);
    // set to true if you want to process Freemarker or JSP results
    this._proxy.setExecuteResult(false);
    // by default, don't pass in any request parameters
    // set the actions context to the one which the proxy is using
    ServletActionContext.setContext(_proxy.getInvocation().getInvocationContext());
    ServletActionContext.setRequest(_request);
    ServletActionContext.setResponse(_response);
    ServletActionContext.setServletContext(_servletContext);
    this._action = (ActionSupport) this._proxy.getAction();
    // reset previsious params
    List<String> paramNames = new ArrayList<String>(this._request.getParameterMap().keySet());
    for (int i = 0; i < paramNames.size(); i++) {
        String paramName = (String) paramNames.get(i);
        this.removeParameter(paramName);
    }
}
Also used : ActionProxyFactory(com.opensymphony.xwork2.ActionProxyFactory) ArrayList(java.util.ArrayList)

Example 25 with ActionSupport

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

the class TestLangAction method testFailureRemoveDefaultLang.

public void testFailureRemoveDefaultLang() throws Throwable {
    int initLangs = this._langManager.getLangs().size();
    Lang defaultLang = this._langManager.getDefaultLang();
    String result = this.executeRemoveLang("admin", defaultLang.getCode());
    assertEquals(Action.INPUT, result);
    assertEquals(initLangs, this._langManager.getLangs().size());
    ActionSupport action = this.getAction();
    Collection<String> errors = action.getActionErrors();
    assertEquals(1, errors.size());
}
Also used : ActionSupport(com.opensymphony.xwork2.ActionSupport) Lang(com.agiletec.aps.system.services.lang.Lang)

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