Search in sources :

Example 1 with BatchPrivacyGroupPublisher

use of com.quorum.tessera.privacygroup.publish.BatchPrivacyGroupPublisher in project tessera by ConsenSys.

the class BatchPrivacyGroupPublisherProviderTest method provider.

@Test
public void provider() {
    PrivacyGroupPublisher privacyGroupPublisher = mock(PrivacyGroupPublisher.class);
    BatchPrivacyGroupPublisher result;
    try (var privacyGroupPublisherMockedStatic = mockStatic(PrivacyGroupPublisher.class)) {
        privacyGroupPublisherMockedStatic.when(PrivacyGroupPublisher::create).thenReturn(privacyGroupPublisher);
        result = BatchPrivacyGroupPublisherProvider.provider();
        privacyGroupPublisherMockedStatic.verify(PrivacyGroupPublisher::create);
        privacyGroupPublisherMockedStatic.verifyNoMoreInteractions();
    }
    assertThat(result).isNotNull();
    verifyNoInteractions(privacyGroupPublisher);
}
Also used : BatchPrivacyGroupPublisher(com.quorum.tessera.privacygroup.publish.BatchPrivacyGroupPublisher) PrivacyGroupPublisher(com.quorum.tessera.privacygroup.publish.PrivacyGroupPublisher) BatchPrivacyGroupPublisher(com.quorum.tessera.privacygroup.publish.BatchPrivacyGroupPublisher) Test(org.junit.Test)

Example 2 with BatchPrivacyGroupPublisher

use of com.quorum.tessera.privacygroup.publish.BatchPrivacyGroupPublisher 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 BatchPrivacyGroupPublisher

use of com.quorum.tessera.privacygroup.publish.BatchPrivacyGroupPublisher in project tessera by ConsenSys.

the class BatchPrivacyGroupPublisherTest method create.

@Test
public void create() {
    BatchPrivacyGroupPublisher privacyGroupPublisher = mock(BatchPrivacyGroupPublisher.class);
    ServiceLoader<BatchPrivacyGroupPublisher> serviceLoader = mock(ServiceLoader.class);
    when(serviceLoader.findFirst()).thenReturn(Optional.of(privacyGroupPublisher));
    BatchPrivacyGroupPublisher result;
    try (var serviceLoaderMockedStatic = mockStatic(ServiceLoader.class)) {
        serviceLoaderMockedStatic.when(() -> ServiceLoader.load(BatchPrivacyGroupPublisher.class)).thenReturn(serviceLoader);
        result = BatchPrivacyGroupPublisher.create();
        serviceLoaderMockedStatic.verify(() -> ServiceLoader.load(BatchPrivacyGroupPublisher.class));
        serviceLoaderMockedStatic.verifyNoMoreInteractions();
    }
    verify(serviceLoader).findFirst();
    verifyNoMoreInteractions(serviceLoader);
    assertThat(result).isNotNull().isSameAs(privacyGroupPublisher);
}
Also used : BatchPrivacyGroupPublisher(com.quorum.tessera.privacygroup.publish.BatchPrivacyGroupPublisher) Test(org.junit.Test)

Example 4 with BatchPrivacyGroupPublisher

use of com.quorum.tessera.privacygroup.publish.BatchPrivacyGroupPublisher 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)

Example 5 with BatchPrivacyGroupPublisher

use of com.quorum.tessera.privacygroup.publish.BatchPrivacyGroupPublisher in project tessera by ConsenSys.

the class BatchPrivacyGroupPublisherProvider method provider.

public static BatchPrivacyGroupPublisher provider() {
    PrivacyGroupPublisher privacyGroupPublisher = PrivacyGroupPublisher.create();
    ExecutorFactory executorFactory = new ExecutorFactory();
    CancellableCountDownLatchFactory countDownLatchFactory = new CancellableCountDownLatchFactory();
    return new AsyncBatchPrivacyGroupPublisher(executorFactory, countDownLatchFactory, privacyGroupPublisher);
}
Also used : CancellableCountDownLatchFactory(com.quorum.tessera.threading.CancellableCountDownLatchFactory) ExecutorFactory(com.quorum.tessera.threading.ExecutorFactory) PrivacyGroupPublisher(com.quorum.tessera.privacygroup.publish.PrivacyGroupPublisher) BatchPrivacyGroupPublisher(com.quorum.tessera.privacygroup.publish.BatchPrivacyGroupPublisher)

Aggregations

BatchPrivacyGroupPublisher (com.quorum.tessera.privacygroup.publish.BatchPrivacyGroupPublisher)5 Test (org.junit.Test)3 PrivacyGroupDAO (com.quorum.tessera.data.PrivacyGroupDAO)2 Enclave (com.quorum.tessera.enclave.Enclave)2 PrivacyGroupPublisher (com.quorum.tessera.privacygroup.publish.PrivacyGroupPublisher)2 PrivacyGroupManager (com.quorum.tessera.privacygroup.PrivacyGroupManager)1 CancellableCountDownLatchFactory (com.quorum.tessera.threading.CancellableCountDownLatchFactory)1 ExecutorFactory (com.quorum.tessera.threading.ExecutorFactory)1