use of com.quorum.tessera.data.DataSourceFactory in project tessera by ConsenSys.
the class PrivacyGroupDAOProviderTest method provides.
@Test
public void provides() {
try (var mockedConfigFactory = mockStatic(ConfigFactory.class);
var mockedDataSourceFactory = mockStatic(DataSourceFactory.class);
var mockedPersistence = mockStatic(Persistence.class)) {
mockedPersistence.when(() -> Persistence.createEntityManagerFactory(anyString(), anyMap())).thenReturn(mock(EntityManagerFactory.class));
Config config = mock(Config.class);
JdbcConfig jdbcConfig = mock(JdbcConfig.class);
when(jdbcConfig.isAutoCreateTables()).thenReturn(autocreateTables);
when(config.getJdbcConfig()).thenReturn(jdbcConfig);
ConfigFactory configFactory = mock(ConfigFactory.class);
when(configFactory.getConfig()).thenReturn(config);
mockedConfigFactory.when(ConfigFactory::create).thenReturn(configFactory);
mockedDataSourceFactory.when(DataSourceFactory::create).thenReturn(mock(DataSourceFactory.class));
PrivacyGroupDAO result = PrivacyGroupDAOProvider.provider();
assertThat(result).isNotNull().isExactlyInstanceOf(PrivacyGroupDAOImpl.class);
mockedPersistence.verify(() -> Persistence.createEntityManagerFactory(anyString(), anyMap()));
mockedPersistence.verifyNoMoreInteractions();
PrivacyGroupDAOProvider.provider();
}
}
use of com.quorum.tessera.data.DataSourceFactory in project tessera by ConsenSys.
the class StagingEntityDAOProviderTest method provider.
@Test
public void provider() {
try (var mockedConfigFactory = mockStatic(ConfigFactory.class);
var mockedDataSourceFactory = mockStatic(DataSourceFactory.class);
var mockedPersistence = mockStatic(Persistence.class)) {
mockedPersistence.when(() -> Persistence.createEntityManagerFactory(anyString(), anyMap())).thenReturn(mock(EntityManagerFactory.class));
Config config = mock(Config.class);
JdbcConfig jdbcConfig = mock(JdbcConfig.class);
when(jdbcConfig.isAutoCreateTables()).thenReturn(autocreateTables);
when(config.getJdbcConfig()).thenReturn(jdbcConfig);
ConfigFactory configFactory = mock(ConfigFactory.class);
when(configFactory.getConfig()).thenReturn(config);
mockedConfigFactory.when(ConfigFactory::create).thenReturn(configFactory);
mockedDataSourceFactory.when(DataSourceFactory::create).thenReturn(mock(DataSourceFactory.class));
StagingEntityDAO result = StagingEntityDAOProvider.provider();
assertThat(result).isNotNull().isExactlyInstanceOf(StagingEntityDAOImpl.class);
mockedPersistence.verify(() -> Persistence.createEntityManagerFactory(anyString(), anyMap()));
mockedPersistence.verifyNoMoreInteractions();
}
}
use of com.quorum.tessera.data.DataSourceFactory in project tessera by ConsenSys.
the class EncryptedTransactionDAOProviderTest method provides.
@Test
public void provides() {
try (var mockedConfigFactory = mockStatic(ConfigFactory.class);
var mockedDataSourceFactory = mockStatic(DataSourceFactory.class);
var mockedPersistence = mockStatic(Persistence.class)) {
mockedPersistence.when(() -> Persistence.createEntityManagerFactory(anyString(), anyMap())).thenReturn(mock(EntityManagerFactory.class));
Config config = mock(Config.class);
JdbcConfig jdbcConfig = mock(JdbcConfig.class);
when(jdbcConfig.isAutoCreateTables()).thenReturn(autocreateTables);
when(config.getJdbcConfig()).thenReturn(jdbcConfig);
ConfigFactory configFactory = mock(ConfigFactory.class);
when(configFactory.getConfig()).thenReturn(config);
mockedConfigFactory.when(ConfigFactory::create).thenReturn(configFactory);
mockedDataSourceFactory.when(DataSourceFactory::create).thenReturn(mock(DataSourceFactory.class));
EncryptedTransactionDAO result = EncryptedTransactionDAOProvider.provider();
assertThat(result).isNotNull().isExactlyInstanceOf(EncryptedTransactionDAOImpl.class);
mockedPersistence.verify(() -> Persistence.createEntityManagerFactory(anyString(), anyMap()));
mockedPersistence.verifyNoMoreInteractions();
EncryptedTransactionDAOProvider.provider();
}
}
use of com.quorum.tessera.data.DataSourceFactory in project tessera by ConsenSys.
the class DataSourceFactoryProviderTest method provider.
@Test
public void provider() {
DataSourceFactory dataSourceFactory = DataSourceFactoryProvider.provider();
assertThat(dataSourceFactory).isNotNull().isExactlyInstanceOf(HikariDataSourceFactory.class);
}
use of com.quorum.tessera.data.DataSourceFactory in project tessera by ConsenSys.
the class DataSourceFactoryProviderTest method loadFromModuleInfo.
@Test
public void loadFromModuleInfo() {
DataSourceFactory dataSourceFactory = ServiceLoader.load(DataSourceFactory.class).findFirst().get();
assertThat(dataSourceFactory).isNotNull().isExactlyInstanceOf(HikariDataSourceFactory.class);
}
Aggregations