use of com.quorum.tessera.data.PrivacyGroupDAO 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.PrivacyGroupDAO in project tessera by ConsenSys.
the class PrivacyGroupManagerProviderTest method provider.
@Test
public void provider() {
try (var enclaveMockedStatic = mockStatic(Enclave.class);
var privacyGroupDAOMockStatic = mockStatic(PrivacyGroupDAO.class);
var batchPrivacyGroupPublisherMockedStatic = mockStatic(BatchPrivacyGroupPublisher.class)) {
enclaveMockedStatic.when(Enclave::create).thenReturn(mock(Enclave.class));
privacyGroupDAOMockStatic.when(PrivacyGroupDAO::create).thenReturn(mock(PrivacyGroupDAO.class));
batchPrivacyGroupPublisherMockedStatic.when(BatchPrivacyGroupPublisher::create).thenReturn(mock(BatchPrivacyGroupPublisher.class));
PrivacyGroupManager result = PrivacyGroupManagerProvider.provider();
assertThat(result).isNotNull();
enclaveMockedStatic.verify(Enclave::create);
enclaveMockedStatic.verifyNoMoreInteractions();
privacyGroupDAOMockStatic.verify(PrivacyGroupDAO::create);
privacyGroupDAOMockStatic.verifyNoMoreInteractions();
batchPrivacyGroupPublisherMockedStatic.verify(BatchPrivacyGroupPublisher::create);
batchPrivacyGroupPublisherMockedStatic.verifyNoMoreInteractions();
}
}
use of com.quorum.tessera.data.PrivacyGroupDAO in project tessera by ConsenSys.
the class PrivacyGroupManagerProvider method provider.
public static PrivacyGroupManager provider() {
Enclave enclave = Enclave.create();
PrivacyGroupDAO privacyGroupDAO = PrivacyGroupDAO.create();
BatchPrivacyGroupPublisher publisher = BatchPrivacyGroupPublisher.create();
return new PrivacyGroupManagerImpl(enclave, privacyGroupDAO, publisher);
}
Aggregations