@BeforeClass public static void setUp() { setTestObjectBuilder(new ITestObjectBuilder() { @Override public IChemObject newTestObject() { return new Mapping(new Atom(), new Atom()); } }); }
/** * Clones this <code>Reaction</code> and its content. * * @return The cloned object */ @Override public Object clone() throws CloneNotSupportedException { Reaction clone = (Reaction) super.clone(); // clone the reactants, products and agents clone.reactants = (IAtomContainerSet) reactants.clone(); clone.agents = (IAtomContainerSet) agents.clone(); clone.products = (IAtomContainerSet) products.clone(); // create a Map of corresponding atoms for molecules (key: original Atom, // value: clone Atom) Map<IAtom, IAtom> atomatom = new Hashtable<IAtom, IAtom>(); for (int i = 0; i < reactants.getAtomContainerCount(); ++i) { IAtomContainer mol = reactants.getAtomContainer(i); IAtomContainer mol2 = clone.reactants.getAtomContainer(i); for (int j = 0; j < mol.getAtomCount(); ++j) atomatom.put(mol.getAtom(j), mol2.getAtom(j)); } // clone the maps clone.map = new Mapping[map.length]; for (int f = 0; f < mappingCount; f++) { clone.map[f] = new Mapping(atomatom.get(map[f].getChemObject(0)), atomatom.get(map[f].getChemObject(1))); } return clone; }
/** * Clones this <code>Reaction</code> and its content. * * @return The cloned object */ @Override public Object clone() throws CloneNotSupportedException { Reaction clone = (Reaction) super.clone(); // clone the reactants, products and agents clone.reactants = (IAtomContainerSet) reactants.clone(); clone.agents = (IAtomContainerSet) agents.clone(); clone.products = (IAtomContainerSet) products.clone(); // create a Map of corresponding atoms for molecules (key: original Atom, // value: clone Atom) Map<IAtom, IAtom> atomatom = new Hashtable<IAtom, IAtom>(); for (int i = 0; i < reactants.getAtomContainerCount(); ++i) { IAtomContainer mol = reactants.getAtomContainer(i); IAtomContainer mol2 = clone.reactants.getAtomContainer(i); for (int j = 0; j < mol.getAtomCount(); ++j) atomatom.put(mol.getAtom(j), mol2.getAtom(j)); } // clone the maps clone.map = new Mapping[map.length]; for (int f = 0; f < mappingCount; f++) { clone.map[f] = new Mapping(atomatom.get(map[f].getChemObject(0)), atomatom.get(map[f].getChemObject(1))); } return clone; }
@Override public IChemObject newTestObject() { return new Mapping(new Atom(), new Atom()); } });
@Test public void testMapping_IChemObject_IChemObject() { IMapping mapping = new Mapping(newChemObject().getBuilder().newInstance(IAtom.class), newChemObject() .getBuilder().newInstance(IAtom.class)); Assert.assertNotNull(mapping); }