use of io.nem.symbol.sdk.api.TransactionStatementSearchCriteria in project nem2-sdk-java by nemtech.
the class ReceiptRepositoryOkHttpImpl method searchReceipts.
@Override
public Observable<Page<TransactionStatement>> searchReceipts(TransactionStatementSearchCriteria criteria) {
BigInteger height = criteria.getHeight();
BigInteger fromHeight = criteria.getFromHeight();
BigInteger toHeight = criteria.getToHeight();
List<ReceiptTypeEnum> receiptTypes = toDto(criteria.getReceiptTypes());
String recipientAddress = toDto(criteria.getRecipientAddress());
String senderAddress = toDto(criteria.getSenderAddress());
String targetAddress = toDto(criteria.getTargetAddress());
String artifactId = criteria.getArtifactId();
Integer pageSize = criteria.getPageSize();
Integer pageNumber = criteria.getPageNumber();
String offset = criteria.getOffset();
Order order = toDto(criteria.getOrder());
Callable<TransactionStatementPage> callback = () -> getClient().searchReceipts(height, fromHeight, toHeight, receiptTypes, recipientAddress, senderAddress, targetAddress, artifactId, pageSize, pageNumber, offset, order);
return exceptionHandling(call(callback).map(page -> this.toPage(page.getPagination(), page.getData().stream().map(mapper::createTransactionStatement).collect(Collectors.toList()))));
}
use of io.nem.symbol.sdk.api.TransactionStatementSearchCriteria in project nem2-sdk-java by nemtech.
the class ReceiptRepositoryTransactionSearchIntegrationTest method assertRecipientType.
List<TransactionStatement> assertRecipientType(RepositoryType type, List<ReceiptType> receiptTypes) {
ReceiptRepository receiptRepository = getReceiptRepository(type);
PaginationStreamer<TransactionStatement, TransactionStatementSearchCriteria> streamer = ReceiptPaginationStreamer.transactions(receiptRepository);
List<TransactionStatement> transactionStatements = get(streamer.search(new TransactionStatementSearchCriteria().receiptTypes(receiptTypes)).toList().toObservable());
transactionStatements.forEach(s -> Assertions.assertTrue(s.getReceipts().stream().anyMatch(r -> (receiptTypes.contains(r.getType())))));
return transactionStatements;
}
use of io.nem.symbol.sdk.api.TransactionStatementSearchCriteria in project nem2-sdk-java by nemtech.
the class BlockRepositoryIntegrationTest method getMerkleReceiptsFromTransactions.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void getMerkleReceiptsFromTransactions(RepositoryType type) {
BlockRepository blockRepository = getBlockRepository(type);
ReceiptRepository receiptRepository = getRepositoryFactory(type).createReceiptRepository();
PaginationStreamer<TransactionStatement, TransactionStatementSearchCriteria> streamer = ReceiptPaginationStreamer.transactions(receiptRepository);
List<TransactionStatement> list = get(streamer.search(new TransactionStatementSearchCriteria()).take(5).toList().toObservable());
System.out.println(list.size());
list.forEach(s -> {
String hash = s.generateHash();
System.out.println(hash);
System.out.println(s.getHeight());
MerkleProofInfo merkleProofInfo = get(blockRepository.getMerkleReceipts(s.getHeight(), hash));
System.out.println(toJson(merkleProofInfo));
});
}
use of io.nem.symbol.sdk.api.TransactionStatementSearchCriteria in project nem2-sdk-java by nemtech.
the class ReceiptRepositoryVertxImplTest method searchReceipts.
@Test
public void searchReceipts() throws Exception {
List<TransactionStatementInfoDTO> transactionStatementInfoDTOS = jsonHelper.parseList(TestHelperVertx.loadResource("Recipient-TransactionResolutionStatement.json"), TransactionStatementInfoDTO.class);
mockRemoteCall(toPage(transactionStatementInfoDTOS));
BigInteger height = BigInteger.valueOf(10L);
List<TransactionStatement> transactionStatements = repository.searchReceipts(new TransactionStatementSearchCriteria().height(height).receiptTypes(Collections.singletonList(ReceiptType.MOSAIC_ALIAS_RESOLUTION))).toFuture().get().getData();
Assertions.assertEquals(transactionStatementInfoDTOS.size(), transactionStatements.size());
Assertions.assertEquals("82FEFFC329618ECF56B8A6FDBCFCF1BF0A4B6747AB6A5746B195CEEB810F335C", transactionStatements.get(0).generateHash().toUpperCase());
}
use of io.nem.symbol.sdk.api.TransactionStatementSearchCriteria in project nem2-sdk-java by nemtech.
the class ReceiptRepositoryVertxImpl method searchReceipts.
@Override
public Observable<Page<TransactionStatement>> searchReceipts(TransactionStatementSearchCriteria criteria) {
BigInteger height = criteria.getHeight();
BigInteger fromHeight = criteria.getFromHeight();
BigInteger toHeight = criteria.getToHeight();
List<ReceiptTypeEnum> receiptTypes = toDto(criteria.getReceiptTypes());
String recipientAddress = toDto(criteria.getRecipientAddress());
String senderAddress = toDto(criteria.getSenderAddress());
String targetAddress = toDto(criteria.getTargetAddress());
String artifactId = criteria.getArtifactId();
Integer pageSize = criteria.getPageSize();
Integer pageNumber = criteria.getPageNumber();
String offset = criteria.getOffset();
Order order = toDto(criteria.getOrder());
Consumer<Handler<AsyncResult<TransactionStatementPage>>> callback = (handler) -> getClient().searchReceipts(height, fromHeight, toHeight, receiptTypes, recipientAddress, senderAddress, targetAddress, artifactId, pageSize, pageNumber, offset, order, handler);
return exceptionHandling(call(callback).map(page -> this.toPage(page.getPagination(), page.getData().stream().map(mapper::createTransactionStatement).collect(Collectors.toList()))));
}
Aggregations