Search in sources :

Example 21 with TransactionRepository

use of io.nem.symbol.sdk.api.TransactionRepository in project nem2-sdk-java by nemtech.

the class TransactionSearchRepositoryIntegrationTest method searchByTransactionType.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchByTransactionType(RepositoryType type) {
    TransactionRepository transactionRepository = getTransactionRepository(type);
    TransactionPaginationStreamer streamer = new TransactionPaginationStreamer(transactionRepository);
    TransactionSearchCriteria criteria = new TransactionSearchCriteria(TransactionGroup.CONFIRMED);
    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.assertFalse(transactions.isEmpty());
    helper.assertById(transactionRepository, TransactionGroup.CONFIRMED, transactions);
}
Also used : SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) TransactionRepository(io.nem.symbol.sdk.api.TransactionRepository) TransactionPaginationStreamer(io.nem.symbol.sdk.api.TransactionPaginationStreamer) TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 22 with TransactionRepository

use of io.nem.symbol.sdk.api.TransactionRepository in project nem2-sdk-java by nemtech.

the class TransactionSearchRepositoryIntegrationTest method searchTransactionType.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchTransactionType(RepositoryType type) {
    TransactionRepository transactionRepository = getTransactionRepository(type);
    TransactionPaginationStreamer streamer = new TransactionPaginationStreamer(transactionRepository);
    TransactionGroup group = TransactionGroup.CONFIRMED;
    TransactionSearchCriteria criteria = new TransactionSearchCriteria(group).transactionTypes(Arrays.asList(TransactionType.TRANSFER));
    List<Transaction> transactions = get(streamer.search(criteria).toList().toObservable());
    transactions.forEach(b -> {
        TransferTransaction transferTransaction = (TransferTransaction) b;
        Message message = transferTransaction.getMessage().orElse(PlainMessage.create("No Message!!"));
        Assertions.assertNotNull(message.getText());
    });
    Assertions.assertFalse(transactions.isEmpty());
}
Also used : SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) Message(io.nem.symbol.sdk.model.message.Message) PlainMessage(io.nem.symbol.sdk.model.message.PlainMessage) TransactionRepository(io.nem.symbol.sdk.api.TransactionRepository) TransactionGroup(io.nem.symbol.sdk.model.transaction.TransactionGroup) TransactionPaginationStreamer(io.nem.symbol.sdk.api.TransactionPaginationStreamer) TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 23 with TransactionRepository

use of io.nem.symbol.sdk.api.TransactionRepository in project nem2-sdk-java by nemtech.

the class TransactionSearchRepositoryIntegrationTest method searchByTransactionFromHeight.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchByTransactionFromHeight(RepositoryType type) {
    TransactionRepository transactionRepository = getTransactionRepository(type);
    TransactionPaginationStreamer streamer = new TransactionPaginationStreamer(transactionRepository);
    TransactionSearchCriteria toBlockOneTransactions = new TransactionSearchCriteria(TransactionGroup.CONFIRMED).fromHeight(BigInteger.valueOf(2)).embedded(true);
    List<Transaction> transactions = get(streamer.search(toBlockOneTransactions).toList().toObservable());
    transactions.forEach(b -> Assertions.assertTrue(b.getTransactionInfo().get().getHeight().compareTo(BigInteger.ONE) > 0));
    Assertions.assertFalse(transactions.isEmpty());
}
Also used : SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) TransactionRepository(io.nem.symbol.sdk.api.TransactionRepository) TransactionPaginationStreamer(io.nem.symbol.sdk.api.TransactionPaginationStreamer) TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 24 with TransactionRepository

use of io.nem.symbol.sdk.api.TransactionRepository in project nem2-sdk-java by nemtech.

the class TransactionSearchRepositoryIntegrationTest method searchBySignerPublicKey.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchBySignerPublicKey(RepositoryType type) {
    TransactionRepository transactionRepository = getTransactionRepository(type);
    TransactionPaginationStreamer streamer = new TransactionPaginationStreamer(transactionRepository);
    Transaction transaction1 = get(streamer.search(new TransactionSearchCriteria(TransactionGroup.CONFIRMED)).take(1));
    TransactionSearchCriteria criteria = new TransactionSearchCriteria(TransactionGroup.CONFIRMED);
    PublicKey expectedSignerPublicKey = transaction1.getSigner().get().getPublicKey();
    criteria.setSignerPublicKey(expectedSignerPublicKey);
    List<Transaction> transactions = get(streamer.search(criteria).toList().toObservable());
    transactions.forEach(b -> Assertions.assertEquals(expectedSignerPublicKey, b.getSigner().get().getPublicKey()));
    Assertions.assertFalse(transactions.isEmpty());
    helper.assertById(transactionRepository, TransactionGroup.CONFIRMED, transactions);
}
Also used : SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) PublicKey(io.nem.symbol.core.crypto.PublicKey) TransactionRepository(io.nem.symbol.sdk.api.TransactionRepository) TransactionPaginationStreamer(io.nem.symbol.sdk.api.TransactionPaginationStreamer) TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

TransactionRepository (io.nem.symbol.sdk.api.TransactionRepository)24 TransactionSearchCriteria (io.nem.symbol.sdk.api.TransactionSearchCriteria)24 Transaction (io.nem.symbol.sdk.model.transaction.Transaction)24 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)24 EnumSource (org.junit.jupiter.params.provider.EnumSource)24 TransferTransaction (io.nem.symbol.sdk.model.transaction.TransferTransaction)22 SignedTransaction (io.nem.symbol.sdk.model.transaction.SignedTransaction)14 TransactionPaginationStreamer (io.nem.symbol.sdk.api.TransactionPaginationStreamer)13 Account (io.nem.symbol.sdk.model.account.Account)8 PublicAccount (io.nem.symbol.sdk.model.account.PublicAccount)7 PlainMessage (io.nem.symbol.sdk.model.message.PlainMessage)6 TransactionGroup (io.nem.symbol.sdk.model.transaction.TransactionGroup)6 BigInteger (java.math.BigInteger)6 TransactionType (io.nem.symbol.sdk.model.transaction.TransactionType)5 PublicKey (io.nem.symbol.core.crypto.PublicKey)4 Address (io.nem.symbol.sdk.model.account.Address)4 Message (io.nem.symbol.sdk.model.message.Message)4 TransferTransactionFactory (io.nem.symbol.sdk.model.transaction.TransferTransactionFactory)4 Collections (java.util.Collections)4 List (java.util.List)4