Search in sources :

Example 1 with PrivacyGroupPublisher

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

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

the class PrivacyGroupPublisherProviderTest method provider.

@Test
public void provider() throws Exception {
    Config config = mock(Config.class);
    when(config.getP2PServerConfig()).thenReturn(mock(ServerConfig.class));
    ConfigFactory configFactory = mock(ConfigFactory.class);
    when(configFactory.getConfig()).thenReturn(config);
    PrivacyGroupPublisher result;
    try (var discoveryMockedStatic = mockStatic(Discovery.class);
        var configFactoryMockedStatic = mockStatic(ConfigFactory.class)) {
        discoveryMockedStatic.when(Discovery::create).thenReturn(mock(Discovery.class));
        configFactoryMockedStatic.when(ConfigFactory::create).thenReturn(configFactory);
        result = PrivacyGroupPublisherProvider.provider();
        discoveryMockedStatic.verify(Discovery::create);
        configFactoryMockedStatic.verify(ConfigFactory::create);
        discoveryMockedStatic.verifyNoMoreInteractions();
        configFactoryMockedStatic.verifyNoMoreInteractions();
    }
    assertThat(result).isNotNull();
}
Also used : ServerConfig(com.quorum.tessera.config.ServerConfig) Config(com.quorum.tessera.config.Config) ServerConfig(com.quorum.tessera.config.ServerConfig) Discovery(com.quorum.tessera.discovery.Discovery) PrivacyGroupPublisher(com.quorum.tessera.privacygroup.publish.PrivacyGroupPublisher) ConfigFactory(com.quorum.tessera.config.ConfigFactory) Test(org.junit.Test)

Example 3 with PrivacyGroupPublisher

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

the class PrivacyGroupPublisherTest method create.

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

Example 4 with PrivacyGroupPublisher

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

PrivacyGroupPublisher (com.quorum.tessera.privacygroup.publish.PrivacyGroupPublisher)4 Test (org.junit.Test)3 BatchPrivacyGroupPublisher (com.quorum.tessera.privacygroup.publish.BatchPrivacyGroupPublisher)2 Config (com.quorum.tessera.config.Config)1 ConfigFactory (com.quorum.tessera.config.ConfigFactory)1 ServerConfig (com.quorum.tessera.config.ServerConfig)1 Discovery (com.quorum.tessera.discovery.Discovery)1 CancellableCountDownLatchFactory (com.quorum.tessera.threading.CancellableCountDownLatchFactory)1 ExecutorFactory (com.quorum.tessera.threading.ExecutorFactory)1