### Question:
AdviceServiceImpl implements AdviceService { @Override public AdviceDTO getAdviceById(Long id) { return modelMapper.map(adviceRepo.findById(id).orElseThrow(() -> new NotFoundException(ErrorMessage.ADVICE_NOT_FOUND_BY_ID + id)), AdviceDTO.class); } @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);  }### Answer:
@Test public void getAdviceById() { when(adviceRepo.findById(anyLong())).thenReturn(Optional.of(advice)); when(modelMapper.map(advice, AdviceDTO.class)).thenReturn(adviceDTO); assertEquals(adviceDTO, adviceService.getAdviceById(anyLong())); }
@Test(expected = NotFoundException.class) public void getAdviceByIdFailed() { adviceService.getAdviceById(anyLong()); }