Search in sources :

Example 6 with Recovery

use of com.quorum.tessera.recovery.Recovery in project tessera by ConsenSys.

the class RecoveryImplTest method testDBStagingTxNotEmpty.

@Test
public void testDBStagingTxNotEmpty() {
    final Recovery spy = spy(recovery);
    when(stagingEntityDAO.countAll()).thenReturn(1L);
    assertThat(spy.recover()).isEqualTo(2);
    verify(stagingEntityDAO).countAll();
}
Also used : Recovery(com.quorum.tessera.recovery.Recovery) Test(org.junit.Test)

Example 7 with Recovery

use of com.quorum.tessera.recovery.Recovery 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)

Aggregations

Recovery (com.quorum.tessera.recovery.Recovery)7 Test (org.junit.Test)7 StagingEntityDAO (com.quorum.tessera.data.staging.StagingEntityDAO)1 Discovery (com.quorum.tessera.discovery.Discovery)1 BatchTransactionRequester (com.quorum.tessera.recovery.resend.BatchTransactionRequester)1 TransactionManager (com.quorum.tessera.transaction.TransactionManager)1 PersistenceException (jakarta.persistence.PersistenceException)1