@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")); }
@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); }
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); } }
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); }
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); }
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);  }