@Test
  public void score_is_0_when_no_match() {

    initializeNoMatchCriterion();

    profile.matches(criteria);

    assertThat(profile.score(), is(0));
  }
  @Test
  public void score_is_sum_when_some_match() {

    initializeSomeMatchCriteria();

    int score = Weight.Important.getValue() * 2;

    profile.matches(criteria);

    assertThat(profile.score(), is(score));
  }
  @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));
  }
Пример #4
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}));
  }
 @Test
 public void false_when_no_match() {
   initializeNoMatchCriterion();
   assertThat(profile.matches(criteria), is(false));
 }
 @Test
 public void true_when_some_match() {
   initializeSomeMatchCriteria();
   assertThat(profile.matches(criteria), is(true));
 }
 @Test
 public void false_when_must_match_not_match() {
   initializeMustMatchNotMatchCriteria();
   assertThat(profile.matches(criteria), is(false));
 }
 @Test
 public void score_is_0_when_empty() {
   profile.matches(criteria);
   assertThat(profile.score(), is(0));
 }
 @Test
 public void false_when_empty() {
   assertThat(profile.matches(criteria), is(false));
 }