/** * Test constructor to create a non-empty database. * * @throws BioException if iterator fails. */ public void testNonEmptyConstructor() throws BioException { SimpleSymbolPropertyTableDB dbInit = new SimpleSymbolPropertyTableDB(); SymbolPropertyTable t1 = new SimpleSymbolPropertyTable(ProteinTools.getAlphabet(), "protein"); SymbolPropertyTable t2 = new SimpleSymbolPropertyTable(DNATools.getDNA(), "dna"); dbInit.addTable(t1); dbInit.addTable(t2); SymbolPropertyTableDB db = new SimpleSymbolPropertyTableDB(dbInit.tableIterator()); assertEquals("Database has wrong number of tables.", 2, db.numTables()); SymbolPropertyTableIterator iterator = db.tableIterator(); ArrayList tables = new ArrayList(2); while (iterator.hasNext()) { tables.add(iterator.nextTable()); } assertEquals("Iterator returned wrong number of tables.", 2, tables.size()); assertEquals("Iterator returned wrong table.", t1, tables.get(0)); assertEquals("Iterator returned wrong table.", t2, tables.get(1)); }
/** Test constructor to create an empty database. */ public void testEmptyConstructor() { SymbolPropertyTableDB db = new SimpleSymbolPropertyTableDB(); assertEquals("Database is not empty.", 0, db.numTables()); assertFalse("Database does not return an empty iterator.", db.tableIterator().hasNext()); }