Search in sources :

Example 11 with WidgetType

use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.

the class TestPageAction method testSavePage_Draft_2.

public void testSavePage_Draft_2() throws Throwable {
    String pageCode = "pagina_test";
    assertNull(this._pageManager.getDraftPage(pageCode));
    try {
        IPage root = this._pageManager.getDraftRoot();
        Map<String, String> params = new HashMap<String, String>();
        params.put("strutsAction", String.valueOf(ApsAdminSystemConstants.ADD));
        params.put("parentPageCode", root.getCode());
        params.put("langit", "Pagina Test 2");
        params.put("langen", "Test Page 2");
        params.put("model", "internal");
        params.put("group", Group.FREE_GROUP_NAME);
        params.put("pageCode", pageCode);
        String result = this.executeSave(params, "admin");
        assertEquals(Action.SUCCESS, result);
        IPage addedPage = this._pageManager.getDraftPage(pageCode);
        this.executeSetDefaultWidgets(params, "admin");
        assertNotNull(addedPage);
        assertEquals("Pagina Test 2", addedPage.getMetadata().getTitles().getProperty("it"));
        Widget[] showlets = addedPage.getWidgets();
        assertEquals(addedPage.getMetadata().getModel().getFrames().length, showlets.length);
        for (int i = 0; i < showlets.length; i++) {
            Widget widget = showlets[i];
            if (i == 3) {
                assertNotNull(widget);
                WidgetType type = widget.getType();
                assertEquals("leftmenu", type.getCode());
                assertEquals(1, type.getTypeParameters().size());
                assertNull(type.getConfig());
                ApsProperties config = widget.getConfig();
                assertEquals(1, config.size());
                assertEquals("code(homepage).subtree(1)", config.getProperty("navSpec"));
            } else {
                assertNull(widget);
            }
        }
    } catch (Throwable t) {
        throw t;
    } finally {
        this._pageManager.deletePage(pageCode);
    }
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) HashMap(java.util.HashMap) Widget(com.agiletec.aps.system.services.page.Widget) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 12 with WidgetType

use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.

the class TestWidgetTypeAction method createNewLogicWidgetType.

private WidgetType createNewLogicWidgetType(String code) {
    WidgetType type = this.createNewWidgetType(code);
    WidgetType parent = this._widgetTypeManager.getWidgetType("content_viewer");
    assertNotNull(parent);
    type.setParentType(parent);
    type.setPluginCode("jacms");
    ApsProperties config = new ApsProperties();
    config.put("contentId", "ART112");
    type.setConfig(config);
    return type;
}
Also used : WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 13 with WidgetType

use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.

the class TestWidgetTypeAction method testAddNewWidgetType.

// TODO ADD MORE TESTS for add new widget
public void testAddNewWidgetType() throws Throwable {
    String widgetTypeCode = "randomWidgetCode_4";
    List<String> fragmantCodes = null;
    try {
        assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
        assertNull(this._guiFragmentManager.getGuiFragment(widgetTypeCode));
        String result = this.executeAddWidgetType("admin", widgetTypeCode, "**GUI**");
        assertEquals(Action.SUCCESS, result);
        WidgetType addedType = this._widgetTypeManager.getWidgetType(widgetTypeCode);
        assertNotNull(addedType);
        FieldSearchFilter filterByType = new FieldSearchFilter("widgettypecode", widgetTypeCode, false);
        FieldSearchFilter[] filters = { filterByType };
        fragmantCodes = this._guiFragmentManager.searchGuiFragments(filters);
        assertNotNull(fragmantCodes);
        assertEquals(1, fragmantCodes.size());
        assertEquals(widgetTypeCode, fragmantCodes.get(0));
        GuiFragment guiFragment = this._guiFragmentManager.getGuiFragment(fragmantCodes.get(0));
        assertNotNull(guiFragment);
        assertEquals(widgetTypeCode, guiFragment.getWidgetTypeCode());
        assertEquals("**GUI**", guiFragment.getGui());
        assertFalse(guiFragment.isLocked());
    } catch (Throwable t) {
        throw t;
    } finally {
        if (null != fragmantCodes) {
            for (int i = 0; i < fragmantCodes.size(); i++) {
                String code = fragmantCodes.get(i);
                this._guiFragmentManager.deleteGuiFragment(code);
            }
        }
        this._widgetTypeManager.deleteWidgetType(widgetTypeCode);
    }
}
Also used : GuiFragment(org.entando.entando.aps.system.services.guifragment.GuiFragment) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType)

Example 14 with WidgetType

use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.

the class TestWidgetTypeAction method testUpdate_2.

public void testUpdate_2() throws Throwable {
    String widgetTypeCode = "test_widgetType_Upd2";
    assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
    List<String> fragmentCodes = this._guiFragmentManager.getGuiFragmentCodesByWidgetType(widgetTypeCode);
    assertEquals(0, fragmentCodes.size());
    try {
        WidgetType type = this.createNewWidgetType(widgetTypeCode);
        this._widgetTypeManager.addWidgetType(type);
        String result = this.executeUpdate(widgetTypeCode, "", "", "admin", null);
        assertEquals(Action.INPUT, result);
        fragmentCodes = this._guiFragmentManager.getGuiFragmentCodesByWidgetType(widgetTypeCode);
        assertEquals(0, fragmentCodes.size());
        ActionSupport action = this.getAction();
        assertEquals(3, action.getFieldErrors().size());
        assertEquals(1, action.getFieldErrors().get("gui").size());
        result = this.executeUpdate(widgetTypeCode, "Titolo modificato", "Modified title", "admin", "** GUI **");
        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(1, 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 15 with WidgetType

use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.

the class TestWidgetTypeAction method testAddNewUserWidgetType.

public void testAddNewUserWidgetType() throws Throwable {
    String widgetTypeCode = "randomWidgetCode_3";
    try {
        this.setUserOnSession("admin");
        this.initAction("/do/Portal/WidgetType", "save");
        this.addParameter("widgetTypeCode", widgetTypeCode);
        this.addParameter("englishTitle", "en");
        this.addParameter("italianTitle", "it");
        this.addParameter("parentWidgetTypeCode", "content_viewer_list");
        this.addParameter("strutsAction", WidgetTypeAction.NEW_USER_WIDGET);
        this.addParameter("maxElemForItem", "5");
        this.addParameter("contentType", "EVN");
        String result = this.executeAction();
        assertEquals(Action.SUCCESS, result);
        WidgetType addedType = this._widgetTypeManager.getWidgetType(widgetTypeCode);
        assertNotNull(addedType);
        ApsProperties config = addedType.getConfig();
        assertEquals(2, config.size());
        assertEquals("EVN", config.getProperty("contentType"));
        assertEquals("5", config.getProperty("maxElemForItem"));
    } catch (Throwable t) {
        throw t;
    } finally {
        this._widgetTypeManager.deleteWidgetType(widgetTypeCode);
    }
}
Also used : WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) ApsProperties(com.agiletec.aps.util.ApsProperties)

Aggregations

WidgetType (org.entando.entando.aps.system.services.widgettype.WidgetType)70 ApsProperties (com.agiletec.aps.util.ApsProperties)33 Widget (com.agiletec.aps.system.services.page.Widget)20 IPage (com.agiletec.aps.system.services.page.IPage)11 GuiFragment (org.entando.entando.aps.system.services.guifragment.GuiFragment)10 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)9 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)5 WidgetTypeParameter (org.entando.entando.aps.system.services.widgettype.WidgetTypeParameter)5 ActionSupport (com.opensymphony.xwork2.ActionSupport)4 IManager (com.agiletec.aps.system.common.IManager)3 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)3 Lang (com.agiletec.aps.system.services.lang.Lang)3 List (java.util.List)3 JAXBGuiFragment (org.entando.entando.aps.system.services.guifragment.api.JAXBGuiFragment)3 IWidgetTypeManager (org.entando.entando.aps.system.services.widgettype.IWidgetTypeManager)3 ILangManager (com.agiletec.aps.system.services.lang.ILangManager)2 SelectItem (com.agiletec.aps.util.SelectItem)2 Properties (java.util.Properties)2 ApiMethod (org.entando.entando.aps.system.services.api.model.ApiMethod)2