@Test public void testUpdateCodeSystemVersion() throws CodeSystemVersionNotFoundException, CodeSystemNotFoundException { CodeSystemVersionDto updatedMock = mock(CodeSystemVersionDto.class); when(updatedMock.getId()).thenReturn((long) 1); when(updatedMock.getCode()).thenReturn("code"); when(updatedMock.getName()).thenReturn("name"); when(updatedMock.getUserName()).thenReturn("username"); CodeSystemVersionDto codeSystemVersionDtoMock = mock(CodeSystemVersionDto.class); CodeSystemVersion codeSystemVersionMock = mock(CodeSystemVersion.class); CodeSystem codeSystemMock = mock(CodeSystem.class); when(codeSystemVersionRepository.findOne(anyLong())).thenReturn( codeSystemVersionMock); when(codeSystemVersionMock.getCodeSystem()).thenReturn(codeSystemMock); when(codeSystemMock.getId()).thenReturn((long) 1); when(codeSystemRepository.findOne(anyLong())) .thenReturn(codeSystemMock); when( valueSetMgmtHelper .createCodeSystemVersionDtoFromEntity(codeSystemVersionMock)) .thenReturn(codeSystemVersionDtoMock); assertEquals(vst.update(updatedMock), codeSystemVersionDtoMock); }
@Override @Transactional(rollbackFor = CodeSystemVersionNotFoundException.class) public CodeSystemVersionDto update(CodeSystemVersionDto updated) throws CodeSystemVersionNotFoundException, CodeSystemNotFoundException { logger.debug("Updating CodeSystemVersion with information" + updated); CodeSystemVersion codeSystemVersion = codeSystemVersionRepository .findOne(updated.getId()); if (codeSystemVersion == null) { logger.debug("No CodeSystemVersion found with an id: " + updated.getId()); throw new CodeSystemVersionNotFoundException(); } codeSystemVersion.update(updated.getCode(), updated.getName(), updated.getDescription(), updated.getUserName()); Long selCodeSystemId = updated.getCodeSystemId(); Long origCodeSystemId = codeSystemVersion.getCodeSystem().getId(); if ((null != selCodeSystemId && null != origCodeSystemId) && selCodeSystemId.equals(origCodeSystemId)) { logger.debug("category association already exists"); } else { CodeSystem codeSystem = codeSystemRepository .findOne(selCodeSystemId); if (codeSystem == null) { logger.debug("No Code System found for the selected id" + selCodeSystemId); throw new CodeSystemNotFoundException( "No Code System found for the selected id" + selCodeSystemId); } codeSystemVersion.setCodeSystem(codeSystem); } return codeSystemVersionMgmtHelper .createCodeSystemVersionDtoFromEntity(codeSystemVersion); }
CodeSystemVersionServiceImpl implements CodeSystemVersionService { @Override @Transactional(rollbackFor = CodeSystemVersionNotFoundException.class) public CodeSystemVersionDto update(CodeSystemVersionDto updated) throws CodeSystemVersionNotFoundException, CodeSystemNotFoundException { logger.debug("Updating CodeSystemVersion with information" + updated); CodeSystemVersion codeSystemVersion = codeSystemVersionRepository .findOne(updated.getId()); if (codeSystemVersion == null) { logger.debug("No CodeSystemVersion found with an id: " + updated.getId()); throw new CodeSystemVersionNotFoundException(); } codeSystemVersion.update(updated.getCode(), updated.getName(), updated.getDescription(), updated.getUserName()); Long selCodeSystemId = updated.getCodeSystemId(); Long origCodeSystemId = codeSystemVersion.getCodeSystem().getId(); if ((null != selCodeSystemId && null != origCodeSystemId) && selCodeSystemId.equals(origCodeSystemId)) { logger.debug("category association already exists"); } else { CodeSystem codeSystem = codeSystemRepository .findOne(selCodeSystemId); if (codeSystem == null) { logger.debug("No Code System found for the selected id" + selCodeSystemId); throw new CodeSystemNotFoundException( "No Code System found for the selected id" + selCodeSystemId); } codeSystemVersion.setCodeSystem(codeSystem); } return codeSystemVersionMgmtHelper .createCodeSystemVersionDtoFromEntity(codeSystemVersion); } }
CodeSystemVersionServiceImpl implements CodeSystemVersionService { @Override @Transactional(rollbackFor = CodeSystemVersionNotFoundException.class) public CodeSystemVersionDto update(CodeSystemVersionDto updated) throws CodeSystemVersionNotFoundException, CodeSystemNotFoundException { logger.debug("Updating CodeSystemVersion with information" + updated); CodeSystemVersion codeSystemVersion = codeSystemVersionRepository .findOne(updated.getId()); if (codeSystemVersion == null) { logger.debug("No CodeSystemVersion found with an id: " + updated.getId()); throw new CodeSystemVersionNotFoundException(); } codeSystemVersion.update(updated.getCode(), updated.getName(), updated.getDescription(), updated.getUserName()); Long selCodeSystemId = updated.getCodeSystemId(); Long origCodeSystemId = codeSystemVersion.getCodeSystem().getId(); if ((null != selCodeSystemId && null != origCodeSystemId) && selCodeSystemId.equals(origCodeSystemId)) { logger.debug("category association already exists"); } else { CodeSystem codeSystem = codeSystemRepository .findOne(selCodeSystemId); if (codeSystem == null) { logger.debug("No Code System found for the selected id" + selCodeSystemId); throw new CodeSystemNotFoundException( "No Code System found for the selected id" + selCodeSystemId); } codeSystemVersion.setCodeSystem(codeSystem); } return codeSystemVersionMgmtHelper .createCodeSystemVersionDtoFromEntity(codeSystemVersion); } CodeSystemVersionServiceImpl(
			CodeSystemVersionRepository codeSystemVersionRepository,
			CodeSystemRepository codeSystemRepository,
			ValueSetMgmtHelper codeSystemVersionMgmtHelper); }
CodeSystemVersionServiceImpl implements CodeSystemVersionService { @Override @Transactional(rollbackFor = CodeSystemVersionNotFoundException.class) public CodeSystemVersionDto update(CodeSystemVersionDto updated) throws CodeSystemVersionNotFoundException, CodeSystemNotFoundException { logger.debug("Updating CodeSystemVersion with information" + updated); CodeSystemVersion codeSystemVersion = codeSystemVersionRepository .findOne(updated.getId()); if (codeSystemVersion == null) { logger.debug("No CodeSystemVersion found with an id: " + updated.getId()); throw new CodeSystemVersionNotFoundException(); } codeSystemVersion.update(updated.getCode(), updated.getName(), updated.getDescription(), updated.getUserName()); Long selCodeSystemId = updated.getCodeSystemId(); Long origCodeSystemId = codeSystemVersion.getCodeSystem().getId(); if ((null != selCodeSystemId && null != origCodeSystemId) && selCodeSystemId.equals(origCodeSystemId)) { logger.debug("category association already exists"); } else { CodeSystem codeSystem = codeSystemRepository .findOne(selCodeSystemId); if (codeSystem == null) { logger.debug("No Code System found for the selected id" + selCodeSystemId); throw new CodeSystemNotFoundException( "No Code System found for the selected id" + selCodeSystemId); } codeSystemVersion.setCodeSystem(codeSystem); } return codeSystemVersionMgmtHelper .createCodeSystemVersionDtoFromEntity(codeSystemVersion); } 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); }
CodeSystemVersionServiceImpl implements CodeSystemVersionService { @Override @Transactional(rollbackFor = CodeSystemVersionNotFoundException.class) public CodeSystemVersionDto update(CodeSystemVersionDto updated) throws CodeSystemVersionNotFoundException, CodeSystemNotFoundException { logger.debug("Updating CodeSystemVersion with information" + updated); CodeSystemVersion codeSystemVersion = codeSystemVersionRepository .findOne(updated.getId()); if (codeSystemVersion == null) { logger.debug("No CodeSystemVersion found with an id: " + updated.getId()); throw new CodeSystemVersionNotFoundException(); } codeSystemVersion.update(updated.getCode(), updated.getName(), updated.getDescription(), updated.getUserName()); Long selCodeSystemId = updated.getCodeSystemId(); Long origCodeSystemId = codeSystemVersion.getCodeSystem().getId(); if ((null != selCodeSystemId && null != origCodeSystemId) && selCodeSystemId.equals(origCodeSystemId)) { logger.debug("category association already exists"); } else { CodeSystem codeSystem = codeSystemRepository .findOne(selCodeSystemId); if (codeSystem == null) { logger.debug("No Code System found for the selected id" + selCodeSystemId); throw new CodeSystemNotFoundException( "No Code System found for the selected id" + selCodeSystemId); } codeSystemVersion.setCodeSystem(codeSystem); } return codeSystemVersionMgmtHelper .createCodeSystemVersionDtoFromEntity(codeSystemVersion); } 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);  }