Search in sources :

Example 1 with CategoriesResponse

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

the class CategoriesResourceTest method shouldGetOnlyNonEmptyCategories.

@Test
public void shouldGetOnlyNonEmptyCategories() {
    final Response response = target().request().get();
    assertEquals(HttpStatusCode.OK_200, response.getStatus());
    Mockito.verify(apiService).findPublishedByUser(any());
    CategoriesResponse categoriesResponse = response.readEntity(CategoriesResponse.class);
    // only C1 is returned
    assertEquals(1, categoriesResponse.getData().size());
}
Also used : ErrorResponse(io.gravitee.rest.api.portal.rest.model.ErrorResponse) Response(javax.ws.rs.core.Response) CategoriesResponse(io.gravitee.rest.api.portal.rest.model.CategoriesResponse) CategoriesResponse(io.gravitee.rest.api.portal.rest.model.CategoriesResponse) Test(org.junit.Test)

Example 2 with CategoriesResponse

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

the class CategoriesResourceTest method shouldGetNoPublishedApiAndNoLink.

@Test
public void shouldGetNoPublishedApiAndNoLink() {
    doReturn(new ArrayList<>()).when(categoryService).findAll();
    // Test with default limit
    final Response response = target().request().get();
    assertEquals(HttpStatusCode.OK_200, response.getStatus());
    CategoriesResponse categoriesResponse = response.readEntity(CategoriesResponse.class);
    assertEquals(0, categoriesResponse.getData().size());
    Links links = categoriesResponse.getLinks();
    assertNull(links);
    // Test with small limit
    final Response anotherResponse = target().queryParam("page", 2).queryParam("size", 1).request().get();
    assertEquals(HttpStatusCode.OK_200, anotherResponse.getStatus());
    categoriesResponse = anotherResponse.readEntity(CategoriesResponse.class);
    assertEquals(0, categoriesResponse.getData().size());
    links = categoriesResponse.getLinks();
    assertNull(links);
}
Also used : ErrorResponse(io.gravitee.rest.api.portal.rest.model.ErrorResponse) Response(javax.ws.rs.core.Response) CategoriesResponse(io.gravitee.rest.api.portal.rest.model.CategoriesResponse) Links(io.gravitee.rest.api.portal.rest.model.Links) CategoriesResponse(io.gravitee.rest.api.portal.rest.model.CategoriesResponse) Test(org.junit.Test)

Example 3 with CategoriesResponse

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

the class CategoriesResourceTest method shouldGetNothingIfAllCategoriesEmpty.

@Test
public void shouldGetNothingIfAllCategoriesEmpty() {
    // 0 APIs returned for user in any categories
    doReturn(0L).when(categoryService).getTotalApisByCategory(any(), any());
    final Response response = target().request().get();
    assertEquals(HttpStatusCode.OK_200, response.getStatus());
    Mockito.verify(apiService).findPublishedByUser(any());
    CategoriesResponse categoriesResponse = response.readEntity(CategoriesResponse.class);
    assertEquals(0, categoriesResponse.getData().size());
}
Also used : ErrorResponse(io.gravitee.rest.api.portal.rest.model.ErrorResponse) Response(javax.ws.rs.core.Response) CategoriesResponse(io.gravitee.rest.api.portal.rest.model.CategoriesResponse) CategoriesResponse(io.gravitee.rest.api.portal.rest.model.CategoriesResponse) Test(org.junit.Test)

Example 4 with CategoriesResponse

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

the class CategoriesResourceTest method shouldGetNotHiddenCategories.

@Test
public void shouldGetNotHiddenCategories() {
    // every category contains one API
    doReturn(1L).when(categoryService).getTotalApisByCategory(any(), any());
    final Response response = target().request().get();
    assertEquals(HttpStatusCode.OK_200, response.getStatus());
    Mockito.verify(apiService).findPublishedByUser(any());
    CategoriesResponse categoriesResponse = response.readEntity(CategoriesResponse.class);
    assertEquals(2, categoriesResponse.getData().size());
}
Also used : ErrorResponse(io.gravitee.rest.api.portal.rest.model.ErrorResponse) Response(javax.ws.rs.core.Response) CategoriesResponse(io.gravitee.rest.api.portal.rest.model.CategoriesResponse) CategoriesResponse(io.gravitee.rest.api.portal.rest.model.CategoriesResponse) Test(org.junit.Test)

Example 5 with CategoriesResponse

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

the class CategoriesResourceNotAuthenticatedTest method shouldGetNotHiddenCategories.

@Test
public void shouldGetNotHiddenCategories() {
    final Response response = target().request().get();
    assertEquals(HttpStatusCode.OK_200, response.getStatus());
    Mockito.verify(apiService).findPublishedByUser(any());
    CategoriesResponse categoriesResponse = response.readEntity(CategoriesResponse.class);
    assertEquals(2, categoriesResponse.getData().size());
}
Also used : Response(javax.ws.rs.core.Response) CategoriesResponse(io.gravitee.rest.api.portal.rest.model.CategoriesResponse) CategoriesResponse(io.gravitee.rest.api.portal.rest.model.CategoriesResponse) Test(org.junit.Test)

Aggregations

CategoriesResponse (io.gravitee.rest.api.portal.rest.model.CategoriesResponse)5 Response (javax.ws.rs.core.Response)5 Test (org.junit.Test)5 ErrorResponse (io.gravitee.rest.api.portal.rest.model.ErrorResponse)4 Links (io.gravitee.rest.api.portal.rest.model.Links)1