LonePairDiff { public static IDifference difference(IChemObject first, IChemObject second) { if (!(first instanceof ILonePair && second instanceof ILonePair)) { return null; } ILonePair firstB = (ILonePair) first; ILonePair secondB = (ILonePair) second; IDifferenceList totalDiff = new ChemObjectDifference("LonePairDiff"); totalDiff.addChild(AtomDiff.difference(firstB.getAtom(), secondB.getAtom())); totalDiff.addChild(ElectronContainerDiff.difference(first, second)); if (totalDiff.childCount() > 0) { return totalDiff; } else { return null; } } private  LonePairDiff(); static String diff(IChemObject first, IChemObject second); static IDifference difference(IChemObject first, IChemObject second);  }
@Test public void testDifference() { IAtom carbon = mock(IAtom.class); IAtom oxygen = mock(IAtom.class); when(carbon.getSymbol()).thenReturn("C"); when(oxygen.getSymbol()).thenReturn("O"); ILonePair bond1 = mock(ILonePair.class); ILonePair bond2 = mock(ILonePair.class); when(bond1.getAtom()).thenReturn(carbon); when(bond2.getAtom()).thenReturn(oxygen); IDifference difference = LonePairDiff.difference(bond1, bond2); Assert.assertNotNull(difference); }