SingleElectronDiff { public static String diff(IChemObject first, IChemObject second) { IDifference diff = difference(first, second); if (diff == null) { return ""; } else { return diff.toString(); } } private  SingleElectronDiff(); static String diff(IChemObject first, IChemObject second); static IDifference difference(IChemObject first, IChemObject second);  }
@Test public void testMatchAgainstItself() { ISingleElectron bond1 = mock(ISingleElectron.class); String result = SingleElectronDiff.diff(bond1, bond1); assertZeroLength(result); }
@Test public void testDiff() { IAtom carbon = mock(IAtom.class); IAtom oxygen = mock(IAtom.class); when(carbon.getSymbol()).thenReturn("C"); when(oxygen.getSymbol()).thenReturn("O"); ISingleElectron bond1 = mock(ISingleElectron.class); ISingleElectron bond2 = mock(ISingleElectron.class); when(bond1.getAtom()).thenReturn(carbon); when(bond2.getAtom()).thenReturn(oxygen); String result = SingleElectronDiff.diff(bond1, bond2); Assert.assertNotNull(result); Assert.assertNotSame(0, result.length()); assertContains(result, "SingleElectronDiff"); assertContains(result, "AtomDiff"); assertContains(result, "C/O"); }