### Question:
GoalServiceImpl implements GoalService { @Override public UserGoalResponseDto getUserGoalResponseDtoFromCustomGoal(UserGoal userGoal) { UserGoalResponseDto userGoalResponseDto = modelMapper.map(userGoal, UserGoalResponseDto.class); if (userGoal.getGoal() == null) { CustomGoal customGoal = customGoalRepo.findById(userGoal .getCustomGoal().getId()).orElseThrow(() -> new NotFoundException(CUSTOM_GOAL_NOT_FOUND_BY_ID)); userGoalResponseDto.setText(customGoal.getText()); } return userGoalResponseDto; }  @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);  }### Answer:
@Test void getUserGoalResponseDtoFromCustomGoal() { CustomGoal customGoal = customUserGoal.getCustomGoal(); when(modelMapper.map(customUserGoal, UserGoalResponseDto.class)).thenReturn(customUserGoalDto); when(customGoalRepo.findById(8L)).thenReturn(Optional.ofNullable(customGoal)); UserGoalResponseDto actual = goalService.getUserGoalResponseDtoFromCustomGoal(customUserGoal); assertEquals(customUserGoalDto, actual); }
@Test void getUserGoalResponseDtoFromCustomGoalFailed() { when(modelMapper.map(customUserGoal, UserGoalResponseDto.class)).thenReturn(customUserGoalDto); when(customGoalRepo.findById(anyLong())).thenReturn(Optional.empty()); assertThrows(NotFoundException.class, () -> goalService.getUserGoalResponseDtoFromCustomGoal(customUserGoal)); }