### Question:
AdviceServiceImpl implements AdviceService { @Override public AdviceDTO getAdviceByName(String language, String name) { return modelMapper.map(adviceTranslationRepo .findAdviceTranslationByLanguage_CodeAndAdvice(language, name).orElseThrow(() -> new NotFoundException(ErrorMessage.ADVICE_NOT_FOUND_BY_NAME + name)), 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 getAdviceByName() { when(adviceTranslationRepo.findAdviceTranslationByLanguage_CodeAndAdvice("en", "test")) .thenReturn(Optional.of(adviceTranslation)); when(modelMapper.map(adviceTranslation, AdviceDTO.class)).thenReturn(adviceDTO); assertEquals(adviceDTO, adviceService.getAdviceByName("en", "test")); }
@Test(expected = NotFoundException.class) public void getAdviceByNameFailed() { adviceService.getAdviceByName("en", "test"); }