CodeSystemVersionServiceImpl implements CodeSystemVersionService { @Override @Transactional public CodeSystemVersionDto create(CodeSystemVersionDto created) throws CodeSystemNotFoundException { logger.debug("Creating a new CodeSystemVersion with information: " + created); String description = (created.getDescription() != null) ? created .getDescription() : ""; CodeSystemVersion codeSystemVersion = CodeSystemVersion .getBuilder(created.getCode(), created.getName(), created.getUserName()).description(description).build(); codeSystemVersion = codeSystemVersionRepository.save(codeSystemVersion); Long codeSystemId = created.getCodeSystemId(); CodeSystem selected = codeSystemRepository.findOne(codeSystemId); if (selected == null) { logger.debug("No CodeSystem found with an id: " + codeSystemId); throw new CodeSystemNotFoundException(); } codeSystemVersion.setCodeSystem(selected); CodeSystemVersionDto codeSystemVersionDto = codeSystemVersionMgmtHelper .createCodeSystemVersionDtoFromEntity(codeSystemVersion); codeSystemVersionDto.setCodeSystemName(selected.getName()); return codeSystemVersionDto; } CodeSystemVersionServiceImpl(
			CodeSystemVersionRepository codeSystemVersionRepository,
			CodeSystemRepository codeSystemRepository,
			ValueSetMgmtHelper codeSystemVersionMgmtHelper); @Override @Transactional CodeSystemVersionDto create(CodeSystemVersionDto created); @Override @Transactional(rollbackFor = CodeSystemVersionNotFoundException.class) CodeSystemVersionDto delete(Long codeSystemVersionId); @Override List<CodeSystemVersionDto> findAll(); @Override CodeSystemVersionDto findById(Long id); @Override @Transactional(rollbackFor = CodeSystemVersionNotFoundException.class) CodeSystemVersionDto update(CodeSystemVersionDto updated); @Override CodeSystemVersionCSDto create(); @Override List<CodeSystemVersionDto> groupByCodeSystem(
			List<CodeSystemVersionDto> codeSystemVersionDtos);  }
@Test(expected = CodeSystemNotFoundException.class) public void testCreateCodeSystemVersion_throw_CodeSystemNotFoundException() throws CodeSystemNotFoundException { CodeSystemVersionDto createdMock = mock(CodeSystemVersionDto.class); when(createdMock.getDescription()).thenReturn("description"); when(createdMock.getName()).thenReturn("name"); when(createdMock.getCode()).thenReturn("code"); when(createdMock.getUserName()).thenReturn("username"); ValueSetCategory selected = new ValueSetCategory(); selected.setCode("code"); selected.setName("name"); selected.setId((long) 1); when(codeSystemRepository.findOne((long) 1)).thenReturn(null); vst.create(createdMock); }