示例#1
0
  public void testLengthNegativeAndPositiveWithGap() throws Exception {
    studySegment.addPeriod(createPeriod("dc", -28, 14, 1));
    studySegment.addPeriod(createPeriod("dc", 10, 8, 2));

    assertDayRange(-28, 25, studySegment.getDayRange());
    assertEquals(54, studySegment.getLengthInDays());
  }
示例#2
0
 public void testFindMatchingChildPeriodByNameWhenNameIsNotPresent() throws Exception {
   Period p1 = createPeriod("P1", 4, 7, 1);
   Period p2 = createPeriod("P2", 4, 7, 1);
   studySegment.addPeriod(p1);
   studySegment.addPeriod(p2);
   assertNull(studySegment.findNaturallyMatchingChild("Q"));
 }
示例#3
0
  public void testLengthNegative() throws Exception {
    Period single = createPeriod("", -28, 15, 1);
    studySegment.addPeriod(single);

    assertDayRange(-28, -14, studySegment.getDayRange());
    assertEquals(15, studySegment.getLengthInDays());
  }
示例#4
0
  public void testLengthSimple() throws Exception {
    Period single = createPeriod("", 3, Duration.Unit.day, 15, 3);
    studySegment.addPeriod(single);

    assertDayRange(3, 47, studySegment.getDayRange());
    assertEquals(45, studySegment.getLengthInDays());
  }
示例#5
0
 public void testFindMatchingChildPeriodByNameWhenNameUnique() throws Exception {
   Period p1 = setGridId("GRID-1", createPeriod("P1", 4, 7, 1));
   Period p2 = setGridId("GRID-2", createPeriod("P2", 4, 7, 1));
   studySegment.addPeriod(p1);
   studySegment.addPeriod(p2);
   assertSame("Not found", p2, studySegment.findNaturallyMatchingChild("P2"));
 }
示例#6
0
 public void testAddPeriod() {
   Period period = new Period();
   studySegment.addPeriod(period);
   assertEquals("wrong number of periods", 1, studySegment.getPeriods().size());
   assertSame("wrong period present", period, studySegment.getPeriods().iterator().next());
   assertEquals(
       "bidirectional relationship not maintained", studySegment, period.getStudySegment());
 }
示例#7
0
  public void testLengthWhenOverlapping() throws Exception {
    Period zero = createPeriod("", 1, Duration.Unit.day, 30, 1);
    Period one = createPeriod("", 17, Duration.Unit.day, 15, 1);
    studySegment.addPeriod(zero);
    studySegment.addPeriod(one);

    assertDayRange(1, 31, studySegment.getDayRange());
    assertEquals(31, studySegment.getLengthInDays());
  }
示例#8
0
  public void testDeepEqualsForDifferentPeriodSets() throws Exception {
    Period p1 = setGridId("G-P1", createPeriod("P1", 4, 7, 1));
    Period p2_0 = setGridId("G-P2", createPeriod("P2", 4, 7, 1));
    Period p2_1 = setGridId("G-P2", createPeriod("P2", 4, 11, 1));
    StudySegment s1 = createNamedInstance("S1", StudySegment.class);
    StudySegment s2 = createNamedInstance("S1", StudySegment.class);
    s1.addPeriod(p1);
    s1.addPeriod(p2_0);
    s2.addPeriod(p2_1);

    Differences actual = s1.deepEquals(s2);
    assertDifferences(actual, "missing period G-P1");
    assertChildDifferences(
        actual, new String[] {"period G-P2", "duration"}, "quantity does not match: 7 != 11");
  }
示例#9
0
  public void testAddMultiplePeriod() {
    studySegment = new StudySegment();
    Period period = createPeriod("name", 3, Duration.Unit.day, 15, 3);
    Period anotherPeriod = createPeriod("name", 3, Duration.Unit.day, 15, 3);
    studySegment.addPeriod(period);
    studySegment.addPeriod(anotherPeriod);

    assertEquals(
        "wrong number of periods because both periods are same",
        1,
        studySegment.getPeriods().size());

    studySegment = new StudySegment();

    period.setId(1);
    studySegment.addPeriod(period);
    studySegment.addPeriod(anotherPeriod);

    assertEquals("wrong number of periods", 2, studySegment.getPeriods().size());
  }
示例#10
0
  public void testDeepEqualsForDifferentName() throws Exception {
    StudySegment s1 = createNamedInstance("S1", StudySegment.class);
    StudySegment s2 = createNamedInstance("S2", StudySegment.class);

    assertDifferences(s1.deepEquals(s2), "name \"S1\" does not match \"S2\"");
  }