ValueSetCategoryServiceImpl implements ValueSetCategoryService { @Override @Transactional(rollbackFor = ValueSetCategoryNotFoundException.class) public ValueSetCategoryDto delete(Long valueSetCategoryId) throws ValueSetCategoryNotFoundException { logger.debug("Deleting ValueSetCategory with id: " + valueSetCategoryId); ValueSetCategory deleted = valueSetCategoryRepository .findOne(valueSetCategoryId); if (deleted == null) { logger.debug("No ValueSetCategory found with an id: " + valueSetCategoryId); throw new ValueSetCategoryNotFoundException(); } valueSetCategoryRepository.delete(deleted); return valueSetMgmtHelper.createValuesetCategoryDtoFromEntity(deleted, 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 testDeleteValueSetCategory() throws ValueSetCategoryNotFoundException { ValueSetCategory deleted = mock(ValueSetCategory.class); when(valueSetCategoryRepository.findOne(anyLong())).thenReturn(deleted); when( consentRepositoryMock .findAllByDoNotShareSensitivityPolicyCodesValueSetCategory(deleted)) .thenReturn(null); ValueSetCategoryDto valueSetCategoryDto = mock(ValueSetCategoryDto.class); when( valueSetMgmtHelper.createValuesetCategoryDtoFromEntity(deleted, consentRepositoryMock)).thenReturn(valueSetCategoryDto); Assert.assertEquals(vst.delete((long) 1), valueSetCategoryDto); }
@Test(expected = ValueSetCategoryNotFoundException.class) public void testDeleteVelueSetCategory_throw_ValueSetCategoryNotFoundException() throws ValueSetCategoryNotFoundException { when(valueSetCategoryRepository.findOne(anyLong())).thenReturn(null); vst.delete((long) 1); }