Search in sources :

Example 1 with TOKEN

use of com.hedera.mirror.monitor.publish.transaction.account.CryptoTransferTransactionSupplier.TransferType.TOKEN in project hedera-mirror-node by hashgraph.

the class CryptoTransferTransactionSupplierTest method createWithCustomAllTransfer.

@Test
void createWithCustomAllTransfer() {
    TokenId nftTokenId = TokenId.fromString("0.0.21");
    Hbar transferAmount = Hbar.fromTinybars(2);
    CryptoTransferTransactionSupplier cryptoTransferTransactionSupplier = new CryptoTransferTransactionSupplier();
    cryptoTransferTransactionSupplier.setAmount(2);
    cryptoTransferTransactionSupplier.setMaxTransactionFee(1);
    cryptoTransferTransactionSupplier.setNftTokenId(nftTokenId.toString());
    cryptoTransferTransactionSupplier.setRecipientAccountId(ACCOUNT_ID_2.toString());
    cryptoTransferTransactionSupplier.setSenderAccountId(ACCOUNT_ID.toString());
    cryptoTransferTransactionSupplier.setSerialNumber(new AtomicLong(10));
    cryptoTransferTransactionSupplier.setTokenId(TOKEN_ID.toString());
    cryptoTransferTransactionSupplier.setTransferTypes(Set.of(CRYPTO, NFT, TOKEN));
    TransferTransaction actual = cryptoTransferTransactionSupplier.get();
    assertThat(actual).returns(ONE_TINYBAR, TransferTransaction::getMaxTransactionFee).satisfies(a -> assertThat(a.getHbarTransfers()).containsEntry(ACCOUNT_ID, transferAmount.negated()).containsEntry(ACCOUNT_ID_2, transferAmount)).satisfies(a -> assertThat(a).extracting(TransferTransaction::getTokenNftTransfers, MAP).hasSize(1).extractingByKey(nftTokenId, LIST).extracting("serial", "sender", "receiver").containsExactlyInAnyOrder(tuple(10L, ACCOUNT_ID, ACCOUNT_ID_2), tuple(11L, ACCOUNT_ID, ACCOUNT_ID_2))).extracting(TransferTransaction::getHbarTransfers, MAP).hasSize(2).containsEntry(ACCOUNT_ID, transferAmount.negated()).containsEntry(ACCOUNT_ID_2, transferAmount);
}
Also used : TokenId(com.hedera.hashgraph.sdk.TokenId) Assertions.tuple(org.assertj.core.api.Assertions.tuple) TransferTransaction(com.hedera.hashgraph.sdk.TransferTransaction) MAP(org.assertj.core.api.InstanceOfAssertFactories.MAP) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) TOKEN(com.hedera.mirror.monitor.publish.transaction.account.CryptoTransferTransactionSupplier.TransferType.TOKEN) Set(java.util.Set) CRYPTO(com.hedera.mirror.monitor.publish.transaction.account.CryptoTransferTransactionSupplier.TransferType.CRYPTO) NFT(com.hedera.mirror.monitor.publish.transaction.account.CryptoTransferTransactionSupplier.TransferType.NFT) Test(org.junit.jupiter.api.Test) AtomicLong(java.util.concurrent.atomic.AtomicLong) LIST(org.assertj.core.api.InstanceOfAssertFactories.LIST) Hbar(com.hedera.hashgraph.sdk.Hbar) Collections(java.util.Collections) AbstractTransactionSupplierTest(com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest) AtomicLong(java.util.concurrent.atomic.AtomicLong) Hbar(com.hedera.hashgraph.sdk.Hbar) TokenId(com.hedera.hashgraph.sdk.TokenId) TransferTransaction(com.hedera.hashgraph.sdk.TransferTransaction) Test(org.junit.jupiter.api.Test) AbstractTransactionSupplierTest(com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest)

Aggregations

Hbar (com.hedera.hashgraph.sdk.Hbar)1 TokenId (com.hedera.hashgraph.sdk.TokenId)1 TransferTransaction (com.hedera.hashgraph.sdk.TransferTransaction)1 AbstractTransactionSupplierTest (com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest)1 CRYPTO (com.hedera.mirror.monitor.publish.transaction.account.CryptoTransferTransactionSupplier.TransferType.CRYPTO)1 NFT (com.hedera.mirror.monitor.publish.transaction.account.CryptoTransferTransactionSupplier.TransferType.NFT)1 TOKEN (com.hedera.mirror.monitor.publish.transaction.account.CryptoTransferTransactionSupplier.TransferType.TOKEN)1 Collections (java.util.Collections)1 Set (java.util.Set)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.tuple (org.assertj.core.api.Assertions.tuple)1 LIST (org.assertj.core.api.InstanceOfAssertFactories.LIST)1 MAP (org.assertj.core.api.InstanceOfAssertFactories.MAP)1 Test (org.junit.jupiter.api.Test)1