@Test void getFactOfTheDayFailed() { when(factTranslationRepo.findAllByFactOfDayStatusAndLanguageId(FactOfDayStatus.CURRENT, 1L)) .thenReturn(Optional.empty()); assertThrows(NotFoundException.class, () -> factTranslationService.getFactOfTheDay(1L)); }
@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); }
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); } }
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); }
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); }
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);  }