@Test void findAllTest() { List<GoalTranslation> goalTranslations = ModelUtils.getGoalTranslations(); List<GoalDto> goalsDto = goalTranslations .stream() .map(goalTranslation -> new GoalDto(goalTranslation.getGoal().getId(), goalTranslation.getText())) .collect(Collectors.toList()); when(modelMapper.map(goalTranslations.get(0), GoalDto.class)).thenReturn(goalsDto.get(0)); when(modelMapper.map(goalTranslations.get(1), GoalDto.class)).thenReturn(goalsDto.get(1)); when(goalTranslationRepo.findAllByLanguageCode(AppConstant.DEFAULT_LANGUAGE_CODE)) .thenReturn(goalTranslations); assertEquals(goalService.findAll(AppConstant.DEFAULT_LANGUAGE_CODE), goalsDto); }
@Override public List<GoalDto> findAll(String language) { return goalTranslationRepo .findAllByLanguageCode(language) .stream() .map(g -> modelMapper.map(g, GoalDto.class)) .collect(Collectors.toList()); }
GoalServiceImpl implements GoalService { @Override public List<GoalDto> findAll(String language) { return goalTranslationRepo .findAllByLanguageCode(language) .stream() .map(g -> modelMapper.map(g, GoalDto.class)) .collect(Collectors.toList()); } }
GoalServiceImpl implements GoalService { @Override public List<GoalDto> findAll(String language) { return goalTranslationRepo .findAllByLanguageCode(language) .stream() .map(g -> modelMapper.map(g, GoalDto.class)) .collect(Collectors.toList()); }  }
GoalServiceImpl implements GoalService { @Override public List<GoalDto> findAll(String language) { return goalTranslationRepo .findAllByLanguageCode(language) .stream() .map(g -> modelMapper.map(g, GoalDto.class)) .collect(Collectors.toList()); }  @Override List<GoalDto> findAll(String language); @Override UserGoalResponseDto getUserGoalResponseDtoFromPredefinedGoal(UserGoal userGoal); @Override UserGoalResponseDto getUserGoalResponseDtoFromCustomGoal(UserGoal userGoal); @Override List<ShoppingListDtoResponse> getShoppingList(Long userId, String languageCode); @Override @Transactional void changeGoalOrCustomGoalStatus(Long userId, boolean status, Long goalId, Long customGoalId); }
GoalServiceImpl implements GoalService { @Override public List<GoalDto> findAll(String language) { return goalTranslationRepo .findAllByLanguageCode(language) .stream() .map(g -> modelMapper.map(g, GoalDto.class)) .collect(Collectors.toList()); }  @Override List<GoalDto> findAll(String language); @Override UserGoalResponseDto getUserGoalResponseDtoFromPredefinedGoal(UserGoal userGoal); @Override UserGoalResponseDto getUserGoalResponseDtoFromCustomGoal(UserGoal userGoal); @Override List<ShoppingListDtoResponse> getShoppingList(Long userId, String languageCode); @Override @Transactional void changeGoalOrCustomGoalStatus(Long userId, boolean status, Long goalId, Long customGoalId);  }