Search in sources :

Example 21 with TransactionSearchCriteria

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

the class AccountRepositoryIntegrationTest method unconfirmedTransactions.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void unconfirmedTransactions(RepositoryType type) {
    Account testAccount = this.config().getDefaultAccount();
    TransactionRepository transactionRepository = getRepositoryFactory(type).createTransactionRepository();
    PublicAccount publicAccount = this.helper().getTestAccount(type).getLeft().getPublicAccount();
    List<Transaction> transactions = get(transactionRepository.search(new TransactionSearchCriteria(TransactionGroup.UNCONFIRMED).signerPublicKey(publicAccount.getPublicKey()))).getData();
    System.out.println(transactions.size());
    transactions.forEach(transaction -> assertTransaction(transaction, testAccount.getAddress()));
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) PublicAccount(io.nem.symbol.sdk.model.account.PublicAccount) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) TransactionRepository(io.nem.symbol.sdk.api.TransactionRepository) PublicAccount(io.nem.symbol.sdk.model.account.PublicAccount) TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 22 with TransactionSearchCriteria

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

the class AccountRepositoryIntegrationTest method getMosaicGlobalRegistration.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void getMosaicGlobalRegistration(RepositoryType type) {
    TransactionRepository transactionRepository = getRepositoryFactory(type).createTransactionRepository();
    Account account = config().getDefaultAccount();
    TransactionType transactionType = TransactionType.MOSAIC_GLOBAL_RESTRICTION;
    List<Transaction> transactions = get(transactionRepository.search(new TransactionSearchCriteria(TransactionGroup.CONFIRMED).transactionTypes(Collections.singletonList(transactionType)).signerPublicKey(account.getPublicAccount().getPublicKey()).pageSize(10))).getData();
    System.out.println(transactions.size());
    Assertions.assertFalse(transactions.isEmpty());
    transactions.forEach(t -> Assertions.assertEquals(transactionType, t.getType()));
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) PublicAccount(io.nem.symbol.sdk.model.account.PublicAccount) TransactionType(io.nem.symbol.sdk.model.transaction.TransactionType) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) TransactionRepository(io.nem.symbol.sdk.api.TransactionRepository) TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 23 with TransactionSearchCriteria

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

the class TransactionRepositoryVertxImplTest method searchTransactionsPartial.

@Test
public void searchTransactionsPartial() throws Exception {
    TransactionInfoDTO transferTransactionDTO = loadTransactionInfoDTO("standaloneTransferTransaction.json");
    PublicAccount publicAccount = Account.generateNewAccount(networkType).getPublicAccount();
    mockRemoteCall(toPage(transferTransactionDTO));
    Page<Transaction> transactions = repository.search(new TransactionSearchCriteria(TransactionGroup.PARTIAL).signerPublicKey(publicAccount.getPublicKey())).toFuture().get();
    Assertions.assertEquals(TransactionType.TRANSFER, transactions.getData().get(0).getType());
    Assertions.assertEquals(TransactionGroup.PARTIAL, transactions.getData().get(0).getGroup().get());
    Assertions.assertEquals(1, transactions.getData().size());
    Assertions.assertEquals(1, transactions.getPageNumber());
    Assertions.assertEquals(2, transactions.getPageSize());
}
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) CosignatureSignedTransaction(io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction) TestHelperVertx.loadTransactionInfoDTO(io.nem.symbol.sdk.infrastructure.vertx.TestHelperVertx.loadTransactionInfoDTO) TransactionInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.TransactionInfoDTO) AnnounceTransactionInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.AnnounceTransactionInfoDTO) PublicAccount(io.nem.symbol.sdk.model.account.PublicAccount) TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria) Test(org.junit.jupiter.api.Test)

Example 24 with TransactionSearchCriteria

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

the class TransactionRepositoryIntegrationTest method getBlockTransactions.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void getBlockTransactions(RepositoryType type) {
    TransactionRepository transactionRepository = getRepositoryFactory(type).createTransactionRepository();
    List<Transaction> transactions = get(transactionRepository.search(new TransactionSearchCriteria(TransactionGroup.CONFIRMED).height(BigInteger.ONE).pageNumber(1))).getData();
    assertEquals(20, transactions.size());
    List<Transaction> nextTransactions = get(transactionRepository.search(new TransactionSearchCriteria(TransactionGroup.CONFIRMED).height(BigInteger.ONE).pageNumber(2))).getData();
    assertTrue(nextTransactions.size() > 0);
    assertNotEquals(transactions.get(1).getTransactionInfo().get().getHash(), nextTransactions.get(0).getTransactionInfo().get().getHash());
}
Also used : TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) TransactionRepository(io.nem.symbol.sdk.api.TransactionRepository) TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 25 with TransactionSearchCriteria

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

the class TransactionSearchRepositoryIntegrationTest method searchEmbedded.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void searchEmbedded(RepositoryType type) {
    TransactionRepository transactionRepository = getTransactionRepository(type);
    TransactionPaginationStreamer streamer = new TransactionPaginationStreamer(transactionRepository);
    TransactionGroup group = TransactionGroup.CONFIRMED;
    TransactionSearchCriteria criteria = new TransactionSearchCriteria(group).embedded(true);
    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)

Aggregations

TransactionSearchCriteria (io.nem.symbol.sdk.api.TransactionSearchCriteria)31 Transaction (io.nem.symbol.sdk.model.transaction.Transaction)31 TransferTransaction (io.nem.symbol.sdk.model.transaction.TransferTransaction)29 TransactionRepository (io.nem.symbol.sdk.api.TransactionRepository)24 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)24 EnumSource (org.junit.jupiter.params.provider.EnumSource)24 SignedTransaction (io.nem.symbol.sdk.model.transaction.SignedTransaction)21 TransactionPaginationStreamer (io.nem.symbol.sdk.api.TransactionPaginationStreamer)13 PublicAccount (io.nem.symbol.sdk.model.account.PublicAccount)12 Account (io.nem.symbol.sdk.model.account.Account)8 CosignatureSignedTransaction (io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction)8 BigInteger (java.math.BigInteger)7 PlainMessage (io.nem.symbol.sdk.model.message.PlainMessage)6 TransactionGroup (io.nem.symbol.sdk.model.transaction.TransactionGroup)6 Test (org.junit.jupiter.api.Test)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