Point2dDifference extends AbstractDifferenceList implements IDifferenceList { public static IDifference construct(String name, Point2d first, Point2d second) { if (first == null && second == null) return null; Point2dDifference totalDiff = new Point2dDifference(name); totalDiff.addChild(DoubleDifference.construct("x", first == null ? null : first.x, second == null ? null : second.x)); totalDiff.addChild(DoubleDifference.construct("y", first == null ? null : first.y, second == null ? null : second.y)); if (totalDiff.childCount() == 0) { return null; } return totalDiff; } private  Point2dDifference(String name); static IDifference construct(String name, Point2d first, Point2d second); @Override String toString();  }
@Test public void testDiff() { Point2d foo = new Point2d(1.0, 2.0); Point2d bar = new Point2d(1.0, 5.0); IDifference result = Point2dDifference.construct("Foo", foo, bar); Assert.assertNotNull(result); }
@Test public void testSame() { Point2d foo = new Point2d(1.0, 2.0); Point2d bar = new Point2d(1.0, 2.0); IDifference result = Point2dDifference.construct("Foo", foo, bar); Assert.assertNull(result); }
@Test public void testTwoNull() { IDifference result = Point2dDifference.construct("Foo", null, null); Assert.assertNull(result); }
@Test public void testOneNull() { Point2d bar = new Point2d(1.0, 2.0); IDifference result = Point2dDifference.construct("Foo", null, bar); Assert.assertNotNull(result); result = Point2dDifference.construct("Foo", bar, null); Assert.assertNotNull(result); }