@Test void getHabitDictionaryTranslation() { Habit habit = ModelUtils.getHabit(); HabitDictionaryTranslation habitDictionaryTranslation = ModelUtils.getHabitDictionaryTranslation(); when(habitDictionaryTranslationRepo.findByHabitDictionaryAndLanguageCode(any(HabitDictionary.class), anyString())) .thenReturn(Optional.of(habitDictionaryTranslation)); assertEquals(habitDictionaryTranslation, habitService.getHabitDictionaryTranslation(habit, "en")); }
@Override public HabitDictionaryTranslation getHabitDictionaryTranslation(Habit habit, String languageCode) { return habitDictionaryTranslationRepo .findByHabitDictionaryAndLanguageCode(habit.getHabitDictionary(), languageCode) .orElseThrow(() -> new NotFoundException(ErrorMessage.HABIT_DICTIONARY_TRANSLATION_NOT_FOUND)); }
HabitServiceImpl implements HabitService { @Override public HabitDictionaryTranslation getHabitDictionaryTranslation(Habit habit, String languageCode) { return habitDictionaryTranslationRepo .findByHabitDictionaryAndLanguageCode(habit.getHabitDictionary(), languageCode) .orElseThrow(() -> new NotFoundException(ErrorMessage.HABIT_DICTIONARY_TRANSLATION_NOT_FOUND)); } }
HabitServiceImpl implements HabitService { @Override public HabitDictionaryTranslation getHabitDictionaryTranslation(Habit habit, String languageCode) { return habitDictionaryTranslationRepo .findByHabitDictionaryAndLanguageCode(habit.getHabitDictionary(), languageCode) .orElseThrow(() -> new NotFoundException(ErrorMessage.HABIT_DICTIONARY_TRANSLATION_NOT_FOUND)); }  }
HabitServiceImpl implements HabitService { @Override public HabitDictionaryTranslation getHabitDictionaryTranslation(Habit habit, String languageCode) { return habitDictionaryTranslationRepo .findByHabitDictionaryAndLanguageCode(habit.getHabitDictionary(), languageCode) .orElseThrow(() -> new NotFoundException(ErrorMessage.HABIT_DICTIONARY_TRANSLATION_NOT_FOUND)); }  @Override HabitDictionaryTranslation getHabitDictionaryTranslation(Habit habit, String languageCode); @Override Habit getById(Long id); @Transactional @Override HabitCreateDto assignHabitForUser(Long habitId, User user); @Override List<HabitDto> getAllHabitsDto(); }
HabitServiceImpl implements HabitService { @Override public HabitDictionaryTranslation getHabitDictionaryTranslation(Habit habit, String languageCode) { return habitDictionaryTranslationRepo .findByHabitDictionaryAndLanguageCode(habit.getHabitDictionary(), languageCode) .orElseThrow(() -> new NotFoundException(ErrorMessage.HABIT_DICTIONARY_TRANSLATION_NOT_FOUND)); }  @Override HabitDictionaryTranslation getHabitDictionaryTranslation(Habit habit, String languageCode); @Override Habit getById(Long id); @Transactional @Override HabitCreateDto assignHabitForUser(Long habitId, User user); @Override List<HabitDto> getAllHabitsDto();  }