ChemObjectDifference extends AbstractDifferenceList implements IDifferenceList { @Override public String toString() { if (differences.size() == 0) return ""; StringBuffer diffBuffer = new StringBuffer(); diffBuffer.append(this.name).append('{'); Iterator<IDifference> children = getChildren().iterator(); while (children.hasNext()) { diffBuffer.append(children.next().toString()); if (children.hasNext()) { diffBuffer.append(", "); } } diffBuffer.append('}'); return diffBuffer.toString(); } ChemObjectDifference(String name); @Override String toString();  }
@Test public void testToString() { ChemObjectDifference diff = new ChemObjectDifference("AtomTypeDiff"); String diffString = diff.toString(); Assert.assertNotNull(diffString); Assert.assertEquals(0, diffString.length()); diff.addChild(StringDifference.construct("Foo", "bar", "bar1")); diffString = diff.toString(); Assert.assertNotNull(diffString); assertOneLiner(diffString); assertContains(diffString, "AtomTypeDiff"); assertContains(diffString, "{"); assertContains(diffString, "}"); }