use of io.gravitee.rest.api.model.CategoryEntity in project gravitee-management-rest-api by gravitee-io.
the class CategoryResourceTest method init.
@Before
public void init() {
mockCategory = new CategoryEntity();
mockCategory.setId(CATEGORY);
mockCategory.setName(CATEGORY);
mockCategory.setUpdatedAt(new Date());
doReturn(mockCategory).when(categoryService).findById(CATEGORY);
updateCategoryEntity = new UpdateCategoryEntity();
updateCategoryEntity.setDescription("toto");
updateCategoryEntity.setName(CATEGORY);
doReturn(mockCategory).when(categoryService).update(eq(CATEGORY), any());
}
use of io.gravitee.rest.api.model.CategoryEntity in project gravitee-management-rest-api by gravitee-io.
the class CategoriesResourceNotAuthenticatedTest method init.
@Before
public void init() {
resetAllMocks();
Set<ApiEntity> mockApis = new HashSet<>();
doReturn(mockApis).when(apiService).findPublishedByUser(any());
CategoryEntity category1 = new CategoryEntity();
category1.setId("1");
category1.setHidden(false);
category1.setOrder(2);
CategoryEntity category2 = new CategoryEntity();
category2.setId("2");
category2.setHidden(false);
category2.setOrder(3);
CategoryEntity category3 = new CategoryEntity();
category3.setId("3");
category3.setHidden(true);
category3.setOrder(1);
List<CategoryEntity> mockCategories = Arrays.asList(category1, category2, category3);
doReturn(mockCategories).when(categoryService).findAll();
doReturn(1L).when(categoryService).getTotalApisByCategory(any(), any());
doReturn(false).when(ratingService).isEnabled();
Mockito.when(categoryMapper.convert(any(), any())).thenCallRealMethod();
}
use of io.gravitee.rest.api.model.CategoryEntity in project gravitee-management-rest-api by gravitee-io.
the class CategoryResourceNotAuthenticatedTest method init.
@Before
public void init() throws IOException, URISyntaxException {
resetAllMocks();
CategoryEntity categoryEntity = new CategoryEntity();
categoryEntity.setId(CATEGORY_ID);
categoryEntity.setHidden(false);
doReturn(categoryEntity).when(categoryService).findNotHiddenById(CATEGORY_ID);
Set<ApiEntity> mockApis = new HashSet<>();
doReturn(mockApis).when(apiService).findPublishedByUser(any());
Mockito.when(categoryMapper.convert(any(), any())).thenCallRealMethod();
}
use of io.gravitee.rest.api.model.CategoryEntity in project gravitee-management-rest-api by gravitee-io.
the class ApisResourceTest method shouldHavePromotedApiIfCategoryWithoutHighLightedApi.
@Test
public void shouldHavePromotedApiIfCategoryWithoutHighLightedApi() throws TechnicalException {
doReturn(new CategoryEntity()).when(categoryService).findById("myCat");
final Response response = target().queryParam("size", 3).queryParam("promoted", true).queryParam("category", "myCat").request().get();
assertEquals(HttpStatusCode.OK_200, response.getStatus());
ArgumentCaptor<ApiEntity> apiEntityCaptor = ArgumentCaptor.forClass(ApiEntity.class);
Mockito.verify(apiMapper, Mockito.times(1)).convert(apiEntityCaptor.capture());
final List<String> allNameValues = apiEntityCaptor.getAllValues().stream().map(a -> a.getName()).collect(Collectors.toList());
assertEquals(1, allNameValues.size());
assertTrue(allNameValues.containsAll(Arrays.asList("1")));
ApisResponse apiResponse = response.readEntity(ApisResponse.class);
assertEquals(1, apiResponse.getData().size());
}
use of io.gravitee.rest.api.model.CategoryEntity in project gravitee-management-rest-api by gravitee-io.
the class ApisResourceTest method shouldHaveAllButPromotedApiIfCategoryWithHighLightedApi.
@Test
public void shouldHaveAllButPromotedApiIfCategoryWithHighLightedApi() throws TechnicalException {
CategoryEntity myCatEntity = new CategoryEntity();
myCatEntity.setHighlightApi("4");
doReturn(myCatEntity).when(categoryService).findById("myCat");
final Response response = target().queryParam("size", 3).queryParam("promoted", false).queryParam("category", "myCat").request().get();
assertEquals(HttpStatusCode.OK_200, response.getStatus());
ArgumentCaptor<ApiEntity> apiEntityCaptor = ArgumentCaptor.forClass(ApiEntity.class);
Mockito.verify(apiMapper, Mockito.times(4)).convert(apiEntityCaptor.capture());
final List<String> allNameValues = apiEntityCaptor.getAllValues().stream().map(a -> a.getName()).collect(Collectors.toList());
assertEquals(4, allNameValues.size());
assertTrue(allNameValues.containsAll(Arrays.asList("1", "3", "5", "6")));
ApisResponse apiResponse = response.readEntity(ApisResponse.class);
assertEquals(3, apiResponse.getData().size());
}
Aggregations