Skip to content

Commit

Permalink
refactor: separate sql stores from datasources (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndr-brt authored Aug 7, 2024
1 parent d8026fe commit fdeb598
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,19 @@
import org.eclipse.edc.spi.types.TypeManager;
import org.eclipse.edc.sql.QueryExecutor;
import org.eclipse.edc.sql.bootstrapper.SqlSchemaBootstrapper;
import org.eclipse.edc.sql.configuration.DataSourceName;
import org.eclipse.edc.transaction.datasource.spi.DataSourceRegistry;
import org.eclipse.edc.transaction.spi.TransactionContext;

@Provides(FederatedCatalogCache.class)
@Extension(value = "SQL federated catalog cache")
public class SqlFederatedCatalogCacheExtension implements ServiceExtension {

@Deprecated(since = "0.8.1")
@Setting
public static final String DATASOURCE_NAME_SETTING = "edc.datasource.federatedcatalog.name";
public static final String DATASOURCE_SETTING_NAME = "edc.datasource.federatedcatalog.name";
@Setting(value = "The datasource to be used", defaultValue = DataSourceRegistry.DEFAULT_DATASOURCE)
public static final String DATASOURCE_NAME = "edc.sql.store.federatedcatalog.datasource";

@Inject
private DataSourceRegistry dataSourceRegistry;
Expand Down Expand Up @@ -70,6 +74,6 @@ private FederatedCatalogCacheStatements getStatementImpl() {
}

private String getDataSourceName(ServiceExtensionContext context) {
return context.getConfig().getString(DATASOURCE_NAME_SETTING, DataSourceRegistry.DEFAULT_DATASOURCE);
return DataSourceName.getDataSourceName(DATASOURCE_NAME, DATASOURCE_SETTING_NAME, context.getConfig(), context.getMonitor());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
import org.eclipse.edc.spi.system.ServiceExtensionContext;
import org.eclipse.edc.spi.system.configuration.Config;
import org.eclipse.edc.spi.types.TypeManager;
import org.eclipse.edc.transaction.datasource.spi.DataSourceRegistry;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.edc.catalog.store.sql.SqlFederatedCatalogCacheExtension.DATASOURCE_NAME_SETTING;
import static org.eclipse.edc.catalog.store.sql.SqlFederatedCatalogCacheExtension.DATASOURCE_NAME;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -57,6 +57,6 @@ void shouldInitializeTheStore(SqlFederatedCatalogCacheExtension extension, Servi
assertThat(service).isInstanceOf(SqlFederatedCatalogCache.class);

verify(typeManager).registerTypes(Catalog.class, Dataset.class);
verify(config).getString(DATASOURCE_NAME_SETTING, DataSourceRegistry.DEFAULT_DATASOURCE);
verify(config).getString(eq(DATASOURCE_NAME), any());
}
}

0 comments on commit fdeb598

Please sign in to comment.