예제 #1
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());
 }
예제 #2
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());
  }