DataSourceConnectorFactory implements IConnectorFactory<JdbcConnector> { DataSource connectorDataSource(String id) { DataSource ds = dataSources.get(id); if (ds == null) { throw new LmRuntimeException("Unknown connector ID: " + id + "; available IDs: " + dataSources.keySet()); } return ds; } DataSourceConnectorFactory(Map<String, DataSource> dataSources); @Override JdbcConnector createConnector(String id);  }
@Test public void testConnectorDataSource() { assertSame(ds1, factory.connectorDataSource("ds1")); assertSame(ds2, factory.connectorDataSource("ds2")); }
@Test public void testConnectorDataSource_Missing() { assertThrows(LmRuntimeException.class, () -> factory.connectorDataSource("ds3")); }