AtomDiff { public static IDifference difference(IChemObject first, IChemObject second) { if (!(first instanceof IAtom && second instanceof IAtom)) { return null; } IAtom firstElem = (IAtom) first; IAtom secondElem = (IAtom) second; ChemObjectDifference totalDiff = new ChemObjectDifference("AtomDiff"); totalDiff.addChild(IntegerDifference.construct("H", firstElem.getImplicitHydrogenCount(), secondElem.getImplicitHydrogenCount())); totalDiff .addChild(IntegerDifference.construct("SP", firstElem.getStereoParity(), secondElem.getStereoParity())); totalDiff.addChild(Point2dDifference.construct("2D", firstElem.getPoint2d(), secondElem.getPoint2d())); totalDiff.addChild(Point3dDifference.construct("3D", firstElem.getPoint3d(), secondElem.getPoint3d())); totalDiff.addChild(Point3dDifference.construct("F3D", firstElem.getFractionalPoint3d(), secondElem.getFractionalPoint3d())); totalDiff.addChild(DoubleDifference.construct("C", firstElem.getCharge(), secondElem.getCharge())); totalDiff.addChild(AtomTypeDiff.difference(first, second)); if (totalDiff.childCount() > 0) { return totalDiff; } else { return null; } } private  AtomDiff(); static String diff(IChemObject first, IChemObject second); static IDifference difference(IChemObject first, IChemObject second);  }
@Test public void testDifference() { IAtom atom1 = mock(IAtom.class); IAtom atom2 = mock(IAtom.class); when(atom1.getSymbol()).thenReturn("H"); when(atom2.getSymbol()).thenReturn("C"); IDifference difference = AtomDiff.difference(atom1, atom2); Assert.assertNotNull(difference); }