use of com.quorum.tessera.recovery.workflow.BatchWorkflowFactory in project tessera by ConsenSys.
the class BatchResendManagerImplTest method useMaxResultsWhenBatchSizeNotProvided.
@Test
public void useMaxResultsWhenBatchSizeNotProvided() {
final ResendBatchRequest request = ResendBatchRequest.Builder.create().withPublicKey(KEY_STRING).build();
List<EncryptedTransaction> transactions = IntStream.range(0, 5).mapToObj(i -> mock(EncryptedTransaction.class)).collect(Collectors.toUnmodifiableList());
when(encryptedTransactionDAO.transactionCount()).thenReturn(101L);
BatchWorkflow batchWorkflow = mock(BatchWorkflow.class);
when(batchWorkflow.getPublishedMessageCount()).thenReturn(// arbitary total that's returned as result.getTotal()
999L);
when(batchWorkflowFactory.create(101L)).thenReturn(batchWorkflow);
when(encryptedTransactionDAO.retrieveTransactions(lt(100), anyInt())).thenReturn(transactions);
when(encryptedTransactionDAO.retrieveTransactions(gt(99), anyInt())).thenReturn(List.of(mock(EncryptedTransaction.class)));
final ResendBatchResponse result = manager.resendBatch(request);
assertThat(result.getTotal()).isEqualTo(999L);
verify(batchWorkflow, times(101)).execute(any(BatchWorkflowContext.class));
verify(encryptedTransactionDAO, times(21)).retrieveTransactions(anyInt(), anyInt());
verify(encryptedTransactionDAO).transactionCount();
verify(batchWorkflowFactory).create(101L);
}
use of com.quorum.tessera.recovery.workflow.BatchWorkflowFactory in project tessera by ConsenSys.
the class BatchResendManagerProvider method provider.
public static BatchResendManager provider() {
if (BatchResendManagerHolder.INSTANCE.getBatchResendManager().isPresent()) {
return BatchResendManagerHolder.INSTANCE.getBatchResendManager().get();
}
LOGGER.debug("Creating EncryptedTransactionDAO");
final EncryptedTransactionDAO encryptedTransactionDAO = EncryptedTransactionDAO.create();
LOGGER.debug("Created EncryptedTransactionDAO {}", encryptedTransactionDAO);
LOGGER.debug("Creating StagingEntityDAO");
final StagingEntityDAO stagingEntityDAO = StagingEntityDAO.create();
LOGGER.debug("Created StagingEntityDAO");
final int defaultMaxResults = 10000;
BatchWorkflowFactory batchWorkflowFactory = BatchWorkflowFactory.create();
BatchResendManager batchResendManager = new BatchResendManagerImpl(stagingEntityDAO, encryptedTransactionDAO, defaultMaxResults, batchWorkflowFactory);
return BatchResendManagerHolder.INSTANCE.setBatchResendManager(batchResendManager);
}
Aggregations