Search in sources :

Example 91 with IPage

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

the class TestPageConfigAction method testJoinRemoveWidget.

private void testJoinRemoveWidget(String widgetTypeCode) throws Throwable {
    String pageCode = "pagina_1";
    int frame = 1;
    IPage pagina_1 = this._pageManager.getDraftPage(pageCode);
    try {
        assertNull(pagina_1.getWidgets()[frame]);
        String result = this.executeJoinWidget(pageCode, frame, widgetTypeCode, "pageManagerCoach");
        assertEquals("pageTree", result);
        result = this.executeJoinWidget(pageCode, frame, widgetTypeCode, "admin");
        assertEquals(Action.SUCCESS, result);
        pagina_1 = this._pageManager.getDraftPage(pageCode);
        assertNotNull(pagina_1.getWidgets()[frame]);
        assertEquals(widgetTypeCode, pagina_1.getWidgets()[frame].getType().getCode());
        result = this.executeTrashWidget(pageCode, frame, "admin");
        assertEquals(Action.SUCCESS, result);
        pagina_1 = this._pageManager.getDraftPage(pageCode);
        assertNotNull(pagina_1.getWidgets()[frame]);
        result = this.executeDeleteWidget(pageCode, frame, "admin");
        assertEquals(Action.SUCCESS, result);
        pagina_1 = this._pageManager.getDraftPage(pageCode);
        assertNull(pagina_1.getWidgets()[frame]);
    } catch (Throwable t) {
        throw t;
    } finally {
        pagina_1.getWidgets()[frame] = null;
        this._pageManager.updatePage(pagina_1);
    }
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage)

Example 92 with IPage

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

the class TestPageConfigAction method testJoinWidget.

public void testJoinWidget() throws Throwable {
    String pageCode = "pagina_1";
    int frame = 1;
    IPage pagina_1 = this._pageManager.getDraftPage(pageCode);
    try {
        assertNull(pagina_1.getWidgets()[frame]);
        String result = this.executeJoinWidget(pageCode, frame, "leftmenu", "admin");
        assertEquals("configureSpecialWidget", result);
        result = this.executeJoinWidget(pageCode, frame, "leftmenu", "pageManagerCoach");
        assertEquals("pageTree", result);
        assertEquals(1, this.getAction().getActionErrors().size());
    } catch (Throwable t) {
        throw t;
    } finally {
        pagina_1.getWidgets()[frame] = null;
        this._pageManager.updatePage(pagina_1);
    }
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage)

Example 93 with IPage

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

the class TestActivityStream method addPage.

private void addPage(String pageCode) throws Throwable {
    assertNull(this.pageManager.getDraftPage(pageCode));
    try {
        IPage root = this.pageManager.getOnlineRoot();
        Map<String, String> params = new HashMap<>();
        params.put("strutsAction", String.valueOf(ApsAdminSystemConstants.ADD));
        params.put("parentPageCode", root.getCode());
        List<Lang> langs = this.langManager.getLangs();
        for (Lang lang : langs) {
            params.put("lang" + lang.getCode(), "Page " + lang.getDescr());
        }
        params.put("model", "home");
        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);
    } catch (Throwable t) {
        throw t;
    }
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) HashMap(java.util.HashMap) Lang(com.agiletec.aps.system.services.lang.Lang)

Example 94 with IPage

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

the class TestPageAction method testValidateSavePage.

public void testValidateSavePage() throws Throwable {
    String pageCode = "pagina_test";
    String longPageCode = "very_long_page_code__very_long_page_code";
    assertNull(this._pageManager.getDraftPage(pageCode));
    assertNull(this._pageManager.getDraftPage(longPageCode));
    try {
        IPage root = this._pageManager.getDraftRoot();
        Map<String, String> params = new HashMap<String, String>();
        params.put("strutsAction", String.valueOf(ApsAdminSystemConstants.ADD));
        String result = this.executeSave(params, "admin");
        assertEquals(Action.INPUT, result);
        Map<String, List<String>> fieldErrors = this.getAction().getFieldErrors();
        assertEquals(6, fieldErrors.size());
        assertTrue(fieldErrors.containsKey("pageCode"));
        assertTrue(fieldErrors.containsKey("parentPageCode"));
        assertTrue(fieldErrors.containsKey("model"));
        assertTrue(fieldErrors.containsKey("group"));
        assertTrue(fieldErrors.containsKey("langit"));
        assertTrue(fieldErrors.containsKey("langen"));
        params.put("parentPageCode", root.getCode());
        result = this.executeSave(params, "admin");
        assertEquals(Action.INPUT, result);
        fieldErrors = this.getAction().getFieldErrors();
        assertEquals(5, fieldErrors.size());
        assertTrue(fieldErrors.containsKey("pageCode"));
        assertTrue(fieldErrors.containsKey("model"));
        assertTrue(fieldErrors.containsKey("group"));
        assertTrue(fieldErrors.containsKey("langit"));
        assertTrue(fieldErrors.containsKey("langen"));
        params.put("langit", "Pagina Test");
        params.put("model", "home");
        result = this.executeSave(params, "admin");
        assertEquals(Action.INPUT, result);
        fieldErrors = this.getAction().getFieldErrors();
        assertEquals(3, fieldErrors.size());
        assertTrue(fieldErrors.containsKey("pageCode"));
        assertTrue(fieldErrors.containsKey("group"));
        assertTrue(fieldErrors.containsKey("langen"));
        assertNotNull(this._pageManager.getDraftPage("pagina_1"));
        params.put("langen", "Test Page");
        params.put("group", Group.FREE_GROUP_NAME);
        // page already present
        params.put("pageCode", "pagina_1");
        result = this.executeSave(params, "admin");
        assertEquals(Action.INPUT, result);
        fieldErrors = this.getAction().getFieldErrors();
        assertEquals(1, fieldErrors.size());
        assertTrue(fieldErrors.containsKey("pageCode"));
        params.put("pageCode", longPageCode);
        result = this.executeSave(params, "admin");
        assertEquals(Action.INPUT, result);
        fieldErrors = this.getAction().getFieldErrors();
        assertEquals(1, fieldErrors.size());
        assertTrue(fieldErrors.containsKey("pageCode"));
        // very long title
        params.put("langen", String.join("", Collections.nCopies(71, "x")));
        result = this.executeSave(params, "admin");
        assertEquals(Action.INPUT, result);
        fieldErrors = this.getAction().getFieldErrors();
        assertEquals(2, fieldErrors.size());
        assertTrue(fieldErrors.containsKey("pageCode"));
        assertTrue(fieldErrors.containsKey("langen"));
    } catch (Throwable t) {
        this._pageManager.deletePage(pageCode);
        this._pageManager.deletePage(longPageCode);
        throw t;
    }
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) HashMap(java.util.HashMap) List(java.util.List)

Example 95 with IPage

use of com.agiletec.aps.system.services.page.IPage 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)

Aggregations

IPage (com.agiletec.aps.system.services.page.IPage)253 Widget (com.agiletec.aps.system.services.page.Widget)55 ArrayList (java.util.ArrayList)41 Page (com.agiletec.aps.system.services.page.Page)37 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)30 PageMetadata (com.agiletec.aps.system.services.page.PageMetadata)25 HashMap (java.util.HashMap)23 ApsProperties (com.agiletec.aps.util.ApsProperties)20 List (java.util.List)20 RestServerError (org.entando.entando.aps.system.exception.RestServerError)18 IPageManager (com.agiletec.aps.system.services.page.IPageManager)16 UserDetails (com.agiletec.aps.system.services.user.UserDetails)16 ResourceNotFoundException (org.entando.entando.aps.system.exception.ResourceNotFoundException)16 RequestContext (com.agiletec.aps.system.RequestContext)15 PageModel (com.agiletec.aps.system.services.pagemodel.PageModel)15 WidgetType (org.entando.entando.aps.system.services.widgettype.WidgetType)15 Test (org.junit.Test)14 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)13 Lang (com.agiletec.aps.system.services.lang.Lang)12 ResultActions (org.springframework.test.web.servlet.ResultActions)12