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()); }
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()); }
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"); }
public void testLengthNegative() throws Exception { Period single = createPeriod("", -28, 15, 1); studySegment.addPeriod(single); assertDayRange(-28, -14, studySegment.getDayRange()); assertEquals(15, studySegment.getLengthInDays()); }
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()); }
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")); }
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")); }
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()); }
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()); }