DbTableMetadata { public DbColumnMetadata getColumn(String name) { DbColumnMetadata column = columnsByName.get(name); if (column == null) { throw new IllegalArgumentException("Column named '" + name + "' does not exist in table '" + this.name + "'"); } return column; } DbTableMetadata(TableFQName name, DbColumnMetadata[] columns); TableFQName getName(); DbColumnMetadata[] getColumns(); String[] getColumnNames(); DbColumnMetadata[] getPkColumns(); boolean hasColumn(String name); DbColumnMetadata getColumn(String name);  }
@Test public void testGetColumn() { DbColumnMetadata c1 = new DbColumnMetadata("c1", Types.INTEGER, false, false); DbColumnMetadata c2 = new DbColumnMetadata("c2", Types.VARCHAR, false, false); DbTableMetadata md = new DbTableMetadata(TableFQName.forName("x"), new DbColumnMetadata[]{c1, c2}); assertSame(c1, md.getColumn("c1")); assertSame(c2, md.getColumn("c2")); }
@Test public void testGetColumn_Unknown() { DbColumnMetadata c1 = new DbColumnMetadata("c1", Types.INTEGER, false, false); DbTableMetadata md = new DbTableMetadata(TableFQName.forName("x"), new DbColumnMetadata[]{c1}); assertThrows(IllegalArgumentException.class, () -> md.getColumn("no_such_column")); }