/** * Gets the allAtomTypes attribute of the AtomTypeFactory object. * * @return The allAtomTypes value */ public IAtomType[] getAllAtomTypes() { logger.debug("Returning list of size: ", getSize()); return (IAtomType[]) atomTypes.values().toArray(new IAtomType[atomTypes.size()]); }
/** * Gets the allAtomTypes attribute of the AtomTypeFactory object. * * @return The allAtomTypes value */ public IAtomType[] getAllAtomTypes() { logger.debug("Returning list of size: ", getSize()); return (IAtomType[]) atomTypes.values().toArray(new IAtomType[atomTypes.size()]); }
@Test public void testAtomTypeFactory() { Assert.assertNotNull(atf); Assert.assertNotSame(atf.getSize(), 0); }
@Test public void testGetInstance_InputStream_String_IChemObjectBuilder() throws Exception { String configFile = "org/openscience/cdk/config/data/structgen_atomtypes.xml"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(configFile); AtomTypeFactory atf = AtomTypeFactory.getInstance(ins, "xml", new ChemObject().getBuilder()); Assert.assertNotNull(atf); Assert.assertNotSame(0, atf.getSize()); }
@Test public void testGetSize() throws Exception { AtomTypeFactory atf = AtomTypeFactory.getInstance(new ChemObject().getBuilder()); Assert.assertNotSame(0, atf.getSize()); }
@Test public void testGetInstance_String_IChemObjectBuilder() throws Exception { String configFile = "org/openscience/cdk/config/data/structgen_atomtypes.xml"; AtomTypeFactory atf = AtomTypeFactory.getInstance(configFile, new ChemObject().getBuilder()); Assert.assertNotNull(atf); Assert.assertNotSame(0, atf.getSize()); }
/** * Test if all elements up to and including Uranium have atom types. * * @throws Exception */ @Test public void testAllElementsRepresented() throws Exception { AtomTypeFactory factory = AtomTypeFactory.getInstance("org/openscience/cdk/dict/data/cdk-atom-types.owl", SilentChemObjectBuilder.getInstance()); Assert.assertTrue("Could not read the atom types", factory.getSize() != 0); String errorMessage = "Elements without atom type(s) defined in the XML:"; final int testUptoAtomicNumber = 36; // TODO: 92 ? int elementsMissingTypes = 0; for (int i = 1; i < testUptoAtomicNumber; i++) { String symbol = PeriodicTable.getSymbol(i); IAtomType[] expectedTypes = factory.getAtomTypes(symbol); if (expectedTypes.length == 0) { errorMessage += " " + symbol; elementsMissingTypes++; } } Assert.assertEquals(errorMessage, 0, elementsMissingTypes); }