### Question:
Catalog { public int getTableId(String name) throws NoSuchElementException { for (Map.Entry<Integer, Table> entry : tables.entrySet()) { if(entry.getValue().tableName.equals(name)){ return entry.getKey(); } } throw new NoSuchElementException(); } Catalog(); void addTable(DbFile file, String name, String pkeyField); void addTable(DbFile file, String name); void addTable(DbFile file); int getTableId(String name); TupleDesc getTupleDesc(int tableid); DbFile getDbFile(int tableid); String getPrimaryKey(int tableid); Iterator<Integer> tableIdIterator(); String getTableName(int id); void clear(); void loadSchema(String catalogFile);  }### Answer:
@Test public void getTableId() { assertEquals(-2, Database.getCatalog().getTableId(name)); assertEquals(-1, Database.getCatalog().getTableId(nameThisTestRun)); try { Database.getCatalog().getTableId(null); Assert.fail("Should not find table with null name"); } catch (NoSuchElementException e) { } try { Database.getCatalog().getTableId("foo"); Assert.fail("Should not find table with name foo"); } catch (NoSuchElementException e) { } }