Search in sources :

Example 86 with IPage

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

the class DataObjectModelServiceTest method should_raise_exception_on_delete_referenced_dataModel.

@Test(expected = ValidationConflictException.class)
public void should_raise_exception_on_delete_referenced_dataModel() throws Throwable {
    DataObjectModel mockDataModel = new DataObjectModel();
    mockDataModel.setId(234l);
    when(this.dataObjectModelManager.getDataObjectModel(any(Long.class))).thenReturn(mockDataModel);
    DataModelDto dto = new DataModelDto(mockDataModel);
    when(this.dtoBuilder.convert(mockDataModel)).thenReturn(dto);
    Map<String, List<IPage>> utilizers = new HashMap<>();
    List<IPage> pages = new ArrayList<>();
    Page referencedPage = new Page();
    referencedPage.setCode("referenced");
    pages.add(referencedPage);
    utilizers.put("ABC123", pages);
    when(this.dataObjectModelManager.getReferencingPages(any(Long.class))).thenReturn(utilizers);
    this.dataObjectModelService.removeDataObjectModel(34l);
}
Also used : DataModelDto(org.entando.entando.aps.system.services.dataobjectmodel.model.DataModelDto) IPage(com.agiletec.aps.system.services.page.IPage) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Page(com.agiletec.aps.system.services.page.Page) IPage(com.agiletec.aps.system.services.page.IPage) Test(org.junit.Test)

Example 87 with IPage

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

the class DataObjectMapperCacheWrapperTest method createMockPage.

private IPage createMockPage() {
    Page root = new Page();
    root.setCode("root_code");
    root.setModel(this.createMockPageModel());
    root.setGroup(Group.FREE_GROUP_NAME);
    Widget[] widgets = new Widget[] { this.createMockWidget() };
    root.setWidgets(widgets);
    root.setChildrenCodes(new String[] {});
    return root;
}
Also used : Widget(com.agiletec.aps.system.services.page.Widget) Page(com.agiletec.aps.system.services.page.Page) IPage(com.agiletec.aps.system.services.page.IPage)

Example 88 with IPage

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

the class TestPageConfigAction method testUpdateConfig.

public void testUpdateConfig() throws Throwable {
    String pageCode = "test_page";
    assertNull(this._pageManager.getDraftPage(pageCode));
    try {
        IPage parentPage = _pageManager.getDraftRoot();
        PageModel pageModel = parentPage.getMetadata().getModel();
        PageMetadata metadata = PageTestUtil.createPageMetadata(pageModel, true, "pagina temporanea", null, null, false, null, null);
        Page pageToAdd = PageTestUtil.createPage(pageCode, parentPage.getCode(), "free", metadata, pageModel.getDefaultWidget());
        this._pageManager.addPage(pageToAdd);
        IPage addedPage = this._pageManager.getDraftPage(pageCode);
        assertNotNull(addedPage);
        Date lastUpdate = addedPage.getMetadata().getUpdatedAt();
        assertNotNull(lastUpdate);
        synchronized (this) {
            wait(1000);
        }
        String result = this.executeJoinWidget(pageCode, 0, "logic_type", "admin");
        assertEquals(Action.SUCCESS, result);
        IPage modifiedPage = this._pageManager.getDraftPage(pageCode);
        assertNotNull(modifiedPage);
        assertTrue(modifiedPage.getMetadata().getUpdatedAt().after(lastUpdate));
    } catch (Throwable t) {
        throw t;
    } finally {
        this._pageManager.deletePage(pageCode);
    }
}
Also used : PageMetadata(com.agiletec.aps.system.services.page.PageMetadata) IPage(com.agiletec.aps.system.services.page.IPage) IPage(com.agiletec.aps.system.services.page.IPage) Page(com.agiletec.aps.system.services.page.Page) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel) Date(java.util.Date)

Example 89 with IPage

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

the class TestPageConfigAction method testTrashWidget.

public void testTrashWidget() 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.executeTrashWidget(pageCode, frame, "pageManagerCoach");
        assertEquals("pageTree", result);
        assertEquals(1, this.getAction().getActionErrors().size());
        result = this.executeTrashWidget(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 90 with IPage

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

the class TestPageConfigAction method testDeleteWidget.

public void testDeleteWidget() 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.executeDeleteWidget(pageCode, frame, "pageManagerCoach");
        assertEquals("pageTree", result);
        assertEquals(1, this.getAction().getActionErrors().size());
        result = this.executeDeleteWidget(pageCode, frame, "admin");
        assertEquals(Action.SUCCESS, result);
        IPage modifiedContentview = this._pageManager.getDraftPage(pageCode);
        Widget[] modifiedShowlets = modifiedContentview.getWidgets();
        assertNull(modifiedShowlets[frame]);
    } catch (Throwable t) {
        throw t;
    } finally {
        contentview = this._pageManager.getDraftPage(pageCode);
        contentview.getWidgets()[frame] = widget;
        this._pageManager.updatePage(contentview);
    }
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) Widget(com.agiletec.aps.system.services.page.Widget)

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