use of io.gravitee.rest.api.model.CategoryEntity in project gravitee-management-rest-api by gravitee-io.
the class CategoriesResourceTest 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);
doReturn(1L).when(categoryService).getTotalApisByCategory(mockApis, category1);
CategoryEntity category2 = new CategoryEntity();
category2.setId("2");
category2.setHidden(false);
category2.setOrder(3);
doReturn(0L).when(categoryService).getTotalApisByCategory(mockApis, category2);
CategoryEntity category3 = new CategoryEntity();
category3.setId("3");
category3.setHidden(true);
category3.setOrder(1);
doReturn(2L).when(categoryService).getTotalApisByCategory(mockApis, category3);
existingCategories = Arrays.asList(category1, category2, category3);
doReturn(existingCategories).when(categoryService).findAll();
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 CategoryResourceTest 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();
mockImage = new InlinePictureEntity();
apiLogoContent = Files.readAllBytes(Paths.get(this.getClass().getClassLoader().getResource("media/logo.svg").toURI()));
mockImage.setContent(apiLogoContent);
mockImage.setType("image/svg");
doReturn(mockImage).when(categoryService).getPicture(CATEGORY_ID);
}
use of io.gravitee.rest.api.model.CategoryEntity in project gravitee-management-rest-api by gravitee-io.
the class CategoryServiceImpl method convert.
private CategoryEntity convert(final Category category) {
final CategoryEntity categoryEntity = new CategoryEntity();
categoryEntity.setId(category.getId());
categoryEntity.setKey(category.getKey());
categoryEntity.setName(category.getName());
categoryEntity.setDescription(category.getDescription());
categoryEntity.setOrder(category.getOrder());
categoryEntity.setHidden(category.isHidden());
categoryEntity.setHighlightApi(category.getHighlightApi());
categoryEntity.setPicture(category.getPicture());
categoryEntity.setBackground(category.getBackground());
categoryEntity.setPage(category.getPage());
categoryEntity.setUpdatedAt(category.getUpdatedAt());
categoryEntity.setCreatedAt(category.getCreatedAt());
return categoryEntity;
}
use of io.gravitee.rest.api.model.CategoryEntity in project gravitee-management-rest-api by gravitee-io.
the class CategoryService_GetTotalApisByCategoryTest method testEnhanceForOneCategory.
@Test
public void testEnhanceForOneCategory() {
CategoryEntity v = new CategoryEntity();
v.setKey("1");
long totalApisByCategory = categoryService.getTotalApisByCategory(apis, v);
assertEquals(2, totalApisByCategory);
}
use of io.gravitee.rest.api.model.CategoryEntity in project gravitee-management-rest-api by gravitee-io.
the class CategoryService_CreateTest method shouldCreateCategory.
@Test
public void shouldCreateCategory() throws TechnicalException {
NewCategoryEntity v1 = new NewCategoryEntity();
v1.setName("v1");
when(mockCategoryRepository.create(argThat(cat -> cat.getCreatedAt() != null))).thenReturn(new Category());
when(mockEnvironmentService.findById("DEFAULT")).thenReturn(new EnvironmentEntity());
CategoryEntity category = categoryService.create(v1);
assertNotNull("result is null", category);
verify(mockAuditService, times(1)).createEnvironmentAuditLog(any(), eq(CATEGORY_CREATED), any(), isNull(), any());
verify(mockCategoryRepository, times(1)).create(argThat(arg -> arg != null && arg.getName().equals("v1")));
}
Aggregations