use of io.gravitee.management.model.PageEntity in project gravitee-management-rest-api by gravitee-io.
the class SwaggerService_TransformTest method getPage.
private PageEntity getPage(String resource, String contentType) throws IOException {
URL url = Resources.getResource(resource);
String descriptor = Resources.toString(url, Charsets.UTF_8);
PageEntity pageEntity = new PageEntity();
pageEntity.setContent(descriptor);
pageEntity.setContentType(contentType);
PageConfigurationEntity pageConfigurationEntity = new PageConfigurationEntity();
pageConfigurationEntity.setTryIt(true);
pageConfigurationEntity.setTryItURL("https://my.domain.com/v1");
pageEntity.setConfiguration(pageConfigurationEntity);
return pageEntity;
}
use of io.gravitee.management.model.PageEntity in project gravitee-management-rest-api by gravitee-io.
the class PageService_CreateTest method shouldCreatePage.
@Test
public void shouldCreatePage() throws TechnicalException {
final String name = "MARKDOWN";
final String contrib = "contrib";
final String content = "content";
final String type = "MARKDOWN";
when(page1.getId()).thenReturn(PAGE_ID);
when(page1.getName()).thenReturn(name);
when(page1.getApi()).thenReturn(API_ID);
when(page1.getType()).thenReturn(PageType.valueOf(type));
when(page1.getLastContributor()).thenReturn(contrib);
when(page1.getOrder()).thenReturn(1);
when(page1.getContent()).thenReturn(content);
when(pageRepository.findById(anyString())).thenReturn(Optional.empty());
when(pageRepository.create(any())).thenReturn(page1);
when(newPage.getName()).thenReturn(name);
when(newPage.getOrder()).thenReturn(1);
when(newPage.getContent()).thenReturn(content);
when(newPage.getLastContributor()).thenReturn(contrib);
when(newPage.getType()).thenReturn(io.gravitee.management.model.PageType.SWAGGER);
final PageEntity createdPage = pageService.createApiPage(API_ID, newPage);
verify(pageRepository).create(argThat(new ArgumentMatcher<Page>() {
public boolean matches(Object argument) {
final Page pageToCreate = (Page) argument;
return pageToCreate.getId().split("-").length == 5 && API_ID.equals(pageToCreate.getApi()) && name.equals(pageToCreate.getName()) && contrib.equals(pageToCreate.getLastContributor()) && content.equals(pageToCreate.getContent()) && io.gravitee.management.model.PageType.SWAGGER.name().equals(pageToCreate.getType().name()) && pageToCreate.getCreatedAt() != null && pageToCreate.getUpdatedAt() != null && pageToCreate.getCreatedAt().equals(pageToCreate.getUpdatedAt());
}
}));
assertNotNull(createdPage);
assertEquals(5, createdPage.getId().split("-").length);
assertEquals(1, createdPage.getOrder());
assertEquals(content, createdPage.getContent());
assertEquals(contrib, createdPage.getLastContributor());
assertEquals(type, createdPage.getType());
}
use of io.gravitee.management.model.PageEntity in project gravitee-management-rest-api by gravitee-io.
the class PageService_FindByIdTest method shouldFindById.
@Test
public void shouldFindById() throws TechnicalException {
when(page1.getId()).thenReturn(PAGE_ID);
when(page1.getOrder()).thenReturn(1);
when(pageRepository.findById(PAGE_ID)).thenReturn(Optional.of(page1));
final PageEntity pageEntity = pageService.findById(PAGE_ID);
assertNotNull(pageEntity);
assertEquals(1, pageEntity.getOrder());
assertEquals(PAGE_ID, pageEntity.getId());
}
Aggregations