### Question:
FactTranslationServiceImpl implements FactTranslationService { @Cacheable(value = HABIT_FACT_OF_DAY_CACHE) @Override public LanguageTranslationDTO getFactOfTheDay(Long languageId) { return modelMapper.map( factTranslationRepo.findAllByFactOfDayStatusAndLanguageId(CURRENT, languageId).orElseThrow(() -> new NotFoundException(ErrorMessage.FACT_OF_DAY_NOT_FOUND_BY_LANGUAGE_ID + languageId)).get(0), LanguageTranslationDTO.class); } @Autowired  FactTranslationServiceImpl(FactTranslationRepo factTranslationRepo, HabitFactService habitFactService,
                                      ModelMapper modelMapper); @Override List<FactTranslation> saveHabitFactAndFactTranslation(HabitFactPostDTO habitFactPostDTO); @Override List<FactTranslation> saveFactTranslation(List<FactTranslation> factTranslations); @Cacheable(value = HABIT_FACT_OF_DAY_CACHE) @Override LanguageTranslationDTO getFactOfTheDay(Long languageId);  }### Answer:
@Test void getFactOfTheDay() { List<FactTranslation> list = Collections.singletonList(getFactTranslation()); when(factTranslationRepo.findAllByFactOfDayStatusAndLanguageId(FactOfDayStatus.CURRENT, 1L)) .thenReturn(Optional.of(list)); when(modelMapper.map(list.get(0), LanguageTranslationDTO.class)).thenReturn(getLanguageTranslationDTO()); assertEquals(getLanguageTranslationDTO(), factTranslationService.getFactOfTheDay(1L)); }
@Test void getFactOfTheDayFailed() { when(factTranslationRepo.findAllByFactOfDayStatusAndLanguageId(FactOfDayStatus.CURRENT, 1L)) .thenReturn(Optional.empty()); assertThrows(NotFoundException.class, () -> factTranslationService.getFactOfTheDay(1L)); }