AtomContainerDiff { public static String diff(IChemObject first, IChemObject second) { IDifference diff = difference(first, second); if (diff == null) { return ""; } else { return diff.toString(); } } private  AtomContainerDiff(); static String diff(IChemObject first, IChemObject second); static IDifference difference(IChemObject first, IChemObject second);  }
@Test public void testMatchAgainstItself() { IAtomContainer container = mock(IAtomContainer.class); when(container.getElectronContainerCount()).thenReturn(1); when(container.getElectronContainer(0)).thenReturn(mock(IBond.class)); String result = AtomContainerDiff.diff(container, container); assertZeroLength(result); }
@Test public void testDiff() { IAtom carbon = mock(IAtom.class); IAtom oxygen = mock(IAtom.class); when(carbon.getSymbol()).thenReturn("C"); when(oxygen.getSymbol()).thenReturn("O"); IBond b1 = mock(IBond.class); IBond b2 = mock(IBond.class); when(b1.getOrder()).thenReturn(IBond.Order.SINGLE); when(b2.getOrder()).thenReturn(IBond.Order.DOUBLE); when(b1.getAtomCount()).thenReturn(2); when(b2.getAtomCount()).thenReturn(2); when(b1.getBegin()).thenReturn(carbon); when(b1.getEnd()).thenReturn(carbon); when(b2.getBegin()).thenReturn(carbon); when(b2.getEnd()).thenReturn(oxygen); IAtomContainer container1 = mock(IAtomContainer.class); IAtomContainer container2 = mock(IAtomContainer.class); when(container1.getElectronContainerCount()).thenReturn(1); when(container2.getElectronContainerCount()).thenReturn(1); when(container1.getElectronContainer(0)).thenReturn(b1); when(container2.getElectronContainer(0)).thenReturn(b2); String result = AtomContainerDiff.diff(container1, container2); Assert.assertNotNull(result); Assert.assertNotSame(0, result.length()); assertContains(result, "AtomContainerDiff"); assertContains(result, "BondDiff"); assertContains(result, "SINGLE/DOUBLE"); assertContains(result, "AtomDiff"); assertContains(result, "C/O"); }