@Before
  public void setUp() {
    profile = new Profile("Test Profile");
    criteria = new Criteria();

    questionA = new BooleanQuestion(1, "Test Question A");
    questionB = new BooleanQuestion(2, "Test Question B");
    questionC = new BooleanQuestion(3, "Test Question C");

    profile.add(new Answer(questionA, Bool.TRUE));
    profile.add(new Answer(questionB, Bool.FALSE));
    profile.add(new Answer(questionC, Bool.TRUE));
  }
Пример #2
0
  @Test
  public void findsAnswersBasedOnPredicate() {
    profile.add(new Answer(new BooleanQuestion(1, "1"), Bool.FALSE));
    profile.add(new Answer(new PercentileQuestion(2, "2", new String[] {}), 0));
    profile.add(new Answer(new PercentileQuestion(3, "3", new String[] {}), 0));

    List<Answer> answers =
        profile.find(a -> a.getQuestion().getClass() == PercentileQuestion.class);
    assertThat(ids(answers), is(new int[] {2, 3}));

    List<Answer> complementAnswers =
        profile.find(a -> a.getQuestion().getClass() != PercentileQuestion.class);
    ArrayList<Answer> allAnswers = new ArrayList<>();
    allAnswers.addAll(answers);
    allAnswers.addAll(complementAnswers);
    assertThat(ids(allAnswers), is(new int[] {1, 2, 3}));
  }