Search in sources :

Example 71 with Widget

use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.

the class TestPageAction method testDetailPageForAdmin.

public void testDetailPageForAdmin() throws Throwable {
    // PAGINA PREDISPOSTA PER LA
    String selectedPageCode = "contentview";
    // PUBBLICAZIONE VOLANTE
    String result = this.executeActionOnPage(selectedPageCode, "admin", "detail");
    assertEquals(Action.SUCCESS, result);
    IPage page = this._pageManager.getDraftPage(selectedPageCode);
    PageAction action = (PageAction) this.getAction();
    IPage pageToShow = action.getPageToShow();
    assertEquals(page.getCode(), pageToShow.getCode());
    assertEquals(page.getParentCode(), pageToShow.getParentCode());
    assertEquals(page.getModel().getCode(), pageToShow.getModel().getCode());
    assertEquals(page.getGroup(), pageToShow.getGroup());
    assertEquals(page.isShowable(), pageToShow.isShowable());
    assertEquals("Publicazione Contenuto", pageToShow.getTitles().getProperty("it"));
    assertEquals("Content Publishing", pageToShow.getTitles().getProperty("en"));
    Widget widget = page.getWidgets()[page.getModel().getMainFrame()];
    if (null != widget) {
        assertEquals("content_viewer", widget.getType().getCode());
        assertTrue(null == widget.getConfig() || widget.getConfig().isEmpty());
    }
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) Widget(com.agiletec.aps.system.services.page.Widget)

Example 72 with Widget

use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.

the class TestPageConfigAction method testTrashShowlet.

public void testTrashShowlet() throws Throwable {
    String pageCode = "contentview";
    int frame = 1;
    IPage contentview = this._pageManager.getDraftPage(pageCode);
    Widget widget = contentview.getWidgets()[frame];
    try {
        assertNotNull(widget);
        String result = this.executeTrashShowlet(pageCode, frame, "pageManagerCoach");
        assertEquals("pageTree", result);
        assertEquals(1, this.getAction().getActionErrors().size());
        result = this.executeTrashShowlet(pageCode, frame, "admin");
        assertEquals(Action.SUCCESS, result);
        IPage modifiedContentview = this._pageManager.getDraftPage(pageCode);
        Widget[] modifiedShowlets = modifiedContentview.getWidgets();
        assertNotNull(modifiedShowlets[frame]);
    } catch (Throwable t) {
        contentview = this._pageManager.getDraftPage(pageCode);
        contentview.getWidgets()[frame] = widget;
        this._pageManager.updatePage(contentview);
        throw t;
    }
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) Widget(com.agiletec.aps.system.services.page.Widget)

Example 73 with Widget

use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.

the class TestPageTreeAction method testMoveWidgetUp.

public void testMoveWidgetUp() throws Throwable {
    IPage page = this._pageManager.getDraftRoot();
    String pageCode = page.getCode();
    try {
        Widget configWidget = page.getWidgets()[0];
        Widget nullWidget = page.getWidgets()[1];
        assertNotNull(configWidget);
        assertNull(nullWidget);
        String result = this.executeMoveDown(pageCode, 0, "admin");
        assertEquals(Action.SUCCESS, result);
        IPage updatedPage = this._pageManager.getDraftRoot();
        Widget w00 = updatedPage.getWidgets()[0];
        Widget w11 = updatedPage.getWidgets()[1];
        assertNull(w00);
        assertEquals(w11.getType().getCode(), configWidget.getType().getCode());
        result = this.executeMoveUp(pageCode, 1, "admin");
        assertEquals(Action.SUCCESS, result);
        updatedPage = this._pageManager.getDraftRoot();
        w00 = updatedPage.getWidgets()[0];
        w11 = updatedPage.getWidgets()[1];
        assertEquals(w00.getType().getCode(), configWidget.getType().getCode());
        assertNull(w11);
    } finally {
        this._pageManager.updatePage(page);
    }
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) Widget(com.agiletec.aps.system.services.page.Widget)

Example 74 with Widget

use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.

the class TestWidgetTypeAction method testPasteNewWidgetType_2.

public void testPasteNewWidgetType_2() throws Throwable {
    String widgetTypeCode = "randomWidgetCode-2";
    String pageDest = "pagina_1";
    int frameDest = 1;
    Widget temp = this._pageManager.getDraftPage("pagina_11").getWidgets()[2];
    assertNotNull(temp);
    assertEquals("content_viewer", temp.getType().getCode());
    IPage page = this._pageManager.getDraftPage(pageDest);
    try {
        assertNull(page.getWidgets()[frameDest]);
        page.getWidgets()[frameDest] = temp;
        this._pageManager.updatePage(page);
        this.setUserOnSession("admin");
        this.initAction("/do/Portal/WidgetType", "save");
        this.addParameter("widgetTypeCode", widgetTypeCode);
        this.addParameter("englishTitle", "en");
        this.addParameter("italianTitle", "it");
        this.addParameter("pageCode", pageDest);
        this.addParameter("framePos", frameDest);
        this.addParameter("strutsAction", ApsAdminSystemConstants.PASTE);
        this.addParameter("replaceOnPage", "true");
        String result = this.executeAction();
        assertEquals("replaceOnPage", result);
        Widget newWidget = this._pageManager.getDraftPage(pageDest).getWidgets()[frameDest];
        assertNotNull(newWidget);
        assertNotNull(newWidget.getConfig());
        WidgetType addedType = this._widgetTypeManager.getWidgetType(widgetTypeCode);
        assertNotNull(addedType);
        assertEquals(newWidget.getType().getCode(), addedType.getCode());
        ApsProperties config = addedType.getConfig();
        Iterator<Object> keysIter = config.keySet().iterator();
        while (keysIter.hasNext()) {
            String key = (String) keysIter.next();
            assertEquals(newWidget.getConfig().getProperty(key), config.getProperty(key));
        }
    } catch (Throwable t) {
        throw t;
    } finally {
        page.getWidgets()[frameDest] = null;
        this._pageManager.updatePage(page);
        this._widgetTypeManager.deleteWidgetType(widgetTypeCode);
    }
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) Widget(com.agiletec.aps.system.services.page.Widget) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 75 with Widget

use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.

the class TestSimpleWidgetConfigAction method testInitConfigSimpleParameter_1.

public void testInitConfigSimpleParameter_1() throws Throwable {
    String result = this.executeConfigSimpleParameter("admin", "homepage", "1", "formAction");
    assertEquals(Action.SUCCESS, result);
    SimpleWidgetConfigAction action = (SimpleWidgetConfigAction) this.getAction();
    Widget widget = action.getWidget();
    assertNotNull(widget);
    assertEquals(0, widget.getConfig().size());
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget)

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