ConceptCodeServiceImpl implements ConceptCodeService { @Override @Transactional(rollbackFor = ConceptCodeNotFoundException.class) public ConceptCodeDto delete(Long conceptCodeId) throws ConceptCodeNotFoundException { logger.debug("Deleting ConceptCode with id: " + conceptCodeId); ConceptCode deleted = conceptCodeRepository.findOne(conceptCodeId); if (deleted == null) { logger.debug("No ConceptCode found with an id: " + conceptCodeId); throw new ConceptCodeNotFoundException(); } conceptCodeRepository.delete(deleted); return valueSetMgmtHelper.createConceptCodeDtoFromEntity(deleted); } ConceptCodeServiceImpl(int conceptCodePageSize,
			ConceptCodeRepository conceptCodeRepository,
			ValueSetRepository valueSetRepository,
			CodeSystemRepository codeSystemRepository,
			CodeSystemVersionRepository codeSystemVersionRepository,
			ConceptCodeValueSetRepository conceptCodeValueSetRepository,
			ValueSetMgmtHelper valueSetMgmtHelper); @Override @Transactional(rollbackFor = ConceptCodeNotFoundException.class) ConceptCodeDto delete(Long conceptCodeId); @Override ConceptCodeDto findById(Long id); @Override @Transactional(rollbackFor = ConceptCodeNotFoundException.class) ConceptCodeDto update(ConceptCodeDto updated); @Override List<ConceptCodeDto> findAll(); @Override Map<String, Object> findAll(int pageNumber); @Override Map<String, Object> findAllByCode(String searchTerm,
			String codeSystem, String codeSystemVersion, String valueSetName,
			int pageNumber); @Override Map<String, Object> findAllByName(String searchTerm,
			String codeSystem, String codeSystemVersion, String valueSetName,
			int pageNumber); @Override ConceptCodeVSCSDto create(); @Override @Transactional ConceptCodeDto create(ConceptCodeDto created); @Override @Transactional(rollbackFor = DataIntegrityViolationException.class) ConceptCodeDto conceptCodeBatchUpload(ConceptCodeDto conceptCodeDto,
			MultipartFile file, String codeSystemId, Long codeSystemVersionId,
			List<Long> valueSetIds); @Override List<ValueSet> findValueSetsByCodeSystem(String codeSystem,
			String codeSystemVersion); final int CONCEPT_CODE_PAGE_SIZE; }
@Test public void testDeleteConceptCode() throws ConceptCodeNotFoundException { ConceptCode deleted = mock(ConceptCode.class); when(conceptCodeRepository.findOne(anyLong())).thenReturn(deleted); ConceptCodeDto conceptCodeDto = mock(ConceptCodeDto.class); when(valueSetMgmtHelper.createConceptCodeDtoFromEntity(deleted)) .thenReturn(conceptCodeDto); Assert.assertEquals(conceptCodeServiceImpl.delete((long) 1), conceptCodeDto); }
@Test(expected = ConceptCodeNotFoundException.class) public void testDeleteConceptCode_throw_ConceptCodeNotFoundException() throws ConceptCodeNotFoundException { when(conceptCodeRepository.findOne(anyLong())).thenReturn(null); conceptCodeServiceImpl.delete((long) 1); }