DataSourceManager implements AutoCloseable { public DataSource getDataSource(final ScalingDataSourceConfiguration dataSourceConfig) { if (cachedDataSources.containsKey(dataSourceConfig)) { return cachedDataSources.get(dataSourceConfig); } synchronized (cachedDataSources) { if (cachedDataSources.containsKey(dataSourceConfig)) { return cachedDataSources.get(dataSourceConfig); } DataSourceWrapper result = dataSourceFactory.newInstance(dataSourceConfig); cachedDataSources.put(dataSourceConfig, result); return result; } } DataSourceManager(final List<SyncConfiguration> syncConfigs); DataSource getDataSource(final ScalingDataSourceConfiguration dataSourceConfig); @Override void close();  }
@Test public void assertGetDataSource() { DataSourceManager dataSourceManager = new DataSourceManager(); DataSource actual = dataSourceManager.getDataSource(syncConfigurations.get(0).getDumperConfiguration().getDataSourceConfiguration()); assertThat(actual, instanceOf(DataSourceWrapper.class)); }