Esempio n. 1
0
  @Override
  protected void setUp() throws Exception {
    super.setUp();

    study = assignIds(createBasicTemplate("CRM 114"));
    for (Epoch e : study.getPlannedCalendar().getEpochs()) {
      for (StudySegment segment : e.getStudySegments()) {
        Period p = createPeriod(1, 1, 1);
        p.addPlannedActivity(createPlannedActivity("T", 1));
        segment.addPeriod(p);
      }
    }
    nu = createSite("NU", "IL675");
    vanderbilt = createSite("VU", "TN054");
    StudySite ss = study.addSite(nu);
    ss.approveAmendment(study.getAmendment(), new Date());
    configuration = registerMockFor(Configuration.class);
  }
Esempio n. 2
0
  public void testDetailOrder() {
    Study s = Fixtures.createReleasedTemplate();
    Period period = Fixtures.createPeriod("period1", 1, 10, 2);
    PlannedActivity plannedActivity = Fixtures.createPlannedActivity("activity", 3);
    PlannedActivityLabel plannedActivityLabel = Fixtures.createPlannedActivityLabel("label");
    period.addPlannedActivity(plannedActivity);
    plannedActivity.addPlannedActivityLabel(plannedActivityLabel);
    s.getPlannedCalendar().getEpochs().get(0).getStudySegments().get(0).getPeriods().add(period);

    Delta studyDelta = Delta.createDeltaFor(s.getPlannedCalendar().getStudy());
    Delta epochDelta = Delta.createDeltaFor(s.getPlannedCalendar().getEpochs().get(0));
    Delta studySegmentDelta =
        Delta.createDeltaFor(s.getPlannedCalendar().getEpochs().get(0).getStudySegments().get(1));
    Delta periodDelta =
        Delta.createDeltaFor(
            s.getPlannedCalendar()
                .getEpochs()
                .get(0)
                .getStudySegments()
                .get(0)
                .getPeriods()
                .last());
    Delta plannedActivityDelta =
        Delta.createDeltaFor(
            s.getPlannedCalendar()
                .getEpochs()
                .get(0)
                .getStudySegments()
                .get(0)
                .getPeriods()
                .first()
                .getPlannedActivities()
                .get(0));
    Delta plannedActivityLabelDelta =
        Delta.createDeltaFor(
            s.getPlannedCalendar()
                .getEpochs()
                .get(0)
                .getStudySegments()
                .get(0)
                .getPeriods()
                .first()
                .getPlannedActivities()
                .get(0)
                .getPlannedActivityLabels()
                .first());

    List<Delta<?>> listOfDeltas = new ArrayList<Delta<?>>();
    listOfDeltas.add(plannedActivityDelta);
    listOfDeltas.add(periodDelta);
    listOfDeltas.add(epochDelta);
    listOfDeltas.add(studyDelta);
    listOfDeltas.add(studySegmentDelta);
    listOfDeltas.add(plannedActivityLabelDelta);

    expect(templateService.findEquivalentChild(s, studyDelta.getNode())).andReturn(s);
    expect(templateService.findEquivalentChild(s, periodDelta.getNode())).andReturn(null);
    expect(templateService.findEquivalentChild(s, epochDelta.getNode()))
        .andReturn(epochDelta.getNode());
    expect(templateService.findEquivalentChild(s, studySegmentDelta.getNode()))
        .andReturn(studySegmentDelta.getNode());
    expect(templateService.findEquivalentChild(s, plannedActivityDelta.getNode())).andReturn(null);
    expect(templateService.findEquivalentChild(s, plannedActivityLabelDelta.getNode()))
        .andReturn(plannedActivityLabelDelta.getNode());
    replayMocks();
    DeltaIterator di = new DeltaIterator(listOfDeltas, s, templateService, false);

    assertSame("studyDelta is not the first element", studyDelta, di.next());
    assertSame("epochDelta is not the second element", epochDelta, di.next());
    assertSame("studySegmentDelta is not the third element", studySegmentDelta, di.next());
    assertSame("periodDelta is not the forth element", plannedActivityLabelDelta, di.next());
    assertFalse("deltaIterator has more elements ", di.hasNext());
    verifyMocks();
  }