ElementDiff { public static IDifference difference(IChemObject first, IChemObject second) { if (!(first instanceof IElement && second instanceof IElement)) { return null; } IElement firstElem = (IElement) first; IElement secondElem = (IElement) second; ChemObjectDifference coDiff = new ChemObjectDifference("ElementDiff"); coDiff.addChild(StringDifference.construct("S", firstElem.getSymbol(), secondElem.getSymbol())); coDiff.addChild(StringDifference.construct("ID", firstElem.getID(), secondElem.getID())); coDiff.addChild(IntegerDifference.construct("AN", firstElem.getAtomicNumber(), secondElem.getAtomicNumber())); coDiff.addChild(ChemObjectDiff.difference(first, second)); if (coDiff.childCount() > 0) { return coDiff; } else { return null; } } private  ElementDiff(); static String diff(IChemObject first, IChemObject second); static IDifference difference(IChemObject first, IChemObject second);  }
@Test public void testDifference() { IElement element1 = mock(IElement.class); IElement element2 = mock(IElement.class); when(element1.getSymbol()).thenReturn("H"); when(element2.getSymbol()).thenReturn("C"); IDifference difference = ElementDiff.difference(element1, element2); Assert.assertNotNull(difference); }