Search in sources :

Example 1 with PostgressStatements

use of org.eclipse.dataspaceconnector.sql.policy.store.PostgressStatements in project DataSpaceConnector by eclipse-dataspaceconnector.

the class SqlPolicyStoreTest method setUp.

@BeforeEach
void setUp() throws SQLException, IOException {
    var transactionContext = new NoopTransactionContext();
    DataSourceRegistry dataSourceRegistry = mock(DataSourceRegistry.class);
    var jdbcDataSource = new JdbcDataSource();
    jdbcDataSource.setURL("jdbc:h2:mem:");
    // do not actually close
    connection = spy(jdbcDataSource.getConnection());
    doNothing().when(connection).close();
    var datasourceMock = mock(DataSource.class);
    when(datasourceMock.getConnection()).thenReturn(connection);
    when(dataSourceRegistry.resolve(DATASOURCE_NAME)).thenReturn(datasourceMock);
    sqlPolicyStore = new SqlPolicyStore(dataSourceRegistry, DATASOURCE_NAME, transactionContext, new TypeManager(), new PostgressStatements());
    var schema = Files.readString(Paths.get("./docs/schema.sql"));
    transactionContext.execute(() -> SqlQueryExecutor.executeQuery(connection, schema));
}
Also used : PostgressStatements(org.eclipse.dataspaceconnector.sql.policy.store.PostgressStatements) DataSourceRegistry(org.eclipse.dataspaceconnector.spi.transaction.datasource.DataSourceRegistry) SqlPolicyStore(org.eclipse.dataspaceconnector.sql.policy.store.SqlPolicyStore) JdbcDataSource(org.h2.jdbcx.JdbcDataSource) TypeManager(org.eclipse.dataspaceconnector.spi.types.TypeManager) NoopTransactionContext(org.eclipse.dataspaceconnector.spi.transaction.NoopTransactionContext) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

NoopTransactionContext (org.eclipse.dataspaceconnector.spi.transaction.NoopTransactionContext)1 DataSourceRegistry (org.eclipse.dataspaceconnector.spi.transaction.datasource.DataSourceRegistry)1 TypeManager (org.eclipse.dataspaceconnector.spi.types.TypeManager)1 PostgressStatements (org.eclipse.dataspaceconnector.sql.policy.store.PostgressStatements)1 SqlPolicyStore (org.eclipse.dataspaceconnector.sql.policy.store.SqlPolicyStore)1 JdbcDataSource (org.h2.jdbcx.JdbcDataSource)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1