use of io.nem.symbol.sdk.api.TransactionPaginationStreamer in project nem2-sdk-java by nemtech.
the class TransactionSearchRepositoryIntegrationTest method searchBySignerPublicKeyInvalid.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchBySignerPublicKeyInvalid(RepositoryType type) {
TransactionRepository transactionRepository = getTransactionRepository(type);
TransactionPaginationStreamer streamer = new TransactionPaginationStreamer(transactionRepository);
TransactionSearchCriteria criteria = new TransactionSearchCriteria(TransactionGroup.CONFIRMED);
PublicKey expectedSignerPublicKey = Account.generateNewAccount(getNetworkType()).getPublicAccount().getPublicKey();
criteria.setSignerPublicKey(expectedSignerPublicKey);
List<Transaction> transactions = get(streamer.search(criteria).toList().toObservable());
Assertions.assertTrue(transactions.isEmpty());
helper.assertById(transactionRepository, TransactionGroup.CONFIRMED, transactions);
}
use of io.nem.symbol.sdk.api.TransactionPaginationStreamer in project nem2-sdk-java by nemtech.
the class TransactionSearchRepositoryIntegrationTest method searchUnconfirmed.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchUnconfirmed(RepositoryType type) {
TransactionRepository transactionRepository = getTransactionRepository(type);
Address recipient = getRecipient();
TransferTransaction transferTransaction = TransferTransactionFactory.create(getNetworkType(), getDeadline(), recipient, Collections.singletonList(getNetworkCurrency().createAbsolute(BigInteger.valueOf(1)))).message(new PlainMessage("")).maxFee(maxFee).build();
Account signer = config().getDefaultAccount();
SignedTransaction signedTransaction = transferTransaction.signWith(signer, getGenerationHash());
get(transactionRepository.announce(signedTransaction));
get(getListener(type).unconfirmedAdded(signer.getAddress(), signedTransaction.getHash()).take(1));
TransactionPaginationStreamer streamer = new TransactionPaginationStreamer(transactionRepository);
TransactionGroup group = TransactionGroup.UNCONFIRMED;
TransactionSearchCriteria criteria = new TransactionSearchCriteria(group);
criteria.transactionTypes(Collections.singletonList(TransactionType.TRANSFER));
List<Transaction> transactions = get(streamer.search(criteria).toList().toObservable());
transactions.forEach(b -> Assertions.assertEquals(TransactionType.TRANSFER, b.getType()));
Assertions.assertTrue(transactions.stream().filter(t -> t.getTransactionInfo().get().getHash().get().equals(signedTransaction.getHash())).findAny().isPresent());
helper.assertById(transactionRepository, group, transactions);
}
use of io.nem.symbol.sdk.api.TransactionPaginationStreamer in project nem2-sdk-java by nemtech.
the class TransactionSearchRepositoryIntegrationTest method searchUsingOffset.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchUsingOffset(RepositoryType type) {
TransactionRepository transactionRepository = getTransactionRepository(type);
TransactionPaginationStreamer streamer = new TransactionPaginationStreamer(transactionRepository);
TransactionSearchCriteria criteria = new TransactionSearchCriteria(TransactionGroup.CONFIRMED);
criteria.setPageSize(10);
int offsetIndex = 2;
List<Transaction> transactionsWithoutOffset = get(streamer.search(criteria).toList().toObservable());
criteria.setOffset(transactionsWithoutOffset.get(offsetIndex).getRecordId().get());
List<Transaction> transactionFromOffsets = get(streamer.search(criteria).toList().toObservable());
PaginationTester.sameEntities(transactionsWithoutOffset.stream().skip(offsetIndex + 1).collect(Collectors.toList()), transactionFromOffsets);
helper.assertById(transactionRepository, TransactionGroup.CONFIRMED, transactionFromOffsets);
helper.assertById(transactionRepository, TransactionGroup.CONFIRMED, transactionsWithoutOffset);
}
use of io.nem.symbol.sdk.api.TransactionPaginationStreamer in project nem2-sdk-java by nemtech.
the class TransactionSearchRepositoryIntegrationTest method searchByTransactionHeight.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchByTransactionHeight(RepositoryType type) {
TransactionRepository transactionRepository = getTransactionRepository(type);
TransactionPaginationStreamer streamer = new TransactionPaginationStreamer(transactionRepository);
TransactionSearchCriteria criteria = new TransactionSearchCriteria(TransactionGroup.CONFIRMED);
criteria.height(BigInteger.ONE);
criteria.embedded(true);
List<Transaction> transactions = get(streamer.search(criteria).toList().toObservable());
transactions.forEach(b -> Assertions.assertEquals(BigInteger.ONE, b.getTransactionInfo().get().getHeight()));
Assertions.assertFalse(transactions.isEmpty());
helper.assertById(transactionRepository, TransactionGroup.CONFIRMED, transactions);
}
use of io.nem.symbol.sdk.api.TransactionPaginationStreamer in project nem2-sdk-java by nemtech.
the class TransactionSearchRepositoryIntegrationTest method searchEmbeddedTransactionType.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchEmbeddedTransactionType(RepositoryType type) {
TransactionRepository transactionRepository = getTransactionRepository(type);
TransactionPaginationStreamer streamer = new TransactionPaginationStreamer(transactionRepository);
TransactionSearchCriteria criteria = new TransactionSearchCriteria(TransactionGroup.CONFIRMED);
criteria.setEmbedded(true);
List<Transaction> transactions = get(streamer.search(criteria).toList().toObservable());
Assertions.assertFalse(transactions.isEmpty());
transactions.stream().forEach(t -> {
Transaction storedById = get(transactionRepository.getTransaction(TransactionGroup.CONFIRMED, t.getRecordId().get()));
Assertions.assertEquals(storedById.getRecordId().get(), t.getRecordId().get());
if (t.getTransactionInfo().get().getHash().isPresent()) {
Transaction transaction = get(transactionRepository.getTransaction(TransactionGroup.CONFIRMED, t.getTransactionInfo().get().getHash().get()));
Assertions.assertEquals(storedById.getRecordId().get(), t.getRecordId().get());
Assertions.assertEquals(t.getTransactionInfo().get().getHash().get(), t.getTransactionInfo().get().getHash().get());
} else {
Assertions.assertEquals(0, t.getMaxFee().intValue());
}
});
}
Aggregations