Search in sources :

Example 1 with PagesResponse

use of io.gravitee.rest.api.portal.rest.model.PagesResponse in project gravitee-management-rest-api by gravitee-io.

the class PagesResourceTest method shouldGetNoPageIfAuthorizeAndNotPublished.

@Test
public void shouldGetNoPageIfAuthorizeAndNotPublished() {
    doReturn(Collections.emptyList()).when(pageService).search(any(), isNull(), eq(GraviteeContext.getCurrentEnvironment()));
    Response response = target().request().get();
    assertEquals(OK_200, response.getStatus());
    PagesResponse pagesResponse = response.readEntity(PagesResponse.class);
    List<Page> pages = pagesResponse.getData();
    assertNotNull(pages);
    assertEquals(0, pages.size());
}
Also used : PagesResponse(io.gravitee.rest.api.portal.rest.model.PagesResponse) Response(javax.ws.rs.core.Response) Page(io.gravitee.rest.api.portal.rest.model.Page) PagesResponse(io.gravitee.rest.api.portal.rest.model.PagesResponse) Test(org.junit.Test)

Example 2 with PagesResponse

use of io.gravitee.rest.api.portal.rest.model.PagesResponse in project gravitee-management-rest-api by gravitee-io.

the class PagesResourceTest method shouldGetNoPageIfNotAuthorizeAndPublishedPageAndNotSystemFolder.

@Test
public void shouldGetNoPageIfNotAuthorizeAndPublishedPageAndNotSystemFolder() {
    PageEntity publishedPage = new PageEntity();
    publishedPage.setPublished(true);
    doReturn(singletonList(publishedPage)).when(pageService).search(any(), isNull(), eq(GraviteeContext.getCurrentEnvironment()));
    Response response = target().request().get();
    assertEquals(OK_200, response.getStatus());
    PagesResponse pagesResponse = response.readEntity(PagesResponse.class);
    List<Page> pages = pagesResponse.getData();
    assertNotNull(pages);
    assertEquals(0, pages.size());
}
Also used : PageEntity(io.gravitee.rest.api.model.PageEntity) PagesResponse(io.gravitee.rest.api.portal.rest.model.PagesResponse) Response(javax.ws.rs.core.Response) Page(io.gravitee.rest.api.portal.rest.model.Page) PagesResponse(io.gravitee.rest.api.portal.rest.model.PagesResponse) Test(org.junit.Test)

Example 3 with PagesResponse

use of io.gravitee.rest.api.portal.rest.model.PagesResponse in project gravitee-management-rest-api by gravitee-io.

the class PagesResourceTest method shouldGetPagesIfAuthorizeAndPublishedPageAndNotSystemFolder.

@Test
public void shouldGetPagesIfAuthorizeAndPublishedPageAndNotSystemFolder() {
    PageEntity publishedPage = new PageEntity();
    publishedPage.setPublished(true);
    PageEntity markdownTemplatePage = new PageEntity();
    markdownTemplatePage.setPublished(true);
    markdownTemplatePage.setType(PageType.MARKDOWN_TEMPLATE.name());
    doReturn(Arrays.asList(publishedPage, markdownTemplatePage)).when(pageService).search(any(), isNull(), eq(GraviteeContext.getCurrentEnvironment()));
    when(accessControlService.canAccessPageFromPortal(any(PageEntity.class))).thenAnswer(invocationOnMock -> {
        PageEntity page = invocationOnMock.getArgument(0);
        return !PageType.MARKDOWN_TEMPLATE.name().equals(page.getType());
    });
    final Response response = target().request().get();
    assertEquals(OK_200, response.getStatus());
    final PagesResponse pagesResponse = response.readEntity(PagesResponse.class);
    List<Page> pages = pagesResponse.getData();
    assertNotNull(pages);
    assertEquals(1, pages.size());
    assertNotNull(pages.get(0).getLinks());
}
Also used : PageEntity(io.gravitee.rest.api.model.PageEntity) PagesResponse(io.gravitee.rest.api.portal.rest.model.PagesResponse) Response(javax.ws.rs.core.Response) Page(io.gravitee.rest.api.portal.rest.model.Page) PagesResponse(io.gravitee.rest.api.portal.rest.model.PagesResponse) Test(org.junit.Test)

Example 4 with PagesResponse

use of io.gravitee.rest.api.portal.rest.model.PagesResponse in project gravitee-management-rest-api by gravitee-io.

the class PagesResourceTest method shouldGetNoPageIfAuthorizeAndPublishedPageAndSystemFolder.

@Test
public void shouldGetNoPageIfAuthorizeAndPublishedPageAndSystemFolder() {
    PageEntity publishedPage = new PageEntity();
    publishedPage.setPublished(true);
    publishedPage.setType("SYSTEM_FOLDER");
    doReturn(singletonList(publishedPage)).when(pageService).search(any(), isNull(), eq(GraviteeContext.getCurrentEnvironment()));
    Response response = target().request().get();
    assertEquals(OK_200, response.getStatus());
    PagesResponse pagesResponse = response.readEntity(PagesResponse.class);
    List<Page> pages = pagesResponse.getData();
    assertNotNull(pages);
    assertEquals(0, pages.size());
}
Also used : PageEntity(io.gravitee.rest.api.model.PageEntity) PagesResponse(io.gravitee.rest.api.portal.rest.model.PagesResponse) Response(javax.ws.rs.core.Response) Page(io.gravitee.rest.api.portal.rest.model.Page) PagesResponse(io.gravitee.rest.api.portal.rest.model.PagesResponse) Test(org.junit.Test)

Aggregations

Page (io.gravitee.rest.api.portal.rest.model.Page)4 PagesResponse (io.gravitee.rest.api.portal.rest.model.PagesResponse)4 Response (javax.ws.rs.core.Response)4 Test (org.junit.Test)4 PageEntity (io.gravitee.rest.api.model.PageEntity)3