IsotopeDiff { public static IDifference difference(IChemObject first, IChemObject second) { if (!(first instanceof IIsotope && second instanceof IIsotope)) { return null; } IIsotope firstElem = (IIsotope) first; IIsotope secondElem = (IIsotope) second; ChemObjectDifference totalDiff = new ChemObjectDifference("IsotopeDiff"); totalDiff.addChild(IntegerDifference.construct("MN", firstElem.getMassNumber(), secondElem.getMassNumber())); totalDiff.addChild(DoubleDifference.construct("EM", firstElem.getExactMass(), secondElem.getExactMass())); totalDiff.addChild(DoubleDifference.construct("AB", firstElem.getNaturalAbundance(), secondElem.getNaturalAbundance())); totalDiff.addChild(ElementDiff.difference(first, second)); if (totalDiff.childCount() > 0) { return totalDiff; } else { return null; } } private  IsotopeDiff(); static String diff(IChemObject first, IChemObject second); static IDifference difference(IChemObject first, IChemObject second);  }
@Test public void testDifference() { IIsotope element1 = mock(IIsotope.class); IIsotope element2 = mock(IIsotope.class); when(element1.getSymbol()).thenReturn("H"); when(element2.getSymbol()).thenReturn("C"); IDifference difference = IsotopeDiff.difference(element1, element2); Assert.assertNotNull(difference); }