use of io.nem.symbol.sdk.api.TransactionSearchCriteria in project nem2-sdk-java by nemtech.
the class AccountRepositoryIntegrationTest method outgoingTransactionsById.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void outgoingTransactionsById(RepositoryType type) {
TransactionRepository transactionRepository = getRepositoryFactory(type).createTransactionRepository();
Account account = config().getDefaultAccount();
List<Transaction> transactions = get(transactionRepository.search(new TransactionSearchCriteria(TransactionGroup.CONFIRMED).signerPublicKey(account.getPublicAccount().getPublicKey()).pageSize(10))).getData();
Assertions.assertTrue(transactions.size() > 1);
String id = transactions.get(1).getTransactionInfo().get().getId().get();
List<Transaction> transactions2 = get(transactionRepository.getTransactions(TransactionGroup.CONFIRMED, Arrays.asList(id)));
Assertions.assertEquals(1, transactions2.size());
transactions2.forEach(t -> Assertions.assertEquals(id, t.getTransactionInfo().get().getId().get()));
}
use of io.nem.symbol.sdk.api.TransactionSearchCriteria in project nem2-sdk-java by nemtech.
the class AccountRepositoryIntegrationTest method getTransactionById.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void getTransactionById(RepositoryType type) {
TransactionRepository transactionRepository = getRepositoryFactory(type).createTransactionRepository();
Account account = config().getDefaultAccount();
List<Transaction> transactions = get(transactionRepository.search(new TransactionSearchCriteria(TransactionGroup.CONFIRMED).signerPublicKey(account.getPublicAccount().getPublicKey()).pageSize(10))).getData();
Assertions.assertTrue(transactions.size() > 0);
String id = transactions.get(1).getTransactionInfo().get().getId().get();
List<Transaction> transactions2 = get(transactionRepository.getTransactions(TransactionGroup.CONFIRMED, Arrays.asList(id)));
Assertions.assertEquals(1, transactions2.size());
transactions2.forEach(t -> Assertions.assertEquals(id, t.getTransactionInfo().get().getId().get()));
}
use of io.nem.symbol.sdk.api.TransactionSearchCriteria in project nem2-sdk-java by nemtech.
the class TransactionRepositoryOkHttpImplTest method searchTransactionsTransactionTypesPartial.
@Test
public void searchTransactionsTransactionTypesPartial() throws Exception {
TransactionInfoDTO transferTransactionDTO = loadTransactionInfoDTO("standaloneTransferTransaction.json", TransactionInfoDTO.class);
PublicAccount publicAccount = Account.generateNewAccount(networkType).getPublicAccount();
mockRemoteCall(toPage(transferTransactionDTO));
TransactionSearchCriteria criteria = new TransactionSearchCriteria(TransactionGroup.PARTIAL).transactionTypes(Arrays.asList(TransactionType.NAMESPACE_METADATA, TransactionType.AGGREGATE_COMPLETE));
Page<Transaction> transactions = repository.search(criteria.address(publicAccount.getAddress())).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());
}
use of io.nem.symbol.sdk.api.TransactionSearchCriteria in project nem2-sdk-java by nemtech.
the class TransactionRepositoryOkHttpImplTest method searchTransactionsTransactionTypes.
@Test
public void searchTransactionsTransactionTypes() throws Exception {
TransactionInfoDTO transferTransactionDTO = loadTransactionInfoDTO("standaloneTransferTransaction.json", TransactionInfoDTO.class);
PublicAccount publicAccount = Account.generateNewAccount(networkType).getPublicAccount();
mockRemoteCall(toPage(transferTransactionDTO));
TransactionSearchCriteria criteria = new TransactionSearchCriteria(TransactionGroup.CONFIRMED).transactionTypes(Arrays.asList(TransactionType.NAMESPACE_METADATA, TransactionType.AGGREGATE_COMPLETE));
Page<Transaction> transactions = repository.search(criteria.address(publicAccount.getAddress())).toFuture().get();
Assertions.assertEquals(TransactionType.TRANSFER, transactions.getData().get(0).getType());
Assertions.assertEquals(TransactionGroup.CONFIRMED, transactions.getData().get(0).getGroup().get());
Assertions.assertEquals(1, transactions.getData().size());
Assertions.assertEquals(1, transactions.getPageNumber());
Assertions.assertEquals(2, transactions.getPageSize());
}
use of io.nem.symbol.sdk.api.TransactionSearchCriteria in project nem2-sdk-java by nemtech.
the class ListenerIntegrationTest method shouldReturnCosignatureAddedViaListener.
@ParameterizedTest
@EnumSource(RepositoryType.class)
@Disabled
void shouldReturnCosignatureAddedViaListener(RepositoryType type) {
Listener listener = getListener(type);
RepositoryFactory repositoryFactory = getRepositoryFactory(type);
TransactionService transactionService = new TransactionServiceImpl(repositoryFactory);
Pair<SignedTransaction, SignedTransaction> pair = this.createAggregateBondedTransaction(type);
System.out.println("Announcing HashLock transaction " + pair.getRight().getHash());
get(transactionService.announce(listener, pair.getRight()));
SignedTransaction signedTransaction = pair.getLeft();
AggregateTransaction announcedTransaction = get(transactionService.announceAggregateBonded(listener, signedTransaction));
assertEquals(signedTransaction.getHash(), announcedTransaction.getTransactionInfo().get().getHash().get());
TransactionRepository transactionRepository = getRepositoryFactory(type).createTransactionRepository();
List<Transaction> transactions = get(transactionRepository.search(new TransactionSearchCriteria(TransactionGroup.CONFIRMED).transactionTypes(Collections.singletonList(TransactionType.AGGREGATE_BONDED)).signerPublicKey(this.cosignatoryAccount.getPublicAccount().getPublicKey()))).getData();
AggregateTransaction transactionToCosign = (AggregateTransaction) transactions.get(0);
this.announceCosignatureTransaction(transactionToCosign, type);
CosignatureSignedTransaction cosignatureSignedTransaction = get(listener.cosignatureAdded(this.cosignatoryAccount.getAddress()).take(1));
assertEquals(cosignatureSignedTransaction.getSigner(), this.cosignatoryAccount2.getPublicAccount());
}
Aggregations