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());
}
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);
}
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());
}
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());
}
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());
}
Aggregations