ElectronContainerDiff { public static IDifference difference(IChemObject first, IChemObject second) { if (!(first instanceof IElectronContainer && second instanceof IElectronContainer)) { return null; } IElectronContainer firstEC = (IElectronContainer) first; IElectronContainer secondEC = (IElectronContainer) second; IDifferenceList totalDiff = new ChemObjectDifference("ElectronContainerDiff"); totalDiff.addChild(IntegerDifference.construct("eCount", firstEC.getElectronCount(), secondEC.getElectronCount())); totalDiff.addChild(ChemObjectDiff.difference(first, second)); if (totalDiff.childCount() > 0) { return totalDiff; } else { return null; } } private  ElectronContainerDiff(); static String diff(IChemObject first, IChemObject second); static IDifference difference(IChemObject first, IChemObject second);  }
@Test public void testDifference() { IElectronContainer ec1 = mock(IElectronContainer.class); IElectronContainer ec2 = mock(IElectronContainer.class); when(ec1.getElectronCount()).thenReturn(2); when(ec2.getElectronCount()).thenReturn(3); IDifference difference = ElectronContainerDiff.difference(ec1, ec2); Assert.assertNotNull(difference); }