Exemple #1
0
  @Then("^the quiz should be opened$")
  public void the_quiz_should_be_opened() throws Throwable {
    when(optionFactory.createQuizOption(quiz.getId(), quiz.getName())).thenReturn(option);
    Set<QuizOption> closed = new HashSet<>();
    Set<QuizOption> open = new HashSet<>();
    open.add(option);

    assertThat(quizCtrl.getClosedQuizzes(), is(equalTo(closed)));
    assertThat(quizCtrl.getAvailableQuizzes(), is(equalTo(open)));
  }
Exemple #2
0
  @Then("^the the user can retrieve list of the available (\\d+)$")
  public void the_the_user_can_retrieve_list_of_the_available_quiz(int id) throws Throwable {
    when(optionFactory.createQuizOption(quiz.getId(), quiz.getName())).thenReturn(option);
    Set<QuizOption> options = new HashSet<>();
    options.add(option);
    when(option.getQuizId()).thenReturn(id);

    Set<QuizOption> quizOptions = quizCtrl.getAvailableQuizzes();
    verify(optionFactory).createQuizOption(anyInt(), anyString());
    assertThat(quizOptions, is(equalTo(options)));
    assertThat(
        quizOptions.toArray(new QuizOption[quizOptions.size()])[0].getQuizId(), is(equalTo(id)));
  }