use of io.nem.symbol.sdk.model.receipt.TransactionStatement 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()))));
}
use of io.nem.symbol.sdk.model.receipt.TransactionStatement in project nem2-sdk-java by nemtech.
the class ReceiptRepositoryOkHttpImplTest method searchReceipts.
@Test
public void searchReceipts() throws Exception {
List<TransactionStatementInfoDTO> transactionStatementInfoDTOS = jsonHelper.parseList(TestHelperOkHttp.loadResource("Recipient-TransactionResolutionStatement.json"), TransactionStatementInfoDTO.class);
mockRemoteCall(toPage(transactionStatementInfoDTOS));
BigInteger height = BigInteger.valueOf(10L);
List<TransactionStatement> transactionStatements = repository.searchReceipts(new TransactionStatementSearchCriteria().height(height)).toFuture().get().getData();
Assertions.assertEquals(transactionStatementInfoDTOS.size(), transactionStatements.size());
Assertions.assertEquals("82FEFFC329618ECF56B8A6FDBCFCF1BF0A4B6747AB6A5746B195CEEB810F335C", transactionStatements.get(0).generateHash().toUpperCase());
}
use of io.nem.symbol.sdk.model.receipt.TransactionStatement in project nem2-sdk-java by nemtech.
the class ReceiptMappingVertxTest method getTransactionStatements2Recipients.
@Test
public void getTransactionStatements2Recipients() {
List<TransactionStatementInfoDTO> transactionStatementInfoDTOS = jsonHelper.parseList(TestHelperVertx.loadResource("Recipient-TransactionResolutionStatement.json"), TransactionStatementInfoDTO.class);
List<TransactionStatement> transactionStatements = transactionStatementInfoDTOS.stream().map(mapper::createTransactionStatement).collect(Collectors.toList());
TransactionStatement transactionStatement = transactionStatements.get(1);
Assertions.assertEquals("41BF730BD307EB507880CA0576A4CCEFEF95F3060DC334CA364AE737114D1F60", transactionStatement.generateHash().toUpperCase());
List<Receipt> receipts = transactionStatement.getReceipts();
Assertions.assertEquals(5, receipts.size());
Assertions.assertEquals(ReceiptType.NAMESPACE_RENTAL_FEE, receipts.get(0).getType());
Assertions.assertEquals("85BBEA6CC462B244", ((BalanceTransferReceipt) receipts.get(0)).getMosaicId().getIdAsHex());
Assertions.assertEquals(ReceiptType.MOSAIC_EXPIRED, receipts.get(1).getType());
Assertions.assertEquals(MosaicId.class, ((ArtifactExpiryReceipt) receipts.get(1)).getArtifactId().getClass());
Assertions.assertEquals(ReceiptType.NAMESPACE_EXPIRED, receipts.get(2).getType());
Assertions.assertEquals(NamespaceId.class, ((ArtifactExpiryReceipt) receipts.get(2)).getArtifactId().getClass());
Assertions.assertEquals(ReceiptType.NAMESPACE_DELETED, receipts.get(3).getType());
Assertions.assertEquals(NamespaceId.class, ((ArtifactExpiryReceipt) receipts.get(3)).getArtifactId().getClass());
Assertions.assertEquals(ReceiptType.INFLATION, receipts.get(4).getType());
Assertions.assertEquals(333, ((InflationReceipt) receipts.get(4)).getAmount().longValue());
}
Aggregations