@Test(expected = ValueSetCategoryNotFoundException.class) public void testCreateValueSet_throw_ValueSetCategoryNotFoundException() throws ValueSetCategoryNotFoundException { ValueSetDto created = mock(ValueSetDto.class); when(created.getDescription()).thenReturn("description"); when(created.getName()).thenReturn("name"); when(created.getCode()).thenReturn("code"); when(created.getValueSetCategoryId()).thenReturn((long) 1); ValueSetCategory selected = new ValueSetCategory(); selected.setCode("code"); selected.setName("name"); selected.setId((long) 1); when(valueSetCategoryRepository.findOne((long) 1)).thenReturn(null); when( valueSetMgmtHelper .createValuesetDtoFromEntity(any(ValueSet.class))) .thenReturn(created); ValueSetDto result = vst.create(created); assertNotNull(result); }
@Override @Transactional public ValueSetDto create(ValueSetDto created) throws ValueSetCategoryNotFoundException { logger.debug("Creating a new ValueSet with information: " + created); String description = (created.getDescription() != null) ? created .getDescription() : ""; ValueSet valueSet = ValueSet .getBuilder(created.getCode(), created.getName(), created.getUserName()).description(description).build(); valueSet = valueSetRepository.save(valueSet); Long valueSetCategoryId = created.getValueSetCategoryId(); ValueSetCategory selected = valueSetCategoryRepository .findOne(valueSetCategoryId); if (selected == null) { logger.debug("No ValueSet category found with an id: " + valueSetCategoryId); throw new ValueSetCategoryNotFoundException(); } valueSet.setValueSetCategory(selected); ValueSetDto valueSetDto = valueSetMgmtHelper .createValuesetDtoFromEntity(valueSet); valueSetDto.setValueSetCatName(selected.getName()); return valueSetDto; }
ValueSetServiceImpl implements ValueSetService { @Override @Transactional public ValueSetDto create(ValueSetDto created) throws ValueSetCategoryNotFoundException { logger.debug("Creating a new ValueSet with information: " + created); String description = (created.getDescription() != null) ? created .getDescription() : ""; ValueSet valueSet = ValueSet .getBuilder(created.getCode(), created.getName(), created.getUserName()).description(description).build(); valueSet = valueSetRepository.save(valueSet); Long valueSetCategoryId = created.getValueSetCategoryId(); ValueSetCategory selected = valueSetCategoryRepository .findOne(valueSetCategoryId); if (selected == null) { logger.debug("No ValueSet category found with an id: " + valueSetCategoryId); throw new ValueSetCategoryNotFoundException(); } valueSet.setValueSetCategory(selected); ValueSetDto valueSetDto = valueSetMgmtHelper .createValuesetDtoFromEntity(valueSet); valueSetDto.setValueSetCatName(selected.getName()); return valueSetDto; } }
ValueSetServiceImpl implements ValueSetService { @Override @Transactional public ValueSetDto create(ValueSetDto created) throws ValueSetCategoryNotFoundException { logger.debug("Creating a new ValueSet with information: " + created); String description = (created.getDescription() != null) ? created .getDescription() : ""; ValueSet valueSet = ValueSet .getBuilder(created.getCode(), created.getName(), created.getUserName()).description(description).build(); valueSet = valueSetRepository.save(valueSet); Long valueSetCategoryId = created.getValueSetCategoryId(); ValueSetCategory selected = valueSetCategoryRepository .findOne(valueSetCategoryId); if (selected == null) { logger.debug("No ValueSet category found with an id: " + valueSetCategoryId); throw new ValueSetCategoryNotFoundException(); } valueSet.setValueSetCategory(selected); ValueSetDto valueSetDto = valueSetMgmtHelper .createValuesetDtoFromEntity(valueSet); valueSetDto.setValueSetCatName(selected.getName()); return valueSetDto; } ValueSetServiceImpl(int valueSetPageSize,
			ValueSetRepository valueSetRepository,
			ValueSetCategoryRepository valueSetCategoryRepository,
			ConceptCodeValueSetRepository conceptCodeValueSetRepository,
			ValueSetMgmtHelper valueSetMgmtHelper); }
ValueSetServiceImpl implements ValueSetService { @Override @Transactional public ValueSetDto create(ValueSetDto created) throws ValueSetCategoryNotFoundException { logger.debug("Creating a new ValueSet with information: " + created); String description = (created.getDescription() != null) ? created .getDescription() : ""; ValueSet valueSet = ValueSet .getBuilder(created.getCode(), created.getName(), created.getUserName()).description(description).build(); valueSet = valueSetRepository.save(valueSet); Long valueSetCategoryId = created.getValueSetCategoryId(); ValueSetCategory selected = valueSetCategoryRepository .findOne(valueSetCategoryId); if (selected == null) { logger.debug("No ValueSet category found with an id: " + valueSetCategoryId); throw new ValueSetCategoryNotFoundException(); } valueSet.setValueSetCategory(selected); ValueSetDto valueSetDto = valueSetMgmtHelper .createValuesetDtoFromEntity(valueSet); valueSetDto.setValueSetCatName(selected.getName()); return valueSetDto; } 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); }
ValueSetServiceImpl implements ValueSetService { @Override @Transactional public ValueSetDto create(ValueSetDto created) throws ValueSetCategoryNotFoundException { logger.debug("Creating a new ValueSet with information: " + created); String description = (created.getDescription() != null) ? created .getDescription() : ""; ValueSet valueSet = ValueSet .getBuilder(created.getCode(), created.getName(), created.getUserName()).description(description).build(); valueSet = valueSetRepository.save(valueSet); Long valueSetCategoryId = created.getValueSetCategoryId(); ValueSetCategory selected = valueSetCategoryRepository .findOne(valueSetCategoryId); if (selected == null) { logger.debug("No ValueSet category found with an id: " + valueSetCategoryId); throw new ValueSetCategoryNotFoundException(); } valueSet.setValueSetCategory(selected); ValueSetDto valueSetDto = valueSetMgmtHelper .createValuesetDtoFromEntity(valueSet); valueSetDto.setValueSetCatName(selected.getName()); return valueSetDto; } 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);  }