use of io.nem.symbol.sdk.model.transaction.Transaction in project nem2-sdk-java by nemtech.
the class TransactionMapperOkHttpTest method shouldCreateAggregateTransferTransaction.
@Test
void shouldCreateAggregateTransferTransaction() {
TransactionInfoDTO aggregateTransferTransactionDTO = TestHelperOkHttp.loadTransactionInfoDTO("aggregateTransferTransaction.json");
Transaction aggregateTransferTransaction = map(aggregateTransferTransactionDTO);
validateAggregateTransaction((AggregateTransaction) aggregateTransferTransaction, aggregateTransferTransactionDTO);
}
use of io.nem.symbol.sdk.model.transaction.Transaction in project nem2-sdk-java by nemtech.
the class TransactionMapperOkHttpTest method shouldCreateStandaloneMosaicSupplyChangeTransaction.
@Test
void shouldCreateStandaloneMosaicSupplyChangeTransaction() {
TransactionInfoDTO mosaicSupplyChangeTransactionDTO = TestHelperOkHttp.loadTransactionInfoDTO("standaloneMosaicSupplyChangeTransaction.json");
Transaction mosaicSupplyChangeTransaction = map(mosaicSupplyChangeTransactionDTO);
validateStandaloneTransaction(mosaicSupplyChangeTransaction, mosaicSupplyChangeTransactionDTO);
}
use of io.nem.symbol.sdk.model.transaction.Transaction 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.model.transaction.Transaction in project nem2-sdk-java by nemtech.
the class JsonSerializationOkHttpTest method jsonToTransaction.
@Test
public void jsonToTransaction() {
String json = TestHelperOkHttp.loadResource("transaction-aggregateTransferTransaction.json");
Transaction transaction = jsonSerialization.jsonToTransaction(json);
Assertions.assertNotNull(transaction);
String mappedJson = jsonSerialization.transactionToJson(transaction);
Assertions.assertNotNull(mappedJson);
}
use of io.nem.symbol.sdk.model.transaction.Transaction in project nem2-sdk-java by nemtech.
the class AccountRepositoryIntegrationTest method outgoingTransactions.
@ParameterizedTest
@EnumSource(RepositoryType.class)
void outgoingTransactions(RepositoryType type) {
TransactionRepository transactionRepository = getRepositoryFactory(type).createTransactionRepository();
PublicAccount recipient = this.helper().getTestAccount(type).getLeft().getPublicAccount();
List<Transaction> transactions = get(transactionRepository.search(new TransactionSearchCriteria(TransactionGroup.CONFIRMED).transactionTypes(Collections.singletonList(TransactionType.TRANSFER)).recipientAddress(recipient.getAddress()))).getData();
System.out.println(transactions.size());
transactions.forEach(transaction -> {
assertTransaction(transaction, null);
TransferTransaction transferTransaction = (TransferTransaction) transaction;
Assertions.assertEquals(recipient.getAddress(), transferTransaction.getRecipient());
});
}
Aggregations