Beispiel #1
0
  public void testDeepEqualsWhenDeltaAreNotEquals() throws Exception {
    Amendment a1 =
        Fixtures.createAmendment("Amendment", DateTools.createDate(2007, Calendar.APRIL, 6));
    Amendment a2 =
        Fixtures.createAmendment("Amendment", DateTools.createDate(2007, Calendar.APRIL, 6));
    Epoch epoch1 = new Epoch();
    epoch1.setName("Epoch");
    epoch1.setGridId("GridId1");
    Delta<Epoch> delta1 = Delta.createDeltaFor(epoch1);
    delta1.setGridId("delta1");
    delta1.addChanges(PropertyChange.create("name", "A", "C"), Add.create(new StudySegment()));
    a1.addDelta(delta1);
    Epoch epoch2 = new Epoch();
    epoch2.setName("Epoch");
    epoch2.setGridId("GridId1");
    Delta<Epoch> delta2 = Delta.createDeltaFor(epoch2);
    delta2.setGridId("delta1");
    delta2.addChanges(PropertyChange.create("name", "A", "B"), Add.create(new StudySegment()));
    a2.addDelta(delta2);
    Differences differences = a1.deepEquals(a2);
    assertFalse(differences.getChildDifferences().isEmpty());

    assertChildDifferences(
        differences,
        new String[] {"delta for epoch GridId1", "property change for name"},
        "new value \"C\" does not match \"B\"");
  }
Beispiel #2
0
 public void testSetMemOnlyRecursiveToDeltas() throws Exception {
   Amendment amendment =
       Fixtures.createAmendment(null, DateTools.createDate(2008, Calendar.JUNE, 22));
   amendment.addDelta(Delta.createDeltaFor(new Study()));
   amendment.setMemoryOnly(true);
   assertTrue(amendment.getDeltas().get(0).isMemoryOnly());
 }
Beispiel #3
0
  public void testUpdatedDateIsMaxAcrossDeltas() throws Exception {
    a3.addDelta(Delta.createDeltaFor(new Epoch(), PropertyChange.create("name", "A", "B")));
    a3.addDelta(Delta.createDeltaFor(new Epoch(), Add.create(new StudySegment())));
    a3.getDeltas()
        .get(0)
        .getChanges()
        .get(0)
        .setUpdatedDate(DateTools.createDate(2005, Calendar.MAY, 3));
    a3.getDeltas()
        .get(1)
        .getChanges()
        .get(0)
        .setUpdatedDate(DateTools.createDate(2005, Calendar.MAY, 4));

    assertDayOfDate(2005, Calendar.MAY, 4, a3.getUpdatedDate());
  }
Beispiel #4
0
  public void testCloneDeepClonesDeltas() throws Exception {
    Amendment src = Fixtures.createAmendment(null, DateTools.createDate(2008, Calendar.JUNE, 22));
    src.addDelta(Delta.createDeltaFor(new Study()));

    Amendment clone = src.clone();
    assertEquals("Wrong number of cloned changes", 1, clone.getDeltas().size());
    assertNotSame("Deltas not deep cloned", src.getDeltas().get(0), clone.getDeltas().get(0));
  }
Beispiel #5
0
 public void testFindMatchingDelta() throws Exception {
   Amendment a1 =
       Fixtures.createAmendment("Amendment", DateTools.createDate(2007, Calendar.APRIL, 6));
   Epoch epoch1 = new Epoch();
   epoch1.setGridId("epoch1");
   Delta<Epoch> delta1 = Delta.createDeltaFor(epoch1);
   delta1.setGridId("delta1");
   a1.addDelta(delta1);
   Delta actualDelta = a1.getMatchingDelta("delta1", "epoch1", delta1.getClass());
   assertNotNull("Delta not found", actualDelta);
 }
Beispiel #6
0
  @Override
  protected void setUp() throws Exception {
    super.setUp();
    remove = new Remove();
    epoch = setId(5, Epoch.create("Treatment", "A", "B", "C"));
    ssa = setId(1, epoch.getStudySegments().get(0));
    ssb = setId(2, epoch.getStudySegments().get(1));
    ssc = setId(3, epoch.getStudySegments().get(2));
    epoch.getStudySegments().remove(ssc);

    delta = Delta.createDeltaFor(epoch);
  }
Beispiel #7
0
 public void testDeepEqualsWhenNoOfDeltaAreDifferent() throws Exception {
   Amendment a1 =
       Fixtures.createAmendment("Amendment", DateTools.createDate(2007, Calendar.APRIL, 6));
   Amendment a2 =
       Fixtures.createAmendment("Amendment", DateTools.createDate(2007, Calendar.APRIL, 6));
   a1.addDelta(
       Delta.createDeltaFor(
           new Epoch(), PropertyChange.create("name", "A", "B"), Add.create(new StudySegment())));
   a2.addDelta(
       Delta.createDeltaFor(
           new Epoch(), PropertyChange.create("name", "A", "B"), Add.create(new StudySegment())));
   a2.addDelta(
       Delta.createDeltaFor(
           new Epoch(), PropertyChange.create("name", "A", "B"), Add.create(new StudySegment())));
   Differences differences = a1.deepEquals(a2);
   assertFalse(differences.getMessages().isEmpty());
   assertEquals(
       "Amendment are Equals",
       "number of deltas does not match: 1 != 2",
       differences.getMessages().get(0));
 }
Beispiel #8
0
  public void testDeepEqualsWithMismatchedChanges() throws Exception {
    Amendment a = new Amendment();
    a.getDeltas()
        .add(
            setGridId(
                "D1",
                Delta.createDeltaFor(
                    setGridId("PC1", new PlannedCalendar()),
                    Add.create(setGridId("E1", new Epoch())))));
    Amendment b = new Amendment();
    b.getDeltas()
        .add(
            setGridId(
                "D1",
                Delta.createDeltaFor(
                    setGridId("PC1", new PlannedCalendar()),
                    Remove.create(setGridId("E1", new Epoch())))));

    assertChildDifferences(
        a.deepEquals(b),
        new String[] {"delta for planned calendar PC1"},
        "add of epoch:E1 replaced by remove of epoch:E1");
  }
Beispiel #9
0
 public void testDeepEqualsWhenNoDeltaFoundInAmendment() throws Exception {
   Amendment a1 =
       Fixtures.createAmendment("Amendment", DateTools.createDate(2007, Calendar.APRIL, 6));
   Amendment a2 =
       Fixtures.createAmendment("Amendment", DateTools.createDate(2007, Calendar.APRIL, 6));
   Epoch epoch1 = new Epoch();
   epoch1.setGridId("epoch1");
   Delta<Epoch> delta1 = Delta.createDeltaFor(epoch1);
   delta1.setGridId("delta1");
   delta1.addChanges(PropertyChange.create("name", "A", "B"), Add.create(new StudySegment()));
   a1.addDelta(delta1);
   StudySegment segment1 = new StudySegment();
   segment1.setGridId("segment1");
   Delta<StudySegment> delta2 = Delta.createDeltaFor(segment1);
   delta2.setGridId("delta1");
   delta2.addChanges(PropertyChange.create("name", "A", "B"), Add.create(new StudySegment()));
   a2.addDelta(delta2);
   Differences differences = a1.deepEquals(a2);
   assertFalse(differences.getMessages().isEmpty());
   assertEquals(
       "Amendments are equals",
       "no delta for epoch epoch1 found",
       differences.getMessages().get(0));
 }
Beispiel #10
0
 private void ensureUpdatedDate(Amendment expectedAmendment, Date expectedDate) {
   expectedAmendment.getDeltas().clear();
   Delta<?> delta = Delta.createDeltaFor(new Epoch(), PropertyChange.create("name", "A", "B"));
   delta.getChanges().get(0).setUpdatedDate(expectedDate);
   expectedAmendment.addDelta(delta);
 }