Point3dDifference extends AbstractDifferenceList implements IDifferenceList { public static IDifference construct(String name, Point3d first, Point3d second) { if (first == null && second == null) return null; Point3dDifference totalDiff = new Point3dDifference(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)); totalDiff.addChild(DoubleDifference.construct("z", first == null ? null : first.z, second == null ? null : second.z)); if (totalDiff.childCount() == 0) { return null; } return totalDiff; } private  Point3dDifference(String name); static IDifference construct(String name, Point3d first, Point3d second); @Override String toString();  }
@Test public void testDiff() { Point3d foo = new Point3d(1.0, 2.0, 4.5); Point3d bar = new Point3d(1.0, 5.0, 8.3); IDifference result = Point3dDifference.construct("Foo", foo, bar); Assert.assertNotNull(result); }
@Test public void testSame() { Point3d foo = new Point3d(1.0, 2.0, 4.5); Point3d bar = new Point3d(1.0, 2.0, 4.5); IDifference result = Point3dDifference.construct("Foo", foo, bar); Assert.assertNull(result); }
@Test public void testTwoNull() { IDifference result = Point3dDifference.construct("Foo", null, null); Assert.assertNull(result); }
@Test public void testOneNull() { Point3d bar = new Point3d(1.0, 5.0, 8.3); IDifference result = Point3dDifference.construct("Foo", null, bar); Assert.assertNotNull(result); result = Point3dDifference.construct("Foo", bar, null); Assert.assertNotNull(result); }