Point2dDifference 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(); } private  Point2dDifference(String name); static IDifference construct(String name, Point2d first, Point2d second); @Override String toString();  }
@Test public void testToString() { Point2d bar = new Point2d(1.0, 5.0); IDifference result = Point2dDifference.construct("Foo", null, bar); String diffString = result.toString(); Assert.assertNotNull(diffString); assertOneLiner(diffString); }