@Test(expected = NotUpdatedException.class) public void updateFailed() { adviceService.update(advicePostDTO, 1L); }
@Override public Advice update(AdvicePostDTO advice, Long id) { return adviceRepo.findById(id) .map(employee -> { employee.setHabitDictionary(habitDictionaryRepo.findById(advice.getHabitDictionary().getId()).get()); return adviceRepo.save(employee); }) .orElseThrow(() -> new NotUpdatedException(ErrorMessage.ADVICE_NOT_UPDATED)); }
AdviceServiceImpl implements AdviceService { @Override public Advice update(AdvicePostDTO advice, Long id) { return adviceRepo.findById(id) .map(employee -> { employee.setHabitDictionary(habitDictionaryRepo.findById(advice.getHabitDictionary().getId()).get()); return adviceRepo.save(employee); }) .orElseThrow(() -> new NotUpdatedException(ErrorMessage.ADVICE_NOT_UPDATED)); } }
AdviceServiceImpl implements AdviceService { @Override public Advice update(AdvicePostDTO advice, Long id) { return adviceRepo.findById(id) .map(employee -> { employee.setHabitDictionary(habitDictionaryRepo.findById(advice.getHabitDictionary().getId()).get()); return adviceRepo.save(employee); }) .orElseThrow(() -> new NotUpdatedException(ErrorMessage.ADVICE_NOT_UPDATED)); } @Autowired  AdviceServiceImpl(AdviceRepo adviceRepo, HabitDictionaryRepo habitDictionaryRepo,
                             AdviceTranslationRepo adviceTranslationRepo, ModelMapper modelMapper); }
AdviceServiceImpl implements AdviceService { @Override public Advice update(AdvicePostDTO advice, Long id) { return adviceRepo.findById(id) .map(employee -> { employee.setHabitDictionary(habitDictionaryRepo.findById(advice.getHabitDictionary().getId()).get()); return adviceRepo.save(employee); }) .orElseThrow(() -> new NotUpdatedException(ErrorMessage.ADVICE_NOT_UPDATED)); } @Autowired  AdviceServiceImpl(AdviceRepo adviceRepo, HabitDictionaryRepo habitDictionaryRepo,
                             AdviceTranslationRepo adviceTranslationRepo, ModelMapper modelMapper); @Override List<LanguageTranslationDTO> getAllAdvices(); @Override LanguageTranslationDTO getRandomAdviceByHabitIdAndLanguage(Long id, String language); @Override AdviceDTO getAdviceById(Long id); @Override AdviceDTO getAdviceByName(String language, String name); @Override Advice save(AdvicePostDTO advicePostDTO); @Override Advice update(AdvicePostDTO advice, Long id); @Override Long delete(Long id); }
AdviceServiceImpl implements AdviceService { @Override public Advice update(AdvicePostDTO advice, Long id) { return adviceRepo.findById(id) .map(employee -> { employee.setHabitDictionary(habitDictionaryRepo.findById(advice.getHabitDictionary().getId()).get()); return adviceRepo.save(employee); }) .orElseThrow(() -> new NotUpdatedException(ErrorMessage.ADVICE_NOT_UPDATED)); } @Autowired  AdviceServiceImpl(AdviceRepo adviceRepo, HabitDictionaryRepo habitDictionaryRepo,
                             AdviceTranslationRepo adviceTranslationRepo, ModelMapper modelMapper); @Override List<LanguageTranslationDTO> getAllAdvices(); @Override LanguageTranslationDTO getRandomAdviceByHabitIdAndLanguage(Long id, String language); @Override AdviceDTO getAdviceById(Long id); @Override AdviceDTO getAdviceByName(String language, String name); @Override Advice save(AdvicePostDTO advicePostDTO); @Override Advice update(AdvicePostDTO advice, Long id); @Override Long delete(Long id);  }