Search in sources :

Example 1 with PageEntity

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

the class SwaggerService_TransformTest method shouldTransformAPIFromSwaggerV2_json.

@Test
public void shouldTransformAPIFromSwaggerV2_json() throws IOException {
    PageEntity pageEntity = getPage("io/gravitee/management/service/swagger-petstore.json", MediaType.APPLICATION_JSON);
    swaggerService.transform(pageEntity);
    assertNotNull(pageEntity.getContent());
    validateV2(Json.mapper().readTree(pageEntity.getContent()));
}
Also used : PageEntity(io.gravitee.management.model.PageEntity) Test(org.junit.Test)

Example 2 with PageEntity

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

the class SwaggerService_TransformTest method shouldTransformAPIFromSwaggerV3_json.

@Test
public void shouldTransformAPIFromSwaggerV3_json() throws IOException {
    PageEntity pageEntity = getPage("io/gravitee/management/service/openapi.json", MediaType.APPLICATION_JSON);
    swaggerService.transform(pageEntity);
    assertNotNull(pageEntity.getContent());
    validateV3(Json.mapper().readTree(pageEntity.getContent()));
}
Also used : PageEntity(io.gravitee.management.model.PageEntity) Test(org.junit.Test)

Example 3 with PageEntity

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

the class SwaggerService_TransformTest method shouldTransformAPIFromSwaggerV2_yaml.

@Test
public void shouldTransformAPIFromSwaggerV2_yaml() throws IOException {
    PageEntity pageEntity = getPage("io/gravitee/management/service/swagger-petstore.yaml", MediaType.TEXT_PLAIN);
    swaggerService.transform(pageEntity);
    assertNotNull(pageEntity.getContent());
    validateV2(Yaml.mapper().readTree(pageEntity.getContent()));
}
Also used : PageEntity(io.gravitee.management.model.PageEntity) Test(org.junit.Test)

Example 4 with PageEntity

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

the class SwaggerService_TransformTest method shouldTransformAPIFromSwaggerV3_yaml.

@Test
public void shouldTransformAPIFromSwaggerV3_yaml() throws IOException {
    PageEntity pageEntity = getPage("io/gravitee/management/service/openapi.yaml", MediaType.TEXT_PLAIN);
    swaggerService.transform(pageEntity);
    assertNotNull(pageEntity.getContent());
    validateV3(Yaml.mapper().readTree(pageEntity.getContent()));
}
Also used : PageEntity(io.gravitee.management.model.PageEntity) Test(org.junit.Test)

Example 5 with PageEntity

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

the class ApiPagesResourceAdminTest method shouldGetPrivateApiPublishedPage.

@Test
public void shouldGetPrivateApiPublishedPage() {
    reset(apiService, pageService, membershipService);
    final ApiEntity apiMock = mock(ApiEntity.class);
    when(apiMock.getVisibility()).thenReturn(Visibility.PRIVATE);
    when(apiMock.getName()).thenReturn(API_NAME);
    doReturn(apiMock).when(apiService).findById(API_NAME);
    final PageEntity pageMock = new PageEntity();
    pageMock.setPublished(true);
    pageMock.setName(PAGE_NAME);
    doReturn(pageMock).when(pageService).findById(PAGE_NAME, false);
    final Response response = target().request().get();
    assertEquals(OK_200, response.getStatus());
    final PageEntity responsePage = response.readEntity(PageEntity.class);
    assertNotNull(responsePage);
    assertEquals(PAGE_NAME, responsePage.getName());
    verify(membershipService, never()).getRole(any(), any(), any(), any());
    verify(apiService, times(1)).findById(API_NAME);
    verify(pageService, times(1)).findById(PAGE_NAME, false);
    verify(pageService, never()).isDisplayable(apiMock, pageMock.isPublished(), USER_NAME);
}
Also used : PageEntity(io.gravitee.management.model.PageEntity) Response(javax.ws.rs.core.Response) ApiEntity(io.gravitee.management.model.ApiEntity) Test(org.junit.Test)

Aggregations

PageEntity (io.gravitee.management.model.PageEntity)13 Test (org.junit.Test)11 ApiEntity (io.gravitee.management.model.ApiEntity)5 Response (javax.ws.rs.core.Response)5 NewPageEntity (io.gravitee.management.model.NewPageEntity)2 PageConfigurationEntity (io.gravitee.management.model.PageConfigurationEntity)1 UpdatePageEntity (io.gravitee.management.model.UpdatePageEntity)1 RolePermissionAction (io.gravitee.management.model.permissions.RolePermissionAction)1 Permissions (io.gravitee.management.rest.security.Permissions)1 Page (io.gravitee.repository.management.model.Page)1 URL (java.net.URL)1 ArgumentMatcher (org.mockito.ArgumentMatcher)1 Matchers.anyString (org.mockito.Matchers.anyString)1