use of io.nem.symbol.sdk.model.transaction.Transaction in project nem2-sdk-java by nemtech.
the class TransactionRepositoryVertxImplTest method shouldGetTransactionConfirmed.
@Test
public void shouldGetTransactionConfirmed() throws Exception {
TransactionInfoDTO transactionInfoDTO = TestHelperVertx.loadTransactionInfoDTO("aggregateMosaicCreationTransaction.json", TransactionInfoDTO.class);
String hash = jsonHelper.getString(transactionInfoDTO, "meta", "hash");
mockRemoteCall(transactionInfoDTO);
Transaction transaction = repository.getTransaction(TransactionGroup.CONFIRMED, hash).toFuture().get();
Assertions.assertNotNull(transaction);
Assertions.assertEquals(hash, transaction.getTransactionInfo().get().getHash().get());
Assertions.assertEquals(TransactionGroup.CONFIRMED, transaction.getGroup().get());
}
use of io.nem.symbol.sdk.model.transaction.Transaction in project nem2-sdk-java by nemtech.
the class TransactionRepositoryVertxImplTest method shouldGetTransactionPartial.
@Test
public void shouldGetTransactionPartial() throws Exception {
TransactionInfoDTO transactionInfoDTO = TestHelperVertx.loadTransactionInfoDTO("aggregateMosaicCreationTransaction.json", TransactionInfoDTO.class);
String hash = jsonHelper.getString(transactionInfoDTO, "meta", "hash");
mockRemoteCall(transactionInfoDTO);
Transaction transaction = repository.getTransaction(TransactionGroup.PARTIAL, hash).toFuture().get();
Assertions.assertNotNull(transaction);
Assertions.assertEquals(hash, transaction.getTransactionInfo().get().getHash().get());
Assertions.assertEquals(TransactionGroup.PARTIAL, transaction.getGroup().get());
}
use of io.nem.symbol.sdk.model.transaction.Transaction 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());
}
use of io.nem.symbol.sdk.model.transaction.Transaction in project nem2-sdk-java by nemtech.
the class TransactionMapperVertxTest method shouldCreateAggregateMosaicCreationTransaction.
@Test
void shouldCreateAggregateMosaicCreationTransaction() {
TransactionInfoDTO aggregateMosaicCreationTransactionDTO = TestHelperVertx.loadTransactionInfoDTO("aggregateMosaicCreationTransaction.json");
Transaction aggregateMosaicCreationTransaction = map(aggregateMosaicCreationTransactionDTO);
validateAggregateTransaction((AggregateTransaction) aggregateMosaicCreationTransaction, aggregateMosaicCreationTransactionDTO);
}
use of io.nem.symbol.sdk.model.transaction.Transaction in project nem2-sdk-java by nemtech.
the class ListenerVertxTest method subscribeOnHash.
@ParameterizedTest
@ValueSource(strings = { "CONFIRMED_ADDED", "AGGREGATE_BONDED_ADDED" })
public void subscribeOnHash(ListenerChannel channel) throws InterruptedException, ExecutionException, TimeoutException {
simulateWebSocketStartup();
TransactionInfoDTO transactionInfo = TestHelperVertx.loadTransactionInfoDTO("aggregateMosaicCreationTransaction.json");
ObjectNode transactionInfoDtoJsonObject = jsonHelper.convert(transactionInfo, ObjectNode.class);
Address address = Address.createFromPublicKey(jsonHelper.getString(transactionInfoDtoJsonObject, "transaction", "signerPublicKey"), NETWORK_TYPE);
String channelName = channel.toString();
List<Transaction> transactions = new ArrayList<>();
List<Throwable> exceptions = new ArrayList<>();
BiFunction<Address, String, Observable<? extends Transaction>> subscriber = channel == ListenerChannel.CONFIRMED_ADDED ? listener::confirmedOrError : listener::aggregateBondedAddedOrError;
TransactionMetaDTO meta = jsonHelper.convert(transactionInfo.getMeta(), TransactionMetaDTO.class);
subscriber.apply(address, meta.getHash()).doOnError(exceptions::add).forEach(transactions::add);
handle(transactionInfoDtoJsonObject, channel.toString() + "/" + address.plain());
Assertions.assertEquals(1, transactions.size());
Assertions.assertEquals(0, exceptions.size());
Assertions.assertEquals(address, transactions.get(0).getSigner().get().getAddress());
Mockito.verify(webSocketMock).handler(Mockito.any());
Mockito.verify(webSocketMock).writeTextMessage(jsonHelper.print(new ListenerSubscribeMessage(this.wsId, channelName + "/" + address.plain())));
Mockito.verify(webSocketMock).writeTextMessage(jsonHelper.print(new ListenerSubscribeMessage(this.wsId, "status" + "/" + address.plain())));
}
Aggregations