Search in sources :

Example 11 with Discovery

use of com.quorum.tessera.discovery.Discovery in project tessera by ConsenSys.

the class RecoveryProviderTest method provider.

@Test
public void provider() {
    try (var staticStagingEntityDAO = mockStatic(StagingEntityDAO.class);
        var staticDiscovery = mockStatic(Discovery.class);
        var staticBatchTransactionRequester = mockStatic(BatchTransactionRequester.class);
        var staticTransactionManager = mockStatic(TransactionManager.class)) {
        staticStagingEntityDAO.when(StagingEntityDAO::create).thenReturn(mock(StagingEntityDAO.class));
        staticDiscovery.when(Discovery::create).thenReturn(mock(Discovery.class));
        staticBatchTransactionRequester.when(BatchTransactionRequester::create).thenReturn(mock(BatchTransactionRequester.class));
        TransactionManager transactionManager = mock(TransactionManager.class);
        staticTransactionManager.when(TransactionManager::create).thenReturn(transactionManager);
        Recovery recovery = RecoveryProvider.provider();
        assertThat(recovery).isNotNull().isExactlyInstanceOf(RecoveryImpl.class);
        staticStagingEntityDAO.verify(StagingEntityDAO::create);
        staticStagingEntityDAO.verifyNoMoreInteractions();
        verifyNoMoreInteractions(transactionManager);
        staticDiscovery.verify(Discovery::create);
        staticDiscovery.verifyNoMoreInteractions();
        staticBatchTransactionRequester.verify(BatchTransactionRequester::create);
        staticBatchTransactionRequester.verifyNoMoreInteractions();
        staticTransactionManager.verify(TransactionManager::create);
        staticTransactionManager.verifyNoMoreInteractions();
    }
}
Also used : BatchTransactionRequester(com.quorum.tessera.recovery.resend.BatchTransactionRequester) TransactionManager(com.quorum.tessera.transaction.TransactionManager) StagingEntityDAO(com.quorum.tessera.data.staging.StagingEntityDAO) Discovery(com.quorum.tessera.discovery.Discovery) Recovery(com.quorum.tessera.recovery.Recovery) Test(org.junit.Test)

Example 12 with Discovery

use of com.quorum.tessera.discovery.Discovery in project tessera by ConsenSys.

the class DiscoveryProviderTest method provideStoredDiscovery.

@Test
public void provideStoredDiscovery() {
    Discovery discovery = mock(Discovery.class);
    when(discoveryHolder.get()).thenReturn(Optional.of(discovery));
    Discovery result = DiscoveryProvider.provider();
    assertThat(result).isSameAs(discovery);
    verify(discoveryHolder, times(2)).get();
    discoveryHolderMockedStatic.verify(DiscoveryHolder::create);
}
Also used : Discovery(com.quorum.tessera.discovery.Discovery) Test(org.junit.Test)

Example 13 with Discovery

use of com.quorum.tessera.discovery.Discovery in project tessera by ConsenSys.

the class DiscoveryProviderTest method provideAutoDiscovery.

@Test
public void provideAutoDiscovery() {
    when(runtimeContext.isDisablePeerDiscovery()).thenReturn(false);
    Discovery discovery = DiscoveryProvider.provider();
    assertThat(discovery).isNotNull().isExactlyInstanceOf(AutoDiscovery.class);
    verify(discoveryHolder).get();
    verify(discoveryHolder).set(discovery);
    discoveryHolderMockedStatic.verify(DiscoveryHolder::create);
    verify(runtimeContext).isDisablePeerDiscovery();
    mockedRuntimeContext.verify(RuntimeContext::getInstance);
}
Also used : Discovery(com.quorum.tessera.discovery.Discovery) RuntimeContext(com.quorum.tessera.context.RuntimeContext) Test(org.junit.Test)

Example 14 with Discovery

use of com.quorum.tessera.discovery.Discovery in project tessera by ConsenSys.

the class DiscoveryProviderTest method provideDisabledAutoDiscovery.

@Test
public void provideDisabledAutoDiscovery() {
    when(runtimeContext.isDisablePeerDiscovery()).thenReturn(true);
    Discovery discovery = DiscoveryProvider.provider();
    assertThat(discovery).isNotNull().isExactlyInstanceOf(DisabledAutoDiscovery.class);
    verify(discoveryHolder).get();
    verify(discoveryHolder).set(discovery);
    discoveryHolderMockedStatic.verify(DiscoveryHolder::create);
    verify(runtimeContext).isDisablePeerDiscovery();
    verify(runtimeContext).getPeers();
    mockedRuntimeContext.verify(RuntimeContext::getInstance);
}
Also used : Discovery(com.quorum.tessera.discovery.Discovery) RuntimeContext(com.quorum.tessera.context.RuntimeContext) Test(org.junit.Test)

Example 15 with Discovery

use of com.quorum.tessera.discovery.Discovery in project tessera by ConsenSys.

the class RecoveryProvider method provider.

public static Recovery provider() {
    StagingEntityDAO stagingEntityDAO = StagingEntityDAO.create();
    Discovery discovery = Discovery.create();
    BatchTransactionRequester batchTransactionRequester = BatchTransactionRequester.create();
    TransactionManager transactionManager = TransactionManager.create();
    return new RecoveryImpl(stagingEntityDAO, discovery, batchTransactionRequester, transactionManager);
}
Also used : BatchTransactionRequester(com.quorum.tessera.recovery.resend.BatchTransactionRequester) TransactionManager(com.quorum.tessera.transaction.TransactionManager) StagingEntityDAO(com.quorum.tessera.data.staging.StagingEntityDAO) Discovery(com.quorum.tessera.discovery.Discovery)

Aggregations

Discovery (com.quorum.tessera.discovery.Discovery)20 Test (org.junit.Test)9 Enclave (com.quorum.tessera.enclave.Enclave)8 RuntimeContext (com.quorum.tessera.context.RuntimeContext)6 Config (com.quorum.tessera.config.Config)5 TransactionManager (com.quorum.tessera.transaction.TransactionManager)5 NodeUri (com.quorum.tessera.discovery.NodeUri)3 ResendBatchPublisher (com.quorum.tessera.recovery.resend.ResendBatchPublisher)3 LegacyResendManager (com.quorum.tessera.recovery.workflow.LegacyResendManager)3 PayloadPublisher (com.quorum.tessera.transaction.publish.PayloadPublisher)3 Objects (java.util.Objects)3 ConfigFactory (com.quorum.tessera.config.ConfigFactory)2 ServerConfig (com.quorum.tessera.config.ServerConfig)2 EncryptedTransactionDAO (com.quorum.tessera.data.EncryptedTransactionDAO)2 StagingEntityDAO (com.quorum.tessera.data.staging.StagingEntityDAO)2 ClientFactory (com.quorum.tessera.jaxrs.client.ClientFactory)2 PartyStore (com.quorum.tessera.p2p.partyinfo.PartyStore)2 PrivacyGroupManager (com.quorum.tessera.privacygroup.PrivacyGroupManager)2 BatchTransactionRequester (com.quorum.tessera.recovery.resend.BatchTransactionRequester)2 BatchResendManager (com.quorum.tessera.recovery.workflow.BatchResendManager)2