use of io.nem.symbol.sdk.model.transaction.Transaction in project nem2-sdk-java by nemtech.
the class ListenerOkHttpTest method confirmedUsingHashUsingAlias.
@Test
public void confirmedUsingHashUsingAlias() throws InterruptedException, ExecutionException, TimeoutException {
simulateWebSocketStartup();
TransactionInfoDTO transactionInfo = TestHelperOkHttp.loadTransactionInfoDTO("aggregateMosaicCreationTransaction.json");
JsonObject transactionInfoDtoJsonObject = jsonHelper.convert(transactionInfo, JsonObject.class);
Address address = Address.createFromPublicKey(jsonHelper.getString(transactionInfoDtoJsonObject, "transaction", "signerPublicKey"), networkType);
NamespaceId alias = NamespaceId.createFromId(BigInteger.TEN);
String channelName = ListenerChannel.CONFIRMED_ADDED.toString();
List<Transaction> transactions = new ArrayList<>();
List<Throwable> exceptions = new ArrayList<>();
listener.confirmedOrError(alias, getHash(transactionInfo)).doOnError(exceptions::add).forEach(transactions::add);
handle(transactionInfoDtoJsonObject, channelName + "/" + alias.plain());
Assertions.assertEquals(1, transactions.size());
Assertions.assertEquals(0, exceptions.size());
Assertions.assertEquals(address, transactions.get(0).getSigner().get().getAddress());
Mockito.verify(webSocketMock).send(jsonHelper.print(new ListenerSubscribeMessage(this.wsId, channelName + "/" + alias.plain())));
Mockito.verify(webSocketMock).send(jsonHelper.print(new ListenerSubscribeMessage(this.wsId, "status" + "/" + alias.plain())));
}
use of io.nem.symbol.sdk.model.transaction.Transaction in project nem2-sdk-java by nemtech.
the class ListenerOkHttpTest method confirmedUsingHashRaiseError.
@Test
public void confirmedUsingHashRaiseError() throws InterruptedException, ExecutionException, TimeoutException {
simulateWebSocketStartup();
TransactionInfoDTO transactionInfo = TestHelperOkHttp.loadTransactionInfoDTO("aggregateMosaicCreationTransaction.json");
JsonObject transactionInfoDtoJsonObject = jsonHelper.convert(transactionInfo, JsonObject.class);
Address address = Address.createFromPublicKey(jsonHelper.getString(transactionInfoDtoJsonObject, "transaction", "signerPublicKey"), networkType);
String channelName = ListenerChannel.CONFIRMED_ADDED.toString();
Map<String, Object> transactionStatusError = new HashMap<>();
transactionStatusError.put("address", address.encoded());
transactionStatusError.put("code", "Fail 666");
transactionStatusError.put("hash", getHash(transactionInfo));
transactionStatusError.put("deadline", 123);
List<Transaction> transactions = new ArrayList<>();
List<Throwable> exceptions = new ArrayList<>();
listener.confirmedOrError(address, getHash(transactionInfo)).doOnError(exceptions::add).forEach(transactions::add);
handle(transactionStatusError, "status/" + address.plain());
Assertions.assertEquals(0, transactions.size());
Assertions.assertEquals(1, exceptions.size());
Assertions.assertEquals(TransactionStatusException.class, exceptions.get(0).getClass());
Assertions.assertEquals("Fail 666 processing transaction " + getHash(transactionInfo), exceptions.get(0).getMessage());
Mockito.verify(webSocketMock).send(jsonHelper.print(new ListenerSubscribeMessage(this.wsId, channelName + "/" + address.plain())));
Mockito.verify(webSocketMock).send(jsonHelper.print(new ListenerSubscribeMessage(this.wsId, "status" + "/" + address.plain())));
}
use of io.nem.symbol.sdk.model.transaction.Transaction in project nem2-sdk-java by nemtech.
the class TransactionRepositoryOkHttpImplTest method shouldGetTransactionPartial.
@Test
public void shouldGetTransactionPartial() throws Exception {
TransactionInfoDTO transactionInfoDTO = 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 TransactionRepositoryOkHttpImplTest method searchTransactions.
@Test
public void searchTransactions() throws Exception {
BigInteger version = AggregateTransactionCosignature.DEFAULT_VERSION;
TransactionInfoDTO transferTransactionDTO = loadTransactionInfoDTO("standaloneTransferTransaction.json", TransactionInfoDTO.class);
PublicAccount publicAccount = Account.generateNewAccount(networkType).getPublicAccount();
mockRemoteCall(toPage(transferTransactionDTO));
Page<Transaction> transactions = repository.search(new TransactionSearchCriteria(TransactionGroup.UNCONFIRMED).signerPublicKey(publicAccount.getPublicKey())).toFuture().get();
Assertions.assertEquals(TransactionType.TRANSFER, transactions.getData().get(0).getType());
Assertions.assertEquals(TransactionGroup.UNCONFIRMED, 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 TransactionRepositoryOkHttpImplTest method shouldGetTransaction.
@Test
public void shouldGetTransaction() throws Exception {
TransactionInfoDTO transactionInfoDTO = 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());
}
Aggregations