### Question:
JdbcMetadataHandler extends MetadataHandler { @Override public ListSchemasResponse doListSchemaNames(final BlockAllocator blockAllocator, final ListSchemasRequest listSchemasRequest) { try (Connection connection = jdbcConnectionFactory.getConnection(getCredentialProvider())) { LOGGER.info("{}: List schema names for Catalog {}", listSchemasRequest.getQueryId(), listSchemasRequest.getCatalogName()); return new ListSchemasResponse(listSchemasRequest.getCatalogName(), listDatabaseNames(connection)); } catch (SQLException sqlException) { throw new RuntimeException(sqlException.getErrorCode() + ": " + sqlException.getMessage()); } } protected  JdbcMetadataHandler(); protected  JdbcMetadataHandler(final DatabaseConnectionConfig databaseConnectionConfig, final JdbcConnectionFactory jdbcConnectionFactory); @VisibleForTesting protected  JdbcMetadataHandler(final DatabaseConnectionConfig databaseConnectionConfig, final AWSSecretsManager secretsManager,
            final AmazonAthena athena, final JdbcConnectionFactory jdbcConnectionFactory); @Override ListSchemasResponse doListSchemaNames(final BlockAllocator blockAllocator, final ListSchemasRequest listSchemasRequest); @Override ListTablesResponse doListTables(final BlockAllocator blockAllocator, final ListTablesRequest listTablesRequest); @Override GetTableResponse doGetTable(final BlockAllocator blockAllocator, final GetTableRequest getTableRequest); abstract Schema getPartitionSchema(final String catalogName); @Override abstract void getPartitions(
            final BlockWriter blockWriter,
            final GetTableLayoutRequest request, QueryStatusChecker queryStatusChecker); @Override abstract GetSplitsResponse doGetSplits(BlockAllocator blockAllocator, GetSplitsRequest getSplitsRequest);  }### Answer:
@Test(expected = RuntimeException.class) public void doListSchemaNamesSQLException() throws SQLException { Mockito.when(this.connection.getMetaData().getSchemas()).thenThrow(new SQLException()); this.jdbcMetadataHandler.doListSchemaNames(this.blockAllocator, new ListSchemasRequest(this.federatedIdentity, "testQueryId", "testCatalog")); }
@Test public void doListSchemaNames() throws SQLException { String[] schema = {"TABLE_SCHEM"}; Object[][] values = {{"testDB"}, {"testdb2"}, {"information_schema"}}; String[] expected = {"testDB", "testdb2"}; AtomicInteger rowNumber = new AtomicInteger(-1); ResultSet resultSet = mockResultSet(schema, values, rowNumber); Mockito.when(connection.getMetaData().getSchemas()).thenReturn(resultSet); ListSchemasResponse listSchemasResponse = this.jdbcMetadataHandler.doListSchemaNames(this.blockAllocator, new ListSchemasRequest(this.federatedIdentity, "testQueryId", "testCatalog")); Assert.assertArrayEquals(expected, listSchemasResponse.getSchemas().toArray()); }