StringDifference implements IDifference { public static IDifference construct(String name, String first, String second) { if (first == null && second == null) { return null; } if (first == null || second == null) { return new StringDifference(name, first, second); } if (first.equals(second)) { return null; } return new StringDifference(name, first, second); } private  StringDifference(String name, String first, String second); static IDifference construct(String name, String first, String second); @Override String toString();  }
@Test public void testDiff() { IDifference result = StringDifference.construct("Foo", "foo", "bar"); Assert.assertNotNull(result); }
@Test public void testSame() { IDifference result = StringDifference.construct("Foo", "foo", "foo"); Assert.assertNull(result); }
@Test public void testTwoNull() { IDifference result = StringDifference.construct("Foo", null, null); Assert.assertNull(result); }
@Test public void testOneNull() { IDifference result = StringDifference.construct("Foo", null, "bar"); Assert.assertNotNull(result); result = StringDifference.construct("Foo", "bar", null); Assert.assertNotNull(result); }