ValueSetCategoryServiceImpl implements ValueSetCategoryService { @Override @Transactional public ValueSetCategoryDto create(ValueSetCategoryDto created) { logger.debug("Creating a new ValueSetCategory with information: " + created); String description = (created.getDescription() != null) ? created .getDescription() : ""; ValueSetCategory valueSetCategory = ValueSetCategory .getBuilder(created.getCode(), created.getName(), created.getUserName()).description(description).build(); valueSetCategory = valueSetCategoryRepository.save(valueSetCategory); return valueSetMgmtHelper.createValuesetCategoryDtoFromEntity( valueSetCategory, consentRepository); } ValueSetCategoryServiceImpl(
			ValueSetCategoryRepository valueSetCategoryRepository,
			ConsentRepository consentRepository,
			ValueSetMgmtHelper valueSetMgmtHelper); @Override @Transactional ValueSetCategoryDto create(ValueSetCategoryDto created); @Override @Transactional(rollbackFor = ValueSetCategoryNotFoundException.class) ValueSetCategoryDto delete(Long valueSetCategoryId); @Override List<ValueSetCategoryDto> findAll(); @Override ValueSetCategoryDto findById(Long id); @Override @Transactional(rollbackFor = ValueSetCategoryNotFoundException.class) ValueSetCategoryDto update(ValueSetCategoryDto updated); @Override List<AddConsentFieldsDto> findAllValueSetCategoriesAddConsentFieldsDto();  }
@Test public void testCreateValueSetValueSetCategory() { ValueSetCategoryDto created = mock(ValueSetCategoryDto.class); when(created.getDescription()).thenReturn("description"); when(created.getName()).thenReturn("name"); when(created.getCode()).thenReturn("code"); when(created.getUserName()).thenReturn("username"); ValueSetCategory valueSetCategory = mock(ValueSetCategory.class); when(valueSetCategoryRepository.save(valueSetCategory)).thenReturn( valueSetCategory); when( valueSetMgmtHelper.createValuesetCategoryDtoFromEntity( any(ValueSetCategory.class), any(ConsentRepository.class))).thenReturn(created); ValueSetCategoryDto result = vst.create(created); Assert.assertEquals(result, created); }