### Question:
JDBCUtil { public static Map<String, JdbcMetadataHandler> createJdbcMetadataHandlerMap(final Map<String, String> properties) { ImmutableMap.Builder<String, JdbcMetadataHandler> metadataHandlerMap = ImmutableMap.builder(); final String functionName = Validate.notBlank(properties.get(LAMBDA_FUNCTION_NAME_PROPERTY), "Lambda function name not present in environment."); List<DatabaseConnectionConfig> databaseConnectionConfigs = new DatabaseConnectionConfigBuilder().properties(properties).build(); if (databaseConnectionConfigs.isEmpty()) { throw new RuntimeException("At least one connection string required."); } boolean defaultPresent = false; for (DatabaseConnectionConfig databaseConnectionConfig : databaseConnectionConfigs) { JdbcMetadataHandler jdbcMetadataHandler = createJdbcMetadataHandler(databaseConnectionConfig); metadataHandlerMap.put(databaseConnectionConfig.getCatalog(), jdbcMetadataHandler); if (DatabaseConnectionConfigBuilder.DEFAULT_CONNECTION_STRING_PROPERTY.equals(databaseConnectionConfig.getCatalog())) { metadataHandlerMap.put(DEFAULT_CATALOG_PREFIX + functionName, jdbcMetadataHandler); defaultPresent = true; } } if (!defaultPresent) { throw new RuntimeException("Must provide connection parameters for default database instance " + DatabaseConnectionConfigBuilder.DEFAULT_CONNECTION_STRING_PROPERTY); } return metadataHandlerMap.build(); } private  JDBCUtil(); static DatabaseConnectionConfig getSingleDatabaseConfigFromEnv(final JdbcConnectionFactory.DatabaseEngine databaseEngine); static Map<String, JdbcMetadataHandler> createJdbcMetadataHandlerMap(final Map<String, String> properties); static Map<String, JdbcRecordHandler> createJdbcRecordHandlerMap(final Map<String, String> properties);  }### Answer:
@Test public void createJdbcMetadataHandlerMap() { Map<String, JdbcMetadataHandler> catalogs = JDBCUtil.createJdbcMetadataHandlerMap(ImmutableMap.<String, String>builder() .put("testCatalog1_connection_string", CONNECTION_STRING1) .put("testCatalog2_connection_string", CONNECTION_STRING2) .put("default", CONNECTION_STRING2) .put("AWS_LAMBDA_FUNCTION_NAME", "functionName") .build()); Assert.assertEquals(4, catalogs.size()); Assert.assertEquals(catalogs.get("testCatalog1").getClass(), MySqlMetadataHandler.class); Assert.assertEquals(catalogs.get("testCatalog2").getClass(), PostGreSqlMetadataHandler.class); Assert.assertEquals(catalogs.get("lambda:functionName").getClass(), PostGreSqlMetadataHandler.class); }
@Test(expected = RuntimeException.class) public void createJdbcMetadataHandlerEmptyConnectionStrings() { JDBCUtil.createJdbcMetadataHandlerMap(Collections.emptyMap()); }
@Test(expected = RuntimeException.class) public void createJdbcMetadataHandlerNoDefault() { JDBCUtil.createJdbcMetadataHandlerMap(ImmutableMap.<String, String>builder() .put("testCatalog1_connection_string", CONNECTION_STRING1) .put("testCatalog2_connection_string", CONNECTION_STRING2) .build()); }