private static void serializeElectronContainerFields(Model model, Resource rdfBond, IElectronContainer bond) { serializeChemObjectFields(model, rdfBond, bond); if (bond.getElectronCount() != null) model.add(rdfBond, CDK.HASELECTRONCOUNT, bond.getElectronCount().toString()); }
private static void serializeElectronContainerFields(Model model, Resource rdfBond, IElectronContainer bond) { serializeChemObjectFields(model, rdfBond, bond); if (bond.getElectronCount() != null) model.add(rdfBond, CDK.HASELECTRONCOUNT, bond.getElectronCount().toString()); }
@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); } }
/** * Compare two {@link IChemObject} classes and return the difference as an {@link IDifference}. * * @param first the first of the two classes to compare * @param second the second of the two classes to compare * @return an {@link IDifference} representation of the difference between the first and second {@link IChemObject}. */ 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; } }
@Test public void testDiff() { IElectronContainer ec1 = mock(IElectronContainer.class); IElectronContainer ec2 = mock(IElectronContainer.class); when(ec1.getElectronCount()).thenReturn(2); when(ec2.getElectronCount()).thenReturn(3); String result = ElectronContainerDiff.diff(ec1, ec2); Assert.assertNotNull(result); Assert.assertNotSame(0, result.length()); assertContains(result, "ElectronContainerDiff"); assertContains(result, "eCount"); assertContains(result, "2/3"); }
/** * The electron count of an LP is always exactly 2. */ @Test @Override public void testSetElectronCount_Integer() { IElectronContainer ec = (IElectronContainer) newChemObject(); ec.setElectronCount(3); Assert.assertEquals(2, ec.getElectronCount().intValue()); ec.setElectronCount(null); Assert.assertEquals(2, ec.getElectronCount().intValue()); }
/** * The electron count of a single electron is always exactly 1. */ @Test @Override public void testSetElectronCount_Integer() { IElectronContainer ec = (IElectronContainer) newChemObject(); ec.setElectronCount(3); Assert.assertEquals(1, ec.getElectronCount().intValue()); ec.setElectronCount(null); Assert.assertEquals(1, ec.getElectronCount().intValue()); } }
@Test public void testSetElectronCount_Integer() { IElectronContainer ec = (IElectronContainer) newChemObject(); ec.setElectronCount(3); Assert.assertEquals(3, ec.getElectronCount().intValue()); }
@Test public void testElectronContainer() { IElectronContainer ec = new ElectronContainer(); Assert.assertNotNull(ec); Assert.assertEquals(0, ec.getElectronCount().intValue()); }
@Test public void testDebugElectronContainer() { IElectronContainer ec = new DebugElectronContainer(); Assert.assertNotNull(ec); Assert.assertEquals(0, ec.getElectronCount().intValue()); } }
@Test public void testElectronContainer() { IElectronContainer ec = new ElectronContainer(); Assert.assertNotNull(ec); Assert.assertEquals(0, ec.getElectronCount().intValue()); }