use of com.quorum.tessera.data.EncryptedTransactionDAO in project tessera by ConsenSys.
the class ResendManagerProvider method provider.
public static ResendManager provider() {
LOGGER.debug("Creating EncryptedTransactionDAO");
final EncryptedTransactionDAO encryptedTransactionDAO = EncryptedTransactionDAO.create();
LOGGER.debug("Created EncryptedTransactionDAO {}", encryptedTransactionDAO);
LOGGER.debug("Creating Enclave");
final Enclave enclave = Enclave.create();
LOGGER.debug("Created Enclave {}", enclave);
PayloadDigest payloadDigest = PayloadDigest.create();
return new ResendManagerImpl(encryptedTransactionDAO, enclave, payloadDigest);
}
use of com.quorum.tessera.data.EncryptedTransactionDAO in project tessera by ConsenSys.
the class LegacyResendManagerProviderTest method provider.
@Test
public void provider() {
try (var enclaveMockedStatic = mockStatic(Enclave.class);
var encryptedTransactionDAOMockedStatic = mockStatic(EncryptedTransactionDAO.class);
var payloadPublisherMockedStatic = mockStatic(PayloadPublisher.class);
var discoveryMockedStatic = mockStatic(Discovery.class)) {
enclaveMockedStatic.when(Enclave::create).thenReturn(mock(Enclave.class));
encryptedTransactionDAOMockedStatic.when(EncryptedTransactionDAO::create).thenReturn(mock(EncryptedTransactionDAO.class));
payloadPublisherMockedStatic.when(PayloadPublisher::create).thenReturn(mock(PayloadPublisher.class));
discoveryMockedStatic.when(Discovery::create).thenReturn(mock(Discovery.class));
LegacyResendManager legacyResendManager = LegacyResendManagerProvider.provider();
assertThat(legacyResendManager).isNotNull();
enclaveMockedStatic.verify(Enclave::create);
enclaveMockedStatic.verifyNoMoreInteractions();
encryptedTransactionDAOMockedStatic.verify(EncryptedTransactionDAO::create);
encryptedTransactionDAOMockedStatic.verifyNoMoreInteractions();
payloadPublisherMockedStatic.verify(PayloadPublisher::create);
discoveryMockedStatic.verify(Discovery::create);
discoveryMockedStatic.verifyNoMoreInteractions();
}
}
use of com.quorum.tessera.data.EncryptedTransactionDAO 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.data.EncryptedTransactionDAO 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