ValueSetCategoryServiceImpl implements ValueSetCategoryService { @Override @Transactional(rollbackFor = ValueSetCategoryNotFoundException.class) public ValueSetCategoryDto update(ValueSetCategoryDto updated) throws ValueSetCategoryNotFoundException { logger.debug("Updating ValueSetCategory with information" + updated); ValueSetCategory valueSetCategory = valueSetCategoryRepository .findOne(updated.getId()); if (valueSetCategory == null) { logger.debug("No ValueSetCategory found with an id: " + updated.getId()); throw new ValueSetCategoryNotFoundException(); } valueSetCategory.update(updated.getCode(), updated.getName(), updated.getDescription(), updated.getUserName()); return valueSetMgmtHelper.createValuesetCategoryDtoFromEntity( valueSetCategory, consentRepository); } ValueSetCategoryServiceImpl(
			ValueSetCategoryRepository valueSetCategoryRepository,
			ConsentRepository consentRepository,
			ValueSetMgmtHelper valueSetMgmtHelper); @Override @Transactional ValueSetCategoryDto create(ValueSetCategoryDto created); @Override @Transactional(rollbackFor = ValueSetCategoryNotFoundException.class) ValueSetCategoryDto delete(Long valueSetCategoryId); @Override List<ValueSetCategoryDto> findAll(); @Override ValueSetCategoryDto findById(Long id); @Override @Transactional(rollbackFor = ValueSetCategoryNotFoundException.class) ValueSetCategoryDto update(ValueSetCategoryDto updated); @Override List<AddConsentFieldsDto> findAllValueSetCategoriesAddConsentFieldsDto();  }
@Test public void testUpdateValueSetCategory() throws ValueSetCategoryNotFoundException { ValueSetCategoryDto updated = mock(ValueSetCategoryDto.class); when(updated.getId()).thenReturn((long) 1); when(updated.getCode()).thenReturn("code"); when(updated.getName()).thenReturn("name"); when(updated.getUserName()).thenReturn("username"); ValueSetCategory valueSetCategory = mock(ValueSetCategory.class); when(valueSetCategoryRepository.findOne(anyLong())).thenReturn( valueSetCategory); when( consentRepositoryMock .findAllByDoNotShareSensitivityPolicyCodesValueSetCategory(valueSetCategory)) .thenReturn(null); ValueSetCategoryDto valueSetCategoryDto = mock(ValueSetCategoryDto.class); when( valueSetMgmtHelper.createValuesetCategoryDtoFromEntity( valueSetCategory, consentRepositoryMock)).thenReturn( valueSetCategoryDto); assertEquals(vst.update(updated), valueSetCategoryDto); }
@Test(expected = ValueSetCategoryNotFoundException.class) public void testUpdateValueSetCategory_throw_ValueSetCategoryNotFoundException() throws ValueSetCategoryNotFoundException { ValueSetCategoryDto updated = mock(ValueSetCategoryDto.class); when(valueSetCategoryRepository.findOne(anyLong())).thenReturn(null); vst.update(updated); }