Search in sources :

Example 41 with ApsProperties

use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.

the class TestWidgetTypeAction method testPasteNewUserWidgetType_1.

public void testPasteNewUserWidgetType_1() throws Throwable {
    String widgetTypeCode = "randomShowletCode_1";
    try {
        assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
        String result = this.executePasteUserWidgetType("admin", widgetTypeCode, "en", "it", "coach_page", "2");
        assertEquals(Action.SUCCESS, result);
        Widget copiedWidget = this._pageManager.getDraftPage("coach_page").getWidgets()[2];
        assertNotNull(copiedWidget);
        assertNotNull(copiedWidget.getConfig());
        WidgetType addedType = this._widgetTypeManager.getWidgetType(widgetTypeCode);
        assertNotNull(addedType);
        ApsProperties config = addedType.getConfig();
        Iterator<Object> keysIter = config.keySet().iterator();
        while (keysIter.hasNext()) {
            String key = (String) keysIter.next();
            assertEquals(copiedWidget.getConfig().getProperty(key), config.getProperty(key));
        }
    } catch (Throwable t) {
        throw t;
    } finally {
        this._widgetTypeManager.deleteWidgetType(widgetTypeCode);
    }
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 42 with ApsProperties

use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.

the class TestPageAction method testSavePage_Draft_2.

public void testSavePage_Draft_2() throws Throwable {
    String pageCode = "pagina_test_2";
    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);
        assertNotNull(addedPage);
        this.executeSetDefaultWidgets(params, "admin");
        addedPage = this._pageManager.getDraftPage(pageCode);
        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 43 with ApsProperties

use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.

the class TestLocaleStringAction method testSaveEdit.

public void testSaveEdit() throws Throwable {
    String key = "NEW_KEY";
    assertFalse(this._i18nManager.getLabelGroups().containsKey(key));
    try {
        ApsProperties labels = this.prepareLabelProperties("itLabel", "enLabel");
        this._i18nManager.addLabelGroup(key, labels);
        String result = this.executeSaveEdit("admin", key, "updatedKeyIt", "updatedKeyEn");
        assertEquals(Action.SUCCESS, result);
        assertTrue(this._i18nManager.getLabelGroups().containsKey(key));
        assertEquals(this._i18nManager.getLabel(key, "it"), "updatedKeyIt");
        assertEquals(this._i18nManager.getLabel(key, "en"), "updatedKeyEn");
    } catch (Throwable t) {
        throw t;
    } finally {
        this._i18nManager.deleteLabelGroup(key);
        assertFalse(this._i18nManager.getLabelGroups().containsKey(key));
    }
}
Also used : ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 44 with ApsProperties

use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.

the class TestLocaleStringAction method testSaveDelete.

public void testSaveDelete() throws Throwable {
    String key = "NEW_KEY";
    try {
        ApsProperties labels = this.prepareLabelProperties("itLabel", "enLabel");
        this._i18nManager.addLabelGroup(key, labels);
        String result = this.executeDelete("admin", key);
        assertEquals(Action.SUCCESS, result);
        assertFalse(this._i18nManager.getLabelGroups().containsKey(key));
    } catch (Throwable t) {
        throw t;
    } finally {
        this._i18nManager.deleteLabelGroup(key);
    }
}
Also used : ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 45 with ApsProperties

use of com.agiletec.aps.util.ApsProperties 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)

Aggregations

ApsProperties (com.agiletec.aps.util.ApsProperties)157 Widget (com.agiletec.aps.system.services.page.Widget)62 WidgetType (org.entando.entando.aps.system.services.widgettype.WidgetType)35 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)28 HashMap (java.util.HashMap)22 IPage (com.agiletec.aps.system.services.page.IPage)18 Lang (com.agiletec.aps.system.services.lang.Lang)14 Test (org.junit.Test)12 PageModel (com.agiletec.aps.system.services.pagemodel.PageModel)10 Properties (java.util.Properties)9 RestServerError (org.entando.entando.aps.system.exception.RestServerError)9 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)9 Page (com.agiletec.aps.system.services.page.Page)8 PageMetadata (com.agiletec.aps.system.services.page.PageMetadata)8 List (java.util.List)8 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)7 NavigatorExpression (com.agiletec.aps.system.services.page.widget.NavigatorExpression)6 ArrayList (java.util.ArrayList)6 IWidgetTypeManager (org.entando.entando.aps.system.services.widgettype.IWidgetTypeManager)6 ResourceNotFoundException (org.entando.entando.aps.system.exception.ResourceNotFoundException)5