CodeSystemServiceImpl implements CodeSystemService { @Override @Transactional(rollbackFor = CodeSystemNotFoundException.class) public CodeSystemDto delete(Long codeSystemId) throws CodeSystemNotFoundException { LOGGER.debug("Deleting CodeSystem with id: " + codeSystemId); CodeSystem deleted = codeSystemRepository.findOne(codeSystemId); if (deleted == null) { LOGGER.debug("No CodeSystem found with an id: " + codeSystemId); throw new CodeSystemNotFoundException(); } codeSystemRepository.delete(deleted); return valueSetMgmtHelper.createCodeSystemDtoFromEntity(deleted); } CodeSystemServiceImpl(CodeSystemRepository codeSystemRepository,
			ValueSetMgmtHelper valueSetMgmtHelper); @Override @Transactional CodeSystemDto create(CodeSystemDto created); @Override @Transactional(rollbackFor = CodeSystemNotFoundException.class) CodeSystemDto delete(Long codeSystemId); @Override List<CodeSystemDto> findAll(); @Override CodeSystemDto findById(Long id); @Override @Transactional(rollbackFor = CodeSystemNotFoundException.class) CodeSystemDto update(CodeSystemDto updated);  }
@Test public void testDeleteCodeSystem() throws CodeSystemNotFoundException { CodeSystem deleted = mock(CodeSystem.class); when(codeSystemRepository.findOne(anyLong())).thenReturn(deleted); CodeSystemDto codeSystemDto = mock(CodeSystemDto.class); when(valueSetMgmtHelper.createCodeSystemDtoFromEntity(deleted)) .thenReturn(codeSystemDto); Assert.assertEquals(vst.delete((long) 1), codeSystemDto); }
@Test(expected = CodeSystemNotFoundException.class) public void testDeleteCodeSystem_throw_CodeSystemNotFoundException() throws CodeSystemNotFoundException { when(codeSystemRepository.findOne(anyLong())).thenReturn(null); vst.delete((long) 1); }