Search in sources :

Example 21 with Listener

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

the class ListenerIntegrationTest method shouldReturnAggregateBondedRemovedTransactionViaListener.

@ParameterizedTest
@EnumSource(RepositoryType.class)
@Disabled
void shouldReturnAggregateBondedRemovedTransactionViaListener(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();
    System.out.println("Announcing Aggregate transaction " + signedTransaction.getHash());
    get(transactionService.announceAggregateBonded(listener, signedTransaction).take(1));
    String transactionHash = get(listener.aggregateBondedRemoved(this.account.getAddress()).take(1));
    assertEquals(signedTransaction.getHash(), transactionHash);
}
Also used : Listener(io.nem.symbol.sdk.api.Listener) TransactionService(io.nem.symbol.sdk.api.TransactionService) RepositoryFactory(io.nem.symbol.sdk.api.RepositoryFactory) SignedTransaction(io.nem.symbol.sdk.model.transaction.SignedTransaction) CosignatureSignedTransaction(io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Disabled(org.junit.jupiter.api.Disabled)

Example 22 with Listener

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

the class ListenerStatusIntegrationTest method createListener.

private Listener createListener(RepositoryType type) throws InterruptedException, ExecutionException {
    Listener listener = getRepositoryFactory(type).createListener();
    CompletableFuture<Void> connected = listener.open();
    connected.get();
    assertTrue(connected.isDone());
    return listener;
}
Also used : Listener(io.nem.symbol.sdk.api.Listener)

Example 23 with Listener

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

the class TransferTransactionIntegrationTest method listen.

private Listener listen(RepositoryType type, List<String> messages, boolean includeAliases, UnresolvedAddress... recipients) throws InterruptedException, ExecutionException {
    Listener listener = getRepositoryFactory(type).createListener();
    listener.open().get();
    final HashSet<UnresolvedAddress> expected = new HashSet<>();
    expected.add(recipientAlias);
    expected.add(recipientAddress);
    if (includeAliases) {
        for (UnresolvedAddress recipient : recipients) {
            listener.getAllAddressesAndAliases(recipient).subscribe(multiple -> {
                Assertions.assertEquals(expected, multiple);
                subscribeMultiple(messages, listener, multiple);
            });
        }
    } else {
        final Set<UnresolvedAddress> multiple = Arrays.stream(recipients).collect(Collectors.toSet());
        subscribeMultiple(messages, listener, multiple);
    }
    return listener;
}
Also used : Listener(io.nem.symbol.sdk.api.Listener) UnresolvedAddress(io.nem.symbol.sdk.model.account.UnresolvedAddress) HashSet(java.util.HashSet)

Aggregations

Listener (io.nem.symbol.sdk.api.Listener)23 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)15 EnumSource (org.junit.jupiter.params.provider.EnumSource)15 SignedTransaction (io.nem.symbol.sdk.model.transaction.SignedTransaction)13 CosignatureSignedTransaction (io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction)12 TransferTransaction (io.nem.symbol.sdk.model.transaction.TransferTransaction)11 AggregateTransaction (io.nem.symbol.sdk.model.transaction.AggregateTransaction)9 Transaction (io.nem.symbol.sdk.model.transaction.Transaction)9 RepositoryFactory (io.nem.symbol.sdk.api.RepositoryFactory)8 CosignatureTransaction (io.nem.symbol.sdk.model.transaction.CosignatureTransaction)8 HashLockTransaction (io.nem.symbol.sdk.model.transaction.HashLockTransaction)8 TransactionService (io.nem.symbol.sdk.api.TransactionService)7 Disabled (org.junit.jupiter.api.Disabled)7 TransactionRepository (io.nem.symbol.sdk.api.TransactionRepository)6 PlainMessage (io.nem.symbol.sdk.model.message.PlainMessage)6 TransactionSearchCriteria (io.nem.symbol.sdk.api.TransactionSearchCriteria)5 Account (io.nem.symbol.sdk.model.account.Account)5 Address (io.nem.symbol.sdk.model.account.Address)4 UnresolvedAddress (io.nem.symbol.sdk.model.account.UnresolvedAddress)4 BlockInfo (io.nem.symbol.sdk.model.blockchain.BlockInfo)4