@Path("/{username}/create")
  @PUT
  public javax.ws.rs.core.Response addQuestionForUser(@PathParam("username") String userName) {
    List<Game> gamesAllReadyPlayed = gameUserDataManager.getGames(userName);
    List<Question> allQuestions = questionManager.loadQuestions().getQuestions();

    if (gamesAllReadyPlayed.size() == allQuestions.size()) {
      // NOTHING TO DO : the player allready answered all questions
      return javax.ws.rs.core.Response.ok().build();
    }

    Question randomQuestion = getRandomQuestion(gamesAllReadyPlayed, allQuestions);

    Game game = new Game();
    game.setId(randomQuestion.getId());
    game.setType(ResponseType.NEED_RESPONSE);

    try {
      gameUserDataManager.addOrUpdateGame(userName, game);
    } catch (StorageException e) {
      LOGGER.error("unable to store result in mongoDb: {}", e.getMessage());
    }

    questionsNotifier.notifyListener(userName, randomQuestion);

    return javax.ws.rs.core.Response.ok().build();
  }
  private Question getRandomQuestion(List<Game> gamesAllReadyPlayed, List<Question> allQuestions) {
    Question tmpQuestion = null;
    for (Game game : gamesAllReadyPlayed) {
      tmpQuestion = new Question();
      tmpQuestion.setId(game.getId());
      allQuestions.remove(tmpQuestion);
    }

    return allQuestions.get(getRandomIndex(allQuestions.size()));
  }
 @Path("/{username}")
 @GET
 @Produces(MediaType.APPLICATION_JSON)
 public AllQuestionResponseDto getAllQuestions(@PathParam("username") String username) {
   List<Game> games =
       gameUserDataManager.getGamesByResultType(username, ResponseType.NEED_RESPONSE);
   AllQuestionResponseDto results = new AllQuestionResponseDto();
   for (Game game : games) {
     results.addQuestion(
         dozerMapper.map(
             questionManager.loadQuestions().getQuestionById(game.getId()),
             QuestionResponseDto.class));
   }
   return results;
 }
  @Path("/{username}/reply")
  @POST
  @Consumes(MediaType.APPLICATION_JSON)
  @Produces(MediaType.APPLICATION_JSON)
  public ResponseResponseDto giveResponse(ResponseRequestDto responseDto) {
    Response res = dozerMapper.map(responseDto, Response.class);

    ResponseResponseDto response = new ResponseResponseDto();

    Set<ConstraintViolation<Response>> constraintViolations = validator.validate(res);
    if (constraintViolations.size() != 0) {
      LOGGER.error("Invalid response from user");
      response.setResponseType(ResponseType.INVALID);
      return response;
    }
    Question question = questionManager.loadQuestions().getQuestionById(res.getId());
    List<String> answers = question.getAnswers();
    List<String> responses = responseDto.getResponses();

    response.setId(res.getId());
    response.setAnswer(responses);
    response.setResponseType(ResponseType.FAIL);

    if (answers.size() == responses.size()) {
      // TODO : gerer le cas des majuscules/minuscules
      if (answers.containsAll(responses)) {
        response.setResponseType(ResponseType.SUCCESS);
      }
    }

    Game game = gameUserDataManager.getGameById(responseDto.getUserName(), res.getId());

    if (game == null) {
      game = new Game();
      game.setId(response.getId());
    }
    game.setGivenAnswers(response.getAnswer());
    game.setType(response.getResponseType());
    try {
      gameUserDataManager.addOrUpdateGame(responseDto.getUserName(), game);
    } catch (StorageException e) {
      LOGGER.error("unable to store result in mongoDb: {}", e.getMessage());
    }

    return response;
  }