Search in sources :

Example 26 with Entity

use of com.hedera.mirror.common.domain.entity.Entity in project hedera-mirror-node by hashgraph.

the class CryptoUpdateTransactionHandlerTest method updateTransactionDeclineReward.

@Test
void updateTransactionDeclineReward() {
    RecordItem withDeclineValueSet = recordItemBuilder.cryptoUpdate().transactionBody(body -> body.clear().setDeclineReward(BoolValue.of(true))).build();
    setupForCrytoUpdateTransactionTest(withDeclineValueSet, t -> assertThat(t).returns(true, Entity::isDeclineReward).returns(null, Entity::getStakedNodeId).returns(null, Entity::getStakedAccountId).extracting(Entity::getStakePeriodStart).isNotNull());
}
Also used : CryptoUpdateTransactionBody(com.hederahashgraph.api.proto.java.CryptoUpdateTransactionBody) BoolValue(com.google.protobuf.BoolValue) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Range(com.google.common.collect.Range) Mockito.times(org.mockito.Mockito.times) EntityType(com.hedera.mirror.common.domain.entity.EntityType) Mockito.verify(org.mockito.Mockito.verify) Entity(com.hedera.mirror.common.domain.entity.Entity) Consumer(java.util.function.Consumer) Test(org.junit.jupiter.api.Test) RecordParserProperties(com.hedera.mirror.importer.parser.record.RecordParserProperties) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) Assertions(org.junit.jupiter.api.Assertions) ACCOUNT(com.hedera.mirror.common.domain.entity.EntityType.ACCOUNT) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) AccountID(com.hederahashgraph.api.proto.java.AccountID) Utility(com.hedera.mirror.importer.util.Utility) Entity(com.hedera.mirror.common.domain.entity.Entity) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) Test(org.junit.jupiter.api.Test)

Example 27 with Entity

use of com.hedera.mirror.common.domain.entity.Entity in project hedera-mirror-node by hashgraph.

the class CryptoUpdateTransactionHandlerTest method updateTransactionStakedAccountId.

@Test
void updateTransactionStakedAccountId() {
    AccountID accountId = AccountID.newBuilder().setAccountNum(1L).build();
    RecordItem withStakedNodeIdSet = recordItemBuilder.cryptoUpdate().transactionBody(body -> body.clear().setStakedAccountId(accountId)).build();
    setupForCrytoUpdateTransactionTest(withStakedNodeIdSet, t -> assertThat(t).returns(1L, Entity::getStakedAccountId).returns(false, Entity::isDeclineReward).returns(-1L, Entity::getStakedNodeId).returns(Utility.getEpochDay(withStakedNodeIdSet.getConsensusTimestamp()), Entity::getStakePeriodStart));
}
Also used : CryptoUpdateTransactionBody(com.hederahashgraph.api.proto.java.CryptoUpdateTransactionBody) BoolValue(com.google.protobuf.BoolValue) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Range(com.google.common.collect.Range) Mockito.times(org.mockito.Mockito.times) EntityType(com.hedera.mirror.common.domain.entity.EntityType) Mockito.verify(org.mockito.Mockito.verify) Entity(com.hedera.mirror.common.domain.entity.Entity) Consumer(java.util.function.Consumer) Test(org.junit.jupiter.api.Test) RecordParserProperties(com.hedera.mirror.importer.parser.record.RecordParserProperties) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) Assertions(org.junit.jupiter.api.Assertions) ACCOUNT(com.hedera.mirror.common.domain.entity.EntityType.ACCOUNT) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) AccountID(com.hederahashgraph.api.proto.java.AccountID) Utility(com.hedera.mirror.importer.util.Utility) Entity(com.hedera.mirror.common.domain.entity.Entity) AccountID(com.hederahashgraph.api.proto.java.AccountID) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) Test(org.junit.jupiter.api.Test)

Example 28 with Entity

use of com.hedera.mirror.common.domain.entity.Entity in project hedera-mirror-node by hashgraph.

the class EntityRepositoryTest method nullCharacter.

@Test
void nullCharacter() {
    Entity entity = domainBuilder.entity().customize(e -> e.memo("abc" + (char) 0)).persist();
    assertThat(entityRepository.findById(entity.getId())).get().isEqualTo(entity);
}
Also used : ByteString(com.google.protobuf.ByteString) Test(org.junit.jupiter.api.Test) Key(com.hederahashgraph.api.proto.java.Key) List(java.util.List) JdbcOperations(org.springframework.jdbc.core.JdbcOperations) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) DomainBuilder(com.hedera.mirror.common.domain.DomainBuilder) Resource(javax.annotation.Resource) RowMapper(org.springframework.jdbc.core.RowMapper) Entity(com.hedera.mirror.common.domain.entity.Entity) Entity(com.hedera.mirror.common.domain.entity.Entity) Test(org.junit.jupiter.api.Test)

Example 29 with Entity

use of com.hedera.mirror.common.domain.entity.Entity in project hedera-mirror-node by hashgraph.

the class EntityRepositoryTest method findByAlias.

@Test
void findByAlias() {
    Entity entity = domainBuilder.entity().persist();
    byte[] alias = entity.getAlias();
    assertThat(entityRepository.findByAlias(alias)).get().isEqualTo(entity.getId());
}
Also used : Entity(com.hedera.mirror.common.domain.entity.Entity) Test(org.junit.jupiter.api.Test)

Example 30 with Entity

use of com.hedera.mirror.common.domain.entity.Entity in project hedera-mirror-node by hashgraph.

the class EntityRepositoryTest method publicKeyUpdates.

@Test
void publicKeyUpdates() {
    Entity entity = domainBuilder.entity().customize(b -> b.key(null)).persist();
    // unset key should result in null public key
    assertThat(entityRepository.findById(entity.getId())).get().extracting(Entity::getPublicKey).isNull();
    // default proto key of single byte should result in empty public key
    entity.setKey(Key.getDefaultInstance().toByteArray());
    entityRepository.save(entity);
    assertThat(entityRepository.findById(entity.getId())).get().extracting(Entity::getPublicKey).isEqualTo("");
    // invalid key should be null
    entity.setKey("123".getBytes());
    entityRepository.save(entity);
    assertThat(entityRepository.findById(entity.getId())).get().extracting(Entity::getPublicKey).isNull();
    // valid key should not be null
    entity.setKey(Key.newBuilder().setEd25519(ByteString.copyFromUtf8("123")).build().toByteArray());
    entityRepository.save(entity);
    assertThat(entityRepository.findById(entity.getId())).get().extracting(Entity::getPublicKey).isNotNull();
    // null key like unset should result in null public key
    entity.setKey(null);
    entityRepository.save(entity);
    assertThat(entityRepository.findById(entity.getId())).get().extracting(Entity::getPublicKey).isNull();
}
Also used : ByteString(com.google.protobuf.ByteString) Test(org.junit.jupiter.api.Test) Key(com.hederahashgraph.api.proto.java.Key) List(java.util.List) JdbcOperations(org.springframework.jdbc.core.JdbcOperations) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) DomainBuilder(com.hedera.mirror.common.domain.DomainBuilder) Resource(javax.annotation.Resource) RowMapper(org.springframework.jdbc.core.RowMapper) Entity(com.hedera.mirror.common.domain.entity.Entity) Entity(com.hedera.mirror.common.domain.entity.Entity) Test(org.junit.jupiter.api.Test)

Aggregations

Entity (com.hedera.mirror.common.domain.entity.Entity)78 Test (org.junit.jupiter.api.Test)52 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)40 RecordItem (com.hedera.mirror.common.domain.transaction.RecordItem)23 TransactionBody (com.hederahashgraph.api.proto.java.TransactionBody)22 IntegrationTest (com.hedera.mirror.importer.IntegrationTest)21 Transaction (com.hederahashgraph.api.proto.java.Transaction)19 TransactionRecord (com.hederahashgraph.api.proto.java.TransactionRecord)16 AbstractEntity (com.hedera.mirror.common.domain.entity.AbstractEntity)15 EntityId (com.hedera.mirror.common.domain.entity.EntityId)15 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)14 AccountID (com.hederahashgraph.api.proto.java.AccountID)11 CryptoUpdateTransactionBody (com.hederahashgraph.api.proto.java.CryptoUpdateTransactionBody)10 ByteString (com.google.protobuf.ByteString)9 Contract (com.hedera.mirror.common.domain.contract.Contract)9 FileAppendTransactionBody (com.hederahashgraph.api.proto.java.FileAppendTransactionBody)9 FileCreateTransactionBody (com.hederahashgraph.api.proto.java.FileCreateTransactionBody)9 FileUpdateTransactionBody (com.hederahashgraph.api.proto.java.FileUpdateTransactionBody)9 Resource (javax.annotation.Resource)9 Assertions (org.junit.jupiter.api.Assertions)9