예제 #1
0
  @Test
  public void testSubjectCriteriaCorrect() {
    DichotomousCriterion criterion1 = new DichotomousCriterion();
    criterion1.setName("criterion1");
    DichotomousCriterion criterion2 = new DichotomousCriterion();
    criterion2.setName("criterion2");
    List<
            AbstractCriterion<
                ? extends Serializable, ? extends AbstractConstraint<? extends Serializable>>>
        criteria =
            new ArrayList<
                AbstractCriterion<
                    ? extends Serializable,
                    ? extends AbstractConstraint<? extends Serializable>>>();
    criteria.add(criterion1);
    criteria.add(criterion2);
    validTrial.setCriteria(criteria);
    assertEquals(2, validTrial.getCriteria().size());
    assertTrue(DichotomousCriterion.class.isInstance(validTrial.getCriteria().get(0)));
    assertEquals("criterion1", validTrial.getCriteria().get(0).getName());
    assertTrue(DichotomousCriterion.class.isInstance(validTrial.getCriteria().get(1)));
    assertEquals("criterion2", validTrial.getCriteria().get(1).getName());

    List<
            AbstractCriterion<
                ? extends Serializable, ? extends AbstractConstraint<? extends Serializable>>>
        list =
            new ArrayList<
                AbstractCriterion<
                    ? extends Serializable,
                    ? extends AbstractConstraint<? extends Serializable>>>();
    validTrial.setCriteria(list);
    assertEquals(list, validTrial.getCriteria());
  }
예제 #2
0
  @Test
  public void testStrataNamesAndIdsStrataCriterions() {
    DichotomousCriterion criterion1 = new DichotomousCriterion();
    criterion1.setId(1);
    criterion1.setName("criterion1");
    criterion1.setOption1("option1");
    criterion1.setOption2("option2");
    try {
      DichotomousConstraint d1 = new DichotomousConstraint(Arrays.asList(new String[] {"option1"}));
      d1.setId(1);
      criterion1.addStrata(d1);
      DichotomousConstraint d2 = new DichotomousConstraint(Arrays.asList(new String[] {"option2"}));
      d2.setId(2);
      criterion1.addStrata(d2);
    } catch (ContraintViolatedException e) {
      fail();
    }
    DichotomousCriterion criterion2 = new DichotomousCriterion();
    criterion2.setId(2);
    criterion2.setName("criterion2");
    criterion2.setOption1("option1");
    criterion2.setOption2("option2");
    try {
      DichotomousConstraint d1 = new DichotomousConstraint(Arrays.asList(new String[] {"option1"}));
      d1.setId(1);
      criterion2.addStrata(d1);
      DichotomousConstraint d2 = new DichotomousConstraint(Arrays.asList(new String[] {"option2"}));
      d2.setId(2);
      criterion2.addStrata(d2);
    } catch (ContraintViolatedException e) {
      fail();
    }
    validTrial.addCriterion(criterion1);
    validTrial.addCriterion(criterion2);

    Pair<List<String>, List<String>> pair = validTrial.getAllStrataIdsAndNames();

    assertEquals(4, pair.first().size());
    assertEquals(4, pair.last().size());

    Collections.sort(pair.first());
    assertEquals("1_1;2_1;", pair.first().get(0));
    assertEquals("1_1;2_2;", pair.first().get(1));
    assertEquals("1_2;2_1;", pair.first().get(2));
    assertEquals("1_2;2_2;", pair.first().get(3));

    Collections.sort(pair.last());
    assertEquals("criterion1_option1;criterion2_option1;", pair.last().get(0));
    assertEquals("criterion1_option1;criterion2_option2;", pair.last().get(1));
    assertEquals("criterion1_option2;criterion2_option1;", pair.last().get(2));
    assertEquals("criterion1_option2;criterion2_option2;", pair.last().get(3));
  }
예제 #3
0
 @Test
 public void testAddSubjectCriteria() {
   DichotomousCriterion criterion1 = new DichotomousCriterion();
   criterion1.setName("criterion1");
   DichotomousCriterion criterion2 = new DichotomousCriterion();
   criterion2.setName("criterion2");
   validTrial.addCriterion(criterion1);
   validTrial.addCriterion(criterion2);
   assertEquals(2, validTrial.getCriteria().size());
   assertTrue(DichotomousCriterion.class.isInstance(validTrial.getCriteria().get(0)));
   assertEquals("criterion1", validTrial.getCriteria().get(0).getName());
   assertTrue(DichotomousCriterion.class.isInstance(validTrial.getCriteria().get(1)));
   assertEquals("criterion2", validTrial.getCriteria().get(1).getName());
   assertValid(validTrial);
 }