use of io.gravitee.rest.api.portal.rest.model.PageLinks in project gravitee-management-rest-api by gravitee-io.
the class ApiPageResourceTest method init.
@Before
public void init() {
resetAllMocks();
ApiEntity mockApi = new ApiEntity();
mockApi.setId(API);
doReturn(mockApi).when(apiService).findById(API);
Set<ApiEntity> mockApis = new HashSet<>(Arrays.asList(mockApi));
doReturn(mockApis).when(apiService).findPublishedByUser(any(), argThat(q -> singletonList(API).equals(q.getIds())));
doReturn(true).when(accessControlService).canAccessApiFromPortal(API);
PageEntity page1 = new PageEntity();
page1.setPublished(true);
page1.setVisibility(Visibility.PUBLIC);
page1.setContent(PAGE_CONTENT);
doReturn(page1).when(pageService).findById(PAGE, null);
doReturn(true).when(accessControlService).canAccessPageFromPortal(API, page1);
doReturn(new Page()).when(pageMapper).convert(any(), any(), any());
doReturn(new PageLinks()).when(pageMapper).computePageLinks(any(), any());
}
use of io.gravitee.rest.api.portal.rest.model.PageLinks in project gravitee-management-rest-api by gravitee-io.
the class PageResourceTest method init.
@Before
public void init() {
resetAllMocks();
PageEntity publishedPage = new PageEntity();
publishedPage.setPublished(true);
publishedPage.setVisibility(Visibility.PUBLIC);
publishedPage.setContent(PAGE_CONTENT);
doReturn(publishedPage).when(pageService).findById(PUBLISHED_PAGE, null);
PageEntity unPublishedPage = new PageEntity();
unPublishedPage.setPublished(false);
publishedPage.setVisibility(Visibility.PUBLIC);
unPublishedPage.setContent(PAGE_CONTENT);
doReturn(unPublishedPage).when(pageService).findById(UNPUBLISHED_PAGE, null);
mockAnotherPage = new PageEntity();
mockAnotherPage.setPublished(true);
publishedPage.setVisibility(Visibility.PUBLIC);
Map<String, String> metadataMap = new HashMap<>();
metadataMap.put(ANOTHER_PAGE, ANOTHER_PAGE);
mockAnotherPage.setMetadata(metadataMap);
doReturn(mockAnotherPage).when(pageService).findById(ANOTHER_PAGE, null);
doThrow(new PageNotFoundException(UNKNOWN_PAGE)).when(pageService).findById(UNKNOWN_PAGE, null);
doReturn(new Page()).when(pageMapper).convert(any(), any(), any());
doReturn(new PageLinks()).when(pageMapper).computePageLinks(any(), any());
doReturn(true).when(accessControlService).canAccessApiFromPortal(anyString());
doReturn(true).when(accessControlService).canAccessPageFromPortal(any());
}
use of io.gravitee.rest.api.portal.rest.model.PageLinks in project gravitee-management-rest-api by gravitee-io.
the class PagesResourceTest method init.
@Before
public void init() throws IOException {
resetAllMocks();
doReturn(new Page()).when(pageMapper).convert(any());
doReturn(new PageLinks()).when(pageMapper).computePageLinks(any(), any());
}
use of io.gravitee.rest.api.portal.rest.model.PageLinks in project gravitee-management-rest-api by gravitee-io.
the class PageMapperTest method testPageLinks.
@Test
public void testPageLinks() {
String basePath = "/" + PAGE_ID;
String parentPath = "/" + PAGE_PARENT;
PageLinks links = pageMapper.computePageLinks(basePath, parentPath);
assertNotNull(links);
assertEquals(basePath, links.getSelf());
assertEquals(basePath + "/content", links.getContent());
assertEquals(parentPath, links.getParent());
}
Aggregations