use of io.nem.symbol.sdk.openapi.okhttp_gson.model.TransactionInfoDTO in project nem2-sdk-java by nemtech.
the class TransactionMapperOkHttpTest method validateAggregateTransaction.
void validateAggregateTransaction(AggregateTransaction aggregateTransaction, TransactionInfoDTO transactionDto) {
AggregateTransactionBodyExtendedDTO aggregateTransactionBodyDTO = jsonHelper.convert(transactionDto.getTransaction(), AggregateTransactionBodyExtendedDTO.class);
TransactionMetaDTO meta = jsonHelper.convert(transactionDto.getMeta(), TransactionMetaDTO.class);
if (aggregateTransaction.getTransactionInfo().isPresent()) {
TransactionInfo transactionInfo = aggregateTransaction.getTransactionInfo().get();
assertEquals(meta.getHeight(), transactionInfo.getHeight());
if (transactionInfo.getHash().isPresent()) {
assertEquals(meta.getHash(), transactionInfo.getHash().get());
}
if (transactionInfo.getMerkleComponentHash().isPresent()) {
assertEquals(meta.getMerkleComponentHash(), transactionInfo.getMerkleComponentHash().get());
}
if (transactionInfo.getIndex().isPresent()) {
assertEquals(transactionInfo.getIndex().get(), meta.getIndex());
}
}
assertEquals(jsonHelper.getString(transactionDto.getTransaction(), "signature"), aggregateTransaction.getSignature().get());
assertEquals(jsonHelper.getString(transactionDto.getTransaction(), "signerPublicKey"), aggregateTransaction.getSigner().get().getPublicKey().toHex());
int version = jsonHelper.getInteger(transactionDto.getTransaction(), "version");
assertEquals((int) aggregateTransaction.getVersion(), version);
int networkType = jsonHelper.getInteger(transactionDto.getTransaction(), "network");
assertEquals(aggregateTransaction.getNetworkType().getValue(), networkType);
assertEquals(aggregateTransaction.getType().getValue(), (int) jsonHelper.getInteger(transactionDto.getTransaction(), "type"));
assertEquals(jsonHelper.getBigInteger(transactionDto.getTransaction(), "maxFee"), aggregateTransaction.getMaxFee());
assertNotNull(aggregateTransaction.getDeadline());
assertEquals(aggregateTransactionBodyDTO.getCosignatures().get(0).getSignature(), aggregateTransaction.getCosignatures().get(0).getSignature());
assertEquals(aggregateTransactionBodyDTO.getCosignatures().get(0).getSignerPublicKey(), aggregateTransaction.getCosignatures().get(0).getSigner().getPublicKey().toHex());
Transaction innerTransaction = aggregateTransaction.getInnerTransactions().get(0);
validateStandaloneTransaction(innerTransaction, jsonHelper.convert(aggregateTransactionBodyDTO.getTransactions().get(0), TransactionInfoDTO.class), transactionDto);
}
use of io.nem.symbol.sdk.openapi.okhttp_gson.model.TransactionInfoDTO in project nem2-sdk-java by nemtech.
the class TransactionRepositoryOkHttpImplTest method shouldGetTransactions.
@Test
public void shouldGetTransactions() throws Exception {
TransactionInfoDTO transactionInfoDTO = loadTransactionInfoDTO("aggregateMosaicCreationTransaction.json", TransactionInfoDTO.class);
String hash = jsonHelper.getString(transactionInfoDTO, "meta", "hash");
mockRemoteCall(Collections.singletonList(transactionInfoDTO));
Transaction transaction = repository.getTransactions(TransactionGroup.CONFIRMED, Collections.singletonList(hash)).toFuture().get().get(0);
Assertions.assertNotNull(transaction);
Assertions.assertEquals(hash, transaction.getTransactionInfo().get().getHash().get());
Assertions.assertEquals(TransactionGroup.CONFIRMED, transaction.getGroup().get());
}
use of io.nem.symbol.sdk.openapi.okhttp_gson.model.TransactionInfoDTO 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.openapi.okhttp_gson.model.TransactionInfoDTO 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.openapi.okhttp_gson.model.TransactionInfoDTO in project nem2-sdk-java by nemtech.
the class OkHttpAggregateTransactionTest method shouldFindAccountInAsASignerOfTheTransaction.
@Test
void shouldFindAccountInAsASignerOfTheTransaction() {
TransactionInfoDTO aggregateTransferTransactionDTO = TestHelperOkHttp.loadTransactionInfoDTO("accountInAsASignerOfTheTransaction.json");
AggregateTransaction aggregateTransferTransaction = (AggregateTransaction) new GeneralTransactionMapper(jsonHelper).mapFromDto(aggregateTransferTransactionDTO);
assertTrue(aggregateTransferTransaction.signedByAccount(PublicAccount.createFromPublicKey("A5F82EC8EBB341427B6785C8111906CD0DF18838FB11B51CE0E18B5E79DFF630", networkType)));
assertTrue(aggregateTransferTransaction.signedByAccount(PublicAccount.createFromPublicKey("7681ED5023141D9CDCF184E5A7B60B7D466739918ED5DA30F7E71EA7B86EFF2D", networkType)));
assertFalse(aggregateTransferTransaction.signedByAccount(PublicAccount.createFromPublicKey("B4F12E7C9F6946091E2CB8B6D3A12B50D17CCBBF646386EA27CE2946A7423DCF", networkType)));
}
Aggregations