예제 #1
0
  public void testUnequalObjects() {
    this.list2.set(0, "xxx-" + this.list2.get(0) + "-xxx");
    this.list2.set(4, "xxx-" + this.list2.get(4) + "-xxx");
    OrderedContainerDiff diff =
        (OrderedContainerDiff) this.differentiator.diff(this.list1, this.list2);
    this.verifyDiffMatchMismatch(diff, this.list1, this.list2);

    Diff[] diffs = diff.getDiffs();
    assertEquals(this.list1.size(), diffs.length);
    OrderedContainerElementDiff oced;
    oced = (OrderedContainerElementDiff) diffs[0];
    assertTrue(oced.different());
    SimpleDiff ed;
    ed = (SimpleDiff) oced.getDiff();
    assertTrue(ed.getObject1().equals("zero"));
    assertTrue(ed.getObject2().equals("xxx-zero-xxx"));
    oced = (OrderedContainerElementDiff) diffs[1];
    assertTrue(oced.identical());
    oced = (OrderedContainerElementDiff) diffs[2];
    assertTrue(oced.identical());
    oced = (OrderedContainerElementDiff) diffs[3];
    assertTrue(oced.identical());
    oced = (OrderedContainerElementDiff) diffs[4];
    assertTrue(oced.different());
    ed = (SimpleDiff) oced.getDiff();
    assertTrue(ed.getObject1().equals("four"));
    assertTrue(ed.getObject2().equals("xxx-four-xxx"));
  }
예제 #2
0
  public void testMissingElements() {
    this.list2.remove(4);
    OrderedContainerDiff diff =
        (OrderedContainerDiff) this.differentiator.diff(this.list1, this.list2);
    this.verifyDiffMatchMismatch(diff, this.list1, this.list2);

    Diff[] diffs = diff.getDiffs();
    assertEquals(this.list1.size(), diffs.length);
    OrderedContainerElementDiff oced;
    oced = (OrderedContainerElementDiff) diffs[0];
    assertTrue(oced.identical());
    oced = (OrderedContainerElementDiff) diffs[1];
    assertTrue(oced.identical());
    oced = (OrderedContainerElementDiff) diffs[2];
    assertTrue(oced.identical());
    oced = (OrderedContainerElementDiff) diffs[3];
    assertTrue(oced.identical());
    Diff moced = diffs[4];
    assertTrue(moced.different());
    assertTrue(moced.getObject1().equals("four"));
    assertTrue(moced.getObject2().toString().equals("<undefined>"));
  }