/** * Compare two {@link IChemObject} classes and return the difference as a {@link String}. * * @param first the first of the two classes to compare * @param second the second of the two classes to compare * @return a {@link String} representation of the difference between the first and second {@link IChemObject}. */ public static String diff(IChemObject first, IChemObject second) { IDifference diff = difference(first, second); if (diff == null) { return ""; } else { return diff.toString(); } }
@Test public void testDifference() { IAtom carbon = mock(IAtom.class); IAtom oxygen = mock(IAtom.class); when(carbon.getSymbol()).thenReturn("C"); when(oxygen.getSymbol()).thenReturn("O"); IBond bond1 = mock(IBond.class); IBond bond2 = mock(IBond.class); when(bond1.getOrder()).thenReturn(IBond.Order.SINGLE); when(bond2.getOrder()).thenReturn(IBond.Order.DOUBLE); when(bond1.getAtomCount()).thenReturn(2); when(bond2.getAtomCount()).thenReturn(2); when(bond1.getBegin()).thenReturn(carbon); when(bond1.getEnd()).thenReturn(carbon); when(bond2.getBegin()).thenReturn(carbon); when(bond2.getEnd()).thenReturn(oxygen); bond1.setOrder(IBond.Order.SINGLE); bond2.setOrder(IBond.Order.DOUBLE); IDifference difference = BondDiff.difference(bond1, bond2); Assert.assertNotNull(difference); } }
@Test public void testDifference() { IAtom carbon = mock(IAtom.class); IAtom oxygen = mock(IAtom.class); when(carbon.getSymbol()).thenReturn("C"); when(carbon.getSymbol()).thenReturn("H"); IBond bond1 = mock(IBond.class); IBond bond2 = mock(IBond.class); when(bond1.getOrder()).thenReturn(IBond.Order.SINGLE); when(bond2.getOrder()).thenReturn(IBond.Order.DOUBLE); when(bond1.getAtomCount()).thenReturn(2); when(bond2.getAtomCount()).thenReturn(2); when(bond1.getBegin()).thenReturn(carbon); when(bond1.getEnd()).thenReturn(carbon); when(bond2.getBegin()).thenReturn(carbon); when(bond2.getEnd()).thenReturn(oxygen); bond1.setOrder(IBond.Order.SINGLE); bond2.setOrder(IBond.Order.DOUBLE); IDifference difference = BondDiff.difference(bond1, bond2); Assert.assertNotNull(difference); } }
if (firstAC.getElectronContainer(i) instanceof IBond && secondAC.getElectronContainer(i) instanceof IBond) { totalDiff.addChild(BondDiff.difference(firstAC.getElectronContainer(i), secondAC.getElectronContainer(i))); } else if (firstAC.getElectronContainer(i) instanceof ILonePair