Search in sources :

Example 1 with Recovery

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

the class RecoveryImplTest method testDBStagingAffectedTxNotEmpty.

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

Example 2 with Recovery

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

the class RecoveryImplTest method testRecoverPartialSuccess.

@Test
public void testRecoverPartialSuccess() {
    final Recovery spy = spy(recovery);
    doReturn(RecoveryResult.PARTIAL_SUCCESS).when(spy).request();
    doReturn(RecoveryResult.PARTIAL_SUCCESS).when(spy).stage();
    doReturn(RecoveryResult.SUCCESS).when(spy).sync();
    assertThat(spy.recover()).isEqualTo(1);
    verify(spy).request();
    verify(spy).stage();
    verify(spy).sync();
    verify(stagingEntityDAO).countAll();
    verify(stagingEntityDAO).countAllAffected();
}
Also used : Recovery(com.quorum.tessera.recovery.Recovery) Test(org.junit.Test)

Example 3 with Recovery

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

the class RecoveryImplTest method testRecoverSuccess.

@Test
public void testRecoverSuccess() {
    final Recovery spy = spy(recovery);
    doReturn(RecoveryResult.SUCCESS).when(spy).request();
    doReturn(RecoveryResult.SUCCESS).when(spy).stage();
    doReturn(RecoveryResult.SUCCESS).when(spy).sync();
    assertThat(spy.recover()).isEqualTo(0);
    verify(spy).request();
    verify(spy).stage();
    verify(spy).sync();
    verify(stagingEntityDAO).countAll();
    verify(stagingEntityDAO).countAllAffected();
}
Also used : Recovery(com.quorum.tessera.recovery.Recovery) Test(org.junit.Test)

Example 4 with Recovery

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

the class RecoveryImplTest method testDBTableNotExisted.

@Test
public void testDBTableNotExisted() {
    final Recovery spy = spy(recovery);
    when(stagingEntityDAO.countAll()).thenThrow(new PersistenceException("OUCH"));
    assertThat(spy.recover()).isEqualTo(2);
    verify(stagingEntityDAO).countAll();
}
Also used : PersistenceException(jakarta.persistence.PersistenceException) Recovery(com.quorum.tessera.recovery.Recovery) Test(org.junit.Test)

Example 5 with Recovery

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

the class RecoveryImplTest method testRecoverFailed.

@Test
public void testRecoverFailed() {
    final Recovery spy = spy(recovery);
    doReturn(RecoveryResult.FAILURE).when(spy).request();
    doReturn(RecoveryResult.PARTIAL_SUCCESS).when(spy).stage();
    doReturn(RecoveryResult.SUCCESS).when(spy).sync();
    assertThat(spy.recover()).isEqualTo(2);
    verify(spy).request();
    verify(spy).stage();
    verify(spy).sync();
    verify(stagingEntityDAO).countAll();
    verify(stagingEntityDAO).countAllAffected();
}
Also used : 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