Search in sources :

Example 1 with PrivacyGroupDAO

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();
    }
}
Also used : DataSourceFactory(com.quorum.tessera.data.DataSourceFactory) JdbcConfig(com.quorum.tessera.config.JdbcConfig) Config(com.quorum.tessera.config.Config) EntityManagerFactory(jakarta.persistence.EntityManagerFactory) JdbcConfig(com.quorum.tessera.config.JdbcConfig) ConfigFactory(com.quorum.tessera.config.ConfigFactory) PrivacyGroupDAO(com.quorum.tessera.data.PrivacyGroupDAO) Test(org.junit.Test)

Example 2 with PrivacyGroupDAO

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();
    }
}
Also used : PrivacyGroupManager(com.quorum.tessera.privacygroup.PrivacyGroupManager) Enclave(com.quorum.tessera.enclave.Enclave) BatchPrivacyGroupPublisher(com.quorum.tessera.privacygroup.publish.BatchPrivacyGroupPublisher) PrivacyGroupDAO(com.quorum.tessera.data.PrivacyGroupDAO) Test(org.junit.Test)

Example 3 with PrivacyGroupDAO

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);
}
Also used : Enclave(com.quorum.tessera.enclave.Enclave) BatchPrivacyGroupPublisher(com.quorum.tessera.privacygroup.publish.BatchPrivacyGroupPublisher) PrivacyGroupDAO(com.quorum.tessera.data.PrivacyGroupDAO)

Aggregations

PrivacyGroupDAO (com.quorum.tessera.data.PrivacyGroupDAO)3 Enclave (com.quorum.tessera.enclave.Enclave)2 BatchPrivacyGroupPublisher (com.quorum.tessera.privacygroup.publish.BatchPrivacyGroupPublisher)2 Test (org.junit.Test)2 Config (com.quorum.tessera.config.Config)1 ConfigFactory (com.quorum.tessera.config.ConfigFactory)1 JdbcConfig (com.quorum.tessera.config.JdbcConfig)1 DataSourceFactory (com.quorum.tessera.data.DataSourceFactory)1 PrivacyGroupManager (com.quorum.tessera.privacygroup.PrivacyGroupManager)1 EntityManagerFactory (jakarta.persistence.EntityManagerFactory)1