Beispiel #1
0
  public void testMergeWithEquivalentAddPresent() throws Exception {
    delta.addChange(Add.create(ssc, 2));

    remove.setChild(ssc);
    remove.mergeInto(delta, NOW);

    assertEquals("Remove should have canceled add", 0, delta.getChanges().size());
  }
Beispiel #2
0
  public void testMergeWithReorderAloneDoesNotCancelReorder() throws Exception {
    delta.addChange(Reorder.create(ssa, 0, 1));

    remove.setChild(ssa);
    remove.mergeInto(delta, NOW);

    assertEquals("Remove should not have canceled anything", 2, delta.getChanges().size());
  }
Beispiel #3
0
  public void testMergeWithNoOtherChanges() throws Exception {
    remove.setChild(ssa);
    remove.mergeInto(delta, NOW);

    assertEquals("Remove should have been added", 1, delta.getChanges().size());
    assertSame(remove, delta.getChanges().get(0));
    assertEquals("Updated date not set", NOW, remove.getUpdatedDate());
  }
Beispiel #4
0
  public void testMergeWithAddFollowedByReorderCancelsBoth() throws Exception {
    delta.addChange(Add.create(ssc, 2));
    Reorder.create(ssc, 2, 1).mergeInto(delta, NOW);

    remove.setChild(ssc);
    remove.mergeInto(delta, NOW);

    assertEquals("Remove should have canceled add and reorder", 0, delta.getChanges().size());
  }
Beispiel #5
0
  public void testMergeWithEquivalentRemovePresent() throws Exception {
    Remove expectedRemove = Remove.create(ssb);
    delta.addChange(expectedRemove);

    remove.setChild(ssb);
    remove.mergeInto(delta, NOW);

    assertEquals("Duplicate remove should not have been added", 1, delta.getChanges().size());
    assertEquals(expectedRemove, delta.getChanges().get(0));
  }
Beispiel #6
0
  public void testMergeTwoIntoDeltaWithIndexesThenRemoveOne() throws Exception {
    StudySegment retained0 = setId(17, new StudySegment());
    StudySegment retained1 = setId(18, new StudySegment());
    StudySegment retained2 = setId(19, new StudySegment());
    delta.addChange(Add.create(retained0, 2));
    delta.addChange(Add.create(ssc, 3));
    delta.addChange(Add.create(retained1, 4));
    delta.addChange(Add.create(retained2, 5));

    remove.setChild(ssc);
    remove.mergeInto(delta, NOW);
    assertEquals("Wrong number of changes in delta", 3, delta.getChanges().size());
    Add add0 = (Add) delta.getChanges().get(0);
    Add add1 = (Add) delta.getChanges().get(1);
    Add add2 = (Add) delta.getChanges().get(2);
    assertAdd("Index for earlier retained add updated", retained0, 2, add0);
    assertChangeTime("Unchanged add time incorrectly updated", null, add0);
    assertAdd("Index for later retained add not updated", retained1, 3, add1);
    assertChangeTime("Updated add time not updated", NOW, add1);
    assertAdd("Index for later retained add not updated", retained2, 4, add2);
    assertChangeTime("Updated add time not updated", NOW, add2);
  }
Beispiel #7
0
  public void testMergeWithChildNotInNode() throws Exception {
    remove.setChild(ssc);
    remove.mergeInto(delta, NOW);

    assertEquals("Remove should not have been added", 0, delta.getChanges().size());
  }
Beispiel #8
0
 public void testSetChildIdKeepsChildIfIdsMatch() throws Exception {
   StudySegment expectedChild = setId(15, new StudySegment());
   remove.setChild(expectedChild);
   remove.setChildId(expectedChild.getId());
   assertSame("New child incorrectly cleared", expectedChild, remove.getChild());
 }
Beispiel #9
0
 public void testSetChildIdClearsChildIfIdsDoNotMatch() throws Exception {
   remove.setChild(setId(3, new StudySegment()));
   remove.setChildId(15);
   assertNull("New child not cleared", remove.getChild());
 }
Beispiel #10
0
 public void testGetChildUsesDirectAttributeIfNoDomainObject() throws Exception {
   remove.setChild(null);
   remove.setChildId(5);
   assertEquals(5, (int) remove.getChildId());
 }
Beispiel #11
0
 public void testGetChildIdPassesThroughFromDomainObject() throws Exception {
   Epoch child = setId(4, new Epoch());
   remove.setChildId(17);
   remove.setChild(child);
   assertEquals(4, (int) remove.getChildId());
 }
Beispiel #12
0
  public void testDeepEqualsWhenRemoveHasDifferentChild() throws Exception {
    Remove remove1 = Remove.create(setGridId("e1", Epoch.create("E1")));
    Remove remove2 = Remove.create(setGridId("e2", Epoch.create("E2")));

    assertDifferences(remove1.deepEquals(remove2), "for different child");
  }
Beispiel #13
0
 public void testEqualsWhenRemoveHasDifferentChild() throws Exception {
   Remove remove1 = Remove.create(createNamedInstance("Epoch1", Epoch.class));
   Remove remove2 = Remove.create(createNamedInstance("Segment2", StudySegment.class));
   assertNotEquals("Removes are equals", remove1, remove2);
 }
Beispiel #14
0
 public void testEqualsWhenRemoveHasSameChild() throws Exception {
   Remove remove1 = Remove.create(createNamedInstance("Segment1", StudySegment.class));
   Remove remove2 = Remove.create(createNamedInstance("Segment1", StudySegment.class));
   assertEquals("Removes are not equals", remove1, remove2);
 }