use of io.gravitee.rest.api.portal.rest.model.Page in project gravitee-management-rest-api by gravitee-io.
the class PageResourceTest method shouldGetPage.
@Test
public void shouldGetPage() {
final Response response = target(PUBLISHED_PAGE).request().get();
assertEquals(OK_200, response.getStatus());
final Page pageResponse = response.readEntity(Page.class);
assertNotNull(pageResponse);
assertNull(pageResponse.getContent());
assertNotNull(pageResponse.getLinks());
}
use of io.gravitee.rest.api.portal.rest.model.Page in project gravitee-management-rest-api by gravitee-io.
the class ApiResourceNotAuthenticatedTest method init.
@Before
public void init() {
resetAllMocks();
mockApi = new ApiEntity();
mockApi.setId(API);
doReturn(mockApi).when(apiService).findById(API);
when(accessControlService.canAccessApiFromPortal(API)).thenReturn(true);
when(accessControlService.canAccessApiFromPortal(mockApi)).thenReturn(true);
doReturn(Arrays.asList(new PageEntity())).when(pageService).search(any(), eq(GraviteeContext.getCurrentEnvironment()));
PlanEntity plan1 = new PlanEntity();
plan1.setId("A");
plan1.setStatus(PlanStatus.PUBLISHED);
PlanEntity plan2 = new PlanEntity();
plan2.setId("B");
plan2.setStatus(PlanStatus.PUBLISHED);
PlanEntity plan3 = new PlanEntity();
plan3.setId("C");
plan3.setStatus(PlanStatus.CLOSED);
doReturn(new HashSet<PlanEntity>(Arrays.asList(plan1, plan2, plan3))).when(planService).findByApi(API);
doReturn(new Api()).when(apiMapper).convert(any());
doReturn(new Page()).when(pageMapper).convert(any());
doReturn(new Plan()).when(planMapper).convert(any());
}
use of io.gravitee.rest.api.portal.rest.model.Page 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());
}
use of io.gravitee.rest.api.portal.rest.model.Page 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());
}
use of io.gravitee.rest.api.portal.rest.model.Page 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());
}
Aggregations