Search in sources :

Example 6 with PageDto

use of org.entando.entando.aps.system.services.page.model.PageDto in project entando-core by entando.

the class PageAuthorizationServiceIntegrationTest method testFilteredPageTree.

@Test
public void testFilteredPageTree() throws Throwable {
    UserDetails admin = this.getUser("admin");
    UserDetails customer = this.getUser("editorCustomers");
    List<PageDto> pages = this.pageService.getPages("homepage");
    List<PageDto> pagesForAdmin = this.authorizationService.filterList(admin, pages);
    List<PageDto> pagesForCustomer = this.authorizationService.filterList(customer, pages);
    assertEquals(7, pagesForAdmin.size());
    assertEquals(5, pagesForCustomer.size());
    pagesForCustomer.forEach(page -> assertTrue((page.getOwnerGroup().equals(Group.FREE_GROUP_NAME) || page.getOwnerGroup().equals("customers"))));
}
Also used : UserDetails(com.agiletec.aps.system.services.user.UserDetails) PageDto(org.entando.entando.aps.system.services.page.model.PageDto) Test(org.junit.Test)

Example 7 with PageDto

use of org.entando.entando.aps.system.services.page.model.PageDto in project entando-core by entando.

the class PageServiceIntegrationTest method testGetPage.

@Test
public void testGetPage() {
    PageDto page = pageService.getPage("pagina_1", IPageService.STATUS_ONLINE);
    assertNotNull(page);
    assertEquals(IPageService.STATUS_ONLINE, page.getStatus());
}
Also used : PageDto(org.entando.entando.aps.system.services.page.model.PageDto) Test(org.junit.Test)

Example 8 with PageDto

use of org.entando.entando.aps.system.services.page.model.PageDto in project entando-core by entando.

the class PageServiceIntegrationTest method testAddAndRemovePage.

@Test
public void testAddAndRemovePage() throws Throwable {
    PageDto pageToClone = pageService.getPage("pagina_11", "draft");
    assertNotNull(pageToClone);
    PageRequest pageRequest = this.createRequestFromDto(pageToClone);
    pageRequest.setCode("pagina_13");
    PageDto addedPage = pageService.addPage(pageRequest);
    assertNotNull(addedPage);
    assertEquals("pagina_13", addedPage.getCode());
    assertEquals("pagina_1", addedPage.getParentCode());
    addedPage = pageService.getPage("pagina_13", "draft");
    assertNotNull(addedPage);
    assertEquals("pagina_13", addedPage.getCode());
    assertEquals("pagina_1", addedPage.getParentCode());
    pageService.removePage("pagina_13");
    try {
        addedPage = null;
        addedPage = pageService.getPage("pagina_13", "draft");
        fail("RestRourceNotFoundException not thrown");
    } catch (RestRourceNotFoundException e) {
        assertNull(addedPage);
    }
}
Also used : RestRourceNotFoundException(org.entando.entando.aps.system.exception.RestRourceNotFoundException) PageRequest(org.entando.entando.web.page.model.PageRequest) PageDto(org.entando.entando.aps.system.services.page.model.PageDto) Test(org.junit.Test)

Example 9 with PageDto

use of org.entando.entando.aps.system.services.page.model.PageDto in project entando-core by entando.

the class PageServiceIntegrationTest method testUpdatePage.

@Test
public void testUpdatePage() {
    PageDto oldPages = pageService.getPage("pagina_12", "draft");
    assertNotNull(oldPages);
    assertEquals(2, oldPages.getTitles().size());
    assertEquals("Pagina 1-2", oldPages.getTitles().get("it"));
    PageRequest pageRequest = this.createRequestFromDto(oldPages);
    pageRequest.getTitles().put("it", "Pagina 1-2 mod");
    PageDto modPage = pageService.updatePage("pagina_12", pageRequest);
    assertNotNull(modPage);
    assertEquals(2, modPage.getTitles().size());
    assertEquals("Pagina 1-2 mod", modPage.getTitles().get("it"));
    modPage = pageService.getPage("pagina_12", "draft");
    assertNotNull(modPage);
    assertEquals(2, modPage.getTitles().size());
    assertEquals("Pagina 1-2 mod", modPage.getTitles().get("it"));
    pageRequest.getTitles().put("it", "Pagina 1-2");
    modPage = pageService.updatePage("pagina_12", pageRequest);
    modPage = pageService.getPage("pagina_12", "draft");
    assertNotNull(modPage);
    assertEquals(2, modPage.getTitles().size());
    assertEquals("Pagina 1-2", modPage.getTitles().get("it"));
}
Also used : PageRequest(org.entando.entando.web.page.model.PageRequest) PageDto(org.entando.entando.aps.system.services.page.model.PageDto) Test(org.junit.Test)

Example 10 with PageDto

use of org.entando.entando.aps.system.services.page.model.PageDto in project entando-core by entando.

the class PageServiceIntegrationTest method testChangeNode.

@Test
public void testChangeNode() {
    PageDto pageToClone = pageService.getPage("pagina_11", "draft");
    assertNotNull(pageToClone);
    PageRequest pageRequest = this.createRequestFromDto(pageToClone);
    pageRequest.setCode("pagina_13");
    PageDto addedPage = pageService.addPage(pageRequest);
    assertNotNull(addedPage);
    assertEquals("pagina_1", addedPage.getParentCode());
    assertEquals(3, addedPage.getPosition());
    PagePositionRequest pagePosRequest = new PagePositionRequest();
    pagePosRequest.setCode("pagina_13");
    pagePosRequest.setParentCode("pagina_2");
    pagePosRequest.setPosition(1);
    addedPage = pageService.movePage("pagina_13", pagePosRequest);
    assertNotNull(addedPage);
    assertEquals("pagina_2", addedPage.getParentCode());
    assertEquals(1, addedPage.getPosition());
    List<PageDto> pages = pageService.getPages("pagina_2");
    assertNotNull(pages);
    assertEquals(1, pages.size());
    assertEquals("pagina_13", pages.get(0).getCode());
    pageService.removePage("pagina_13");
}
Also used : PageRequest(org.entando.entando.web.page.model.PageRequest) PageDto(org.entando.entando.aps.system.services.page.model.PageDto) PagePositionRequest(org.entando.entando.web.page.model.PagePositionRequest) Test(org.junit.Test)

Aggregations

PageDto (org.entando.entando.aps.system.services.page.model.PageDto)18 ArrayList (java.util.ArrayList)10 Test (org.junit.Test)9 HashMap (java.util.HashMap)7 RestAccessControl (org.entando.entando.web.common.annotation.RestAccessControl)7 RestResponse (org.entando.entando.web.common.model.RestResponse)7 PageRequest (org.entando.entando.web.page.model.PageRequest)7 ResponseEntity (org.springframework.http.ResponseEntity)7 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 ValidationGenericException (org.entando.entando.web.common.exceptions.ValidationGenericException)6 UserDetails (com.agiletec.aps.system.services.user.UserDetails)3 List (java.util.List)3 PagePositionRequest (org.entando.entando.web.page.model.PagePositionRequest)3 RestRourceNotFoundException (org.entando.entando.aps.system.exception.RestRourceNotFoundException)2 AbstractControllerTest (org.entando.entando.web.AbstractControllerTest)2 ResultActions (org.springframework.test.web.servlet.ResultActions)2 IManager (com.agiletec.aps.system.common.IManager)1 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)1 GroupUtilizer (com.agiletec.aps.system.services.group.GroupUtilizer)1 IGroupManager (com.agiletec.aps.system.services.group.IGroupManager)1