use of com.quorum.tessera.data.DataSourceFactory in project tessera by ConsenSys.
the class EncryptedRawTransactionDAOProviderTest 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));
EncryptedRawTransactionDAO result = EncryptedRawTransactionDAOProvider.provider();
assertThat(result).isNotNull().isExactlyInstanceOf(EncryptedRawTransactionDAOImpl.class);
mockedPersistence.verify(() -> Persistence.createEntityManagerFactory(anyString(), anyMap()));
mockedPersistence.verifyNoMoreInteractions();
EncryptedTransactionDAOProvider.provider();
}
}
Aggregations