ValueSetServiceImpl implements ValueSetService { @Override @Transactional(rollbackFor = ValueSetNotFoundException.class) public ValueSetDto update(ValueSetDto updated) throws ValueSetNotFoundException, ValueSetCategoryNotFoundException { logger.debug("Updating ValueSet with information" + updated); ValueSet valueSet = valueSetRepository.findOne(updated.getId()); if (valueSet == null) { logger.debug("No ValueSet found with an id: " + updated.getId()); throw new ValueSetNotFoundException(); } valueSet.update(updated.getCode(), updated.getName(), updated.getDescription(), updated.getUserName()); Long selValSetId = updated.getValueSetCategoryId(); Long origValSetId = valueSet.getValueSetCategory().getId(); if ((null != selValSetId && null != origValSetId) && selValSetId.equals(origValSetId)) { logger.debug("category association already exists"); } else { ValueSetCategory valueSetCategory = valueSetCategoryRepository .findOne(selValSetId); if (valueSetCategory == null) { logger.debug("No Valueset Category found for the selected id" + selValSetId); throw new ValueSetCategoryNotFoundException( "No Valueset Category found for the selected id" + selValSetId); } valueSet.setValueSetCategory(valueSetCategory); } return valueSetMgmtHelper.createValuesetDtoFromEntity(valueSet); } ValueSetServiceImpl(int valueSetPageSize,
			ValueSetRepository valueSetRepository,
			ValueSetCategoryRepository valueSetCategoryRepository,
			ConceptCodeValueSetRepository conceptCodeValueSetRepository,
			ValueSetMgmtHelper valueSetMgmtHelper); @Override @Transactional ValueSetDto create(ValueSetDto created); @Override @Transactional(rollbackFor = ValueSetNotFoundException.class) ValueSetDto delete(Long valueSetId); @Override ValueSetDto findById(Long id); @Override @Transactional(rollbackFor = ValueSetNotFoundException.class) ValueSetDto update(ValueSetDto updated); @Override ValueSetVSCDto create(); @Override List<ValueSetDto> findAll(); @Override List<ValueSetDto> findAllWithoutDeletable(); @Override Map<String, Object> findAll(int pageNumber); @Override Map<String, Object> findAllByName(String searchTerm,
			String valueSetCategory, int pageNumber); @Override Map<String, Object> findAllByCode(String searchTerm,
			String valueSetCategory, int pageNumber); @Override @Transactional(rollbackFor = DataIntegrityViolationException.class) ValueSetDto valueSetBatchUpload(ValueSetDto valueSetDto,
			MultipartFile file);  }
@Test(expected = ValueSetNotFoundException.class) public void testUpdateValueSet_throw_ValueSetNotFoundException() throws ValueSetNotFoundException, ValueSetCategoryNotFoundException { ValueSetDto updated = mock(ValueSetDto.class); when(valueSetRepository.findOne(anyLong())).thenReturn(null); vst.update(updated); }