use of io.nem.symbol.sdk.api.Listener in project nem2-sdk-java by nemtech.
the class ListenerIntegrationTest method shouldReturnUnconfirmedAddedTransactionViaListener.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void shouldReturnUnconfirmedAddedTransactionViaListener(RepositoryType type) {
Listener listener = getListener(type);
SignedTransaction signedTransaction = this.announceStandaloneTransferTransaction(type, this.getRecipient());
Transaction transaction = get(listener.unconfirmedAdded(this.account.getAddress(), signedTransaction.getHash()).take(1));
assertEquals(signedTransaction.getHash(), transaction.getTransactionInfo().get().getHash().get());
}
use of io.nem.symbol.sdk.api.Listener in project nem2-sdk-java by nemtech.
the class ListenerIntegrationTest method getAllMultisigAddressesAndAliasesWhenCosign.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void getAllMultisigAddressesAndAliasesWhenCosign(RepositoryType type) {
final MultisigAccountInfo multisigAccountInfo = get(getRepositoryFactory(type).createMultisigRepository().getMultisigAccountInfo(this.multisigAccount.getAddress()));
Assertions.assertEquals(Arrays.asList(this.cosignatoryAccount.getAddress(), this.cosignatoryAccount2.getAddress()), multisigAccountInfo.getCosignatoryAddresses());
Set<NamespaceId> aliases = get(getRepositoryFactory(type).createNamespaceRepository().getAccountsNames(Arrays.asList(cosignatoryAccount.getAddress()))).stream().flatMap(a -> a.getNames().stream().map(n -> n.getNamespaceId())).collect(Collectors.toSet());
Listener listener = getRepositoryFactory(type).createListener();
final Set<UnresolvedAddress> unresolvedAddresses = get(listener.getAllMultisigAddressesAndAliases(this.cosignatoryAccount.getAddress()));
final Set<UnresolvedAddress> expectedAddresees = Sets.newSet(this.cosignatoryAccount.getAddress());
expectedAddresees.addAll(aliases);
Assertions.assertEquals(expectedAddresees, unresolvedAddresses);
}
use of io.nem.symbol.sdk.api.Listener in project nem2-sdk-java by nemtech.
the class ListenerIntegrationTest method shouldReturnNewBlockViaListener.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void shouldReturnNewBlockViaListener(RepositoryType type) {
Listener listener = getListener(type);
BlockInfo blockInfo = get(listener.newBlock().take(1));
assertTrue(blockInfo.getHeight().intValue() > 0);
}
use of io.nem.symbol.sdk.api.Listener in project nem2-sdk-java by nemtech.
the class ListenerIntegrationTest method shouldReturnConfirmedTransactionAddressRecipientViaListener.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void shouldReturnConfirmedTransactionAddressRecipientViaListener(RepositoryType type) {
Listener listener = getListener(type);
SignedTransaction signedTransaction = this.announceStandaloneTransferTransaction(type, this.getRecipient());
Observable<Transaction> confirmed = listener.confirmed(this.getRecipient(), signedTransaction.getHash());
Transaction transaction = get(confirmed.take(1));
assertEquals(signedTransaction.getHash(), transaction.getTransactionInfo().get().getHash().get());
}
use of io.nem.symbol.sdk.api.Listener in project nem2-sdk-java by nemtech.
the class TransactionServiceTest method setup.
@BeforeEach
void setup() {
account = Account.generateNewAccount(networkType);
RepositoryFactory factory = Mockito.mock(RepositoryFactory.class);
transactionRepositoryMock = Mockito.mock(TransactionRepository.class);
Mockito.when(factory.createTransactionRepository()).thenReturn(transactionRepositoryMock);
receiptRepositoryMock = Mockito.mock(ReceiptRepository.class);
Mockito.when(factory.createReceiptRepository()).thenReturn(receiptRepositoryMock);
listener = Mockito.mock(Listener.class);
service = new TransactionServiceImpl(factory);
}
Aggregations