Search in sources :

Example 36 with Transaction

use of com.hedera.mirror.common.domain.transaction.Transaction in project hedera-mirror-node by hashgraph.

the class CryptoApproveAllowanceTransactionHandlerTest method updateTransactionWithAliasNotFoundAndPartialDataActionSkip.

@Test
void updateTransactionWithAliasNotFoundAndPartialDataActionSkip() {
    recordParserProperties.setPartialDataAction(PartialDataAction.SKIP);
    var alias = DomainUtils.fromBytes(domainBuilder.key());
    var recordItem = recordItemBuilder.cryptoApproveAllowance().transactionBody(b -> {
        b.getCryptoAllowancesBuilderList().forEach(builder -> builder.getOwnerBuilder().setAlias(alias));
        b.getNftAllowancesBuilderList().forEach(builder -> builder.getOwnerBuilder().setAlias(alias));
        b.getTokenAllowancesBuilderList().forEach(builder -> builder.getOwnerBuilder().setAlias(alias));
    }).build();
    var transaction = domainBuilder.transaction().get();
    when(entityIdService.lookup(AccountID.newBuilder().setAlias(alias).build())).thenThrow(new AliasNotFoundException("alias", EntityType.ACCOUNT));
    transactionHandler.updateTransaction(transaction, recordItem);
    verifyNoInteractions(entityListener);
}
Also used : NftId(com.hedera.mirror.common.domain.token.NftId) BeforeEach(org.junit.jupiter.api.BeforeEach) PartialDataAction(com.hedera.mirror.importer.parser.PartialDataAction) EntityId(com.hedera.mirror.common.domain.entity.EntityId) BoolValue(com.google.protobuf.BoolValue) EnumSource(org.junit.jupiter.params.provider.EnumSource) EntityType(com.hedera.mirror.common.domain.entity.EntityType) Mockito.verifyNoInteractions(org.mockito.Mockito.verifyNoInteractions) RecordParserProperties(com.hedera.mirror.importer.parser.record.RecordParserProperties) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) AliasNotFoundException(com.hedera.mirror.importer.exception.AliasNotFoundException) TestUtils(com.hedera.mirror.importer.TestUtils) AccountID(com.hederahashgraph.api.proto.java.AccountID) DomainUtils(com.hedera.mirror.common.util.DomainUtils) ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) Range(com.google.common.collect.Range) Mockito.times(org.mockito.Mockito.times) CryptoAllowance(com.hedera.mirror.common.domain.entity.CryptoAllowance) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) NftAllowance(com.hedera.mirror.common.domain.entity.NftAllowance) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Nft(com.hedera.mirror.common.domain.token.Nft) TokenID(com.hederahashgraph.api.proto.java.TokenID) Assertions(org.junit.jupiter.api.Assertions) TokenAllowance(com.hedera.mirror.common.domain.entity.TokenAllowance) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) Transaction(com.hedera.mirror.common.domain.transaction.Transaction) CryptoApproveAllowanceTransactionBody(com.hederahashgraph.api.proto.java.CryptoApproveAllowanceTransactionBody) AliasNotFoundException(com.hedera.mirror.importer.exception.AliasNotFoundException) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 37 with Transaction

use of com.hedera.mirror.common.domain.transaction.Transaction in project hedera-mirror-node by hashgraph.

the class CryptoDeleteAllowanceTransactionHandlerTest method updateTransactionUnsuccessful.

@Test
void updateTransactionUnsuccessful() {
    var transaction = new Transaction();
    RecordItem recordItem = recordItemBuilder.cryptoDeleteAllowance().receipt(r -> r.setStatus(ResponseCodeEnum.ACCOUNT_DELETED)).build();
    transactionHandler.updateTransaction(transaction, recordItem);
    verifyNoInteractions(entityListener);
}
Also used : CryptoDeleteAllowanceTransactionBody(com.hederahashgraph.api.proto.java.CryptoDeleteAllowanceTransactionBody) ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Mockito.times(org.mockito.Mockito.times) EntityType(com.hedera.mirror.common.domain.entity.EntityType) Mockito.verify(org.mockito.Mockito.verify) Mockito.verifyNoInteractions(org.mockito.Mockito.verifyNoInteractions) Test(org.junit.jupiter.api.Test) Nft(com.hedera.mirror.common.domain.token.Nft) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) NftRemoveAllowance(com.hederahashgraph.api.proto.java.NftRemoveAllowance) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) Transaction(com.hedera.mirror.common.domain.transaction.Transaction) Transaction(com.hedera.mirror.common.domain.transaction.Transaction) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) Test(org.junit.jupiter.api.Test)

Aggregations

Transaction (com.hedera.mirror.common.domain.transaction.Transaction)37 Test (org.junit.jupiter.api.Test)24 EntityId (com.hedera.mirror.common.domain.entity.EntityId)23 TransactionBody (com.hederahashgraph.api.proto.java.TransactionBody)19 RecordItem (com.hedera.mirror.common.domain.transaction.RecordItem)18 DomainUtils (com.hedera.mirror.common.util.DomainUtils)17 ResponseCodeEnum (com.hederahashgraph.api.proto.java.ResponseCodeEnum)17 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)17 EntityType (com.hedera.mirror.common.domain.entity.EntityType)16 AccountID (com.hederahashgraph.api.proto.java.AccountID)16 Mockito.verify (org.mockito.Mockito.verify)16 RecordParserProperties (com.hedera.mirror.importer.parser.record.RecordParserProperties)15 Mockito.verifyNoInteractions (org.mockito.Mockito.verifyNoInteractions)15 Range (com.google.common.collect.Range)14 AliasNotFoundException (com.hedera.mirror.importer.exception.AliasNotFoundException)14 PartialDataAction (com.hedera.mirror.importer.parser.PartialDataAction)14 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)14 Assertions (org.junit.jupiter.api.Assertions)14 EnumSource (org.junit.jupiter.params.provider.EnumSource)14 Mockito.when (org.mockito.Mockito.when)14