MetaDataManager { public TableMetaData getTableMetaData(final String tableName) { if (!tableMetaDataMap.containsKey(tableName)) { try { TableMetaDataLoader.load(dataSource, tableName, "").ifPresent(tableMetaData -> tableMetaDataMap.put(tableName, tableMetaData)); } catch (final SQLException ex) { throw new RuntimeException(String.format("Load metaData for table %s failed", tableName), ex); } } return tableMetaDataMap.get(tableName); }  TableMetaData getTableMetaData(final String tableName);  }
@Test public void assertGetTableMetaData() { MetaDataManager metaDataManager = new MetaDataManager(dataSource); assertColumnMetaData(metaDataManager.getTableMetaData(TEST_TABLE)); assertPrimaryKeys(metaDataManager.getTableMetaData(TEST_TABLE).getPrimaryKeyColumns()); }
@Test(expected = RuntimeException.class) public void assertGetTableMetaDataFailure() throws SQLException { when(dataSource.getConnection()).thenThrow(new SQLException("")); new MetaDataManager(dataSource).getTableMetaData(TEST_TABLE); }