use of com.hedera.mirror.common.domain.entity.Entity in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerFileTest method fileSystemDeleteTransaction.
@Test
void fileSystemDeleteTransaction() {
Transaction systemDeleteTransaction = systemDeleteTransaction();
TransactionBody transactionBody = getTransactionBody(systemDeleteTransaction);
TransactionRecord record = transactionRecord(transactionBody);
parseRecordItemAndCommit(new RecordItem(systemDeleteTransaction, record));
Entity fileEntity = getTransactionEntity(record.getConsensusTimestamp());
assertAll(() -> assertRowCountOnSuccessNoData(FILE_ID), () -> assertTransactionAndRecord(transactionBody, record), () -> assertThat(fileEntity).isNotNull().extracting(Entity::getDeleted).isEqualTo(true));
}
use of com.hedera.mirror.common.domain.entity.Entity in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerFileTest method fileDeleteToExisting.
@Test
void fileDeleteToExisting() {
// first create the file
Transaction fileCreateTransaction = fileCreateTransaction();
TransactionBody createTransactionBody = getTransactionBody(fileCreateTransaction);
TransactionRecord recordCreate = transactionRecord(createTransactionBody);
parseRecordItemAndCommit(new RecordItem(fileCreateTransaction, recordCreate));
// now update
Transaction transaction = fileDeleteTransaction();
TransactionBody transactionBody = getTransactionBody(transaction);
TransactionRecord record = transactionRecord(transactionBody);
parseRecordItemAndCommit(new RecordItem(transaction, record));
Entity dbFileEntity = getTransactionEntity(record.getConsensusTimestamp());
assertAll(() -> assertEquals(2, transactionRepository.count()), () -> assertEntities(EntityId.of(FILE_ID)), () -> assertEquals(0, contractResultRepository.count()), () -> assertEquals(6, cryptoTransferRepository.count()), () -> assertEquals(0, liveHashRepository.count()), () -> assertEquals(1, fileDataRepository.count()), () -> assertTransactionAndRecord(transactionBody, record), // Additional entity checks
() -> assertTrue(dbFileEntity.getDeleted()), () -> assertNotNull(dbFileEntity.getKey()), () -> assertNotNull(dbFileEntity.getExpirationTimestamp()), () -> assertNull(dbFileEntity.getAutoRenewPeriod()), () -> assertNull(dbFileEntity.getProxyAccountId()));
}
use of com.hedera.mirror.common.domain.entity.Entity in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerFileTest method fileUpdateExpiryToNew.
@Test
void fileUpdateExpiryToNew() {
Transaction transaction = fileUpdateExpiryTransaction();
TransactionBody transactionBody = getTransactionBody(transaction);
TransactionRecord record = transactionRecord(transactionBody);
parseRecordItemAndCommit(new RecordItem(transaction, record));
Entity actualFile = getTransactionEntity(record.getConsensusTimestamp());
assertAll(// TODO: Review row count in fileDataRepository with issue #294, probably should be 0
() -> assertRowCountOnSuccess(FILE_ID), () -> assertTransactionAndRecord(transactionBody, record), // Additional entity checks
() -> assertFalse(actualFile.getDeleted()), () -> assertEquals(DomainUtils.timeStampInNanos(transactionBody.getFileUpdate().getExpirationTime()), actualFile.getExpirationTimestamp()), () -> assertNull(actualFile.getKey()), () -> assertNull(actualFile.getAutoRenewPeriod()), () -> assertNull(actualFile.getProxyAccountId()));
}
use of com.hedera.mirror.common.domain.entity.Entity in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerFileTest method fileUpdateContentsToExisting.
@Test
void fileUpdateContentsToExisting() {
// first create the file
Transaction fileCreateTransaction = fileCreateTransaction();
TransactionBody createTransactionBody = getTransactionBody(fileCreateTransaction);
TransactionRecord recordCreate = transactionRecord(createTransactionBody);
parseRecordItemAndCommit(new RecordItem(fileCreateTransaction, recordCreate));
// now update
Transaction transaction = fileUpdateContentsTransaction();
TransactionBody transactionBody = getTransactionBody(transaction);
TransactionRecord record = transactionRecord(transactionBody);
parseRecordItemAndCommit(new RecordItem(transaction, record));
Entity actualFile = getTransactionEntity(record.getConsensusTimestamp());
assertAll(() -> assertRowCountOnTwoFileTransactions(), () -> assertTransactionAndRecord(transactionBody, record), () -> assertFileData(transactionBody.getFileUpdate().getContents(), record.getConsensusTimestamp()), // Additional entity checks
() -> assertFalse(actualFile.getDeleted()), () -> assertNotNull(actualFile.getExpirationTimestamp()), () -> assertNotNull(actualFile.getKey()), () -> assertNull(actualFile.getAutoRenewPeriod()), () -> assertNull(actualFile.getProxyAccountId()));
}
use of com.hedera.mirror.common.domain.entity.Entity in project hedera-mirror-node by hashgraph.
the class AbstractTransactionHandlerTest method getExpectedUpdatedEntity.
protected AbstractEntity getExpectedUpdatedEntity() {
AbstractEntity entity = getExpectedEntityWithTimestamp();
TransactionBody defaultBody = getDefaultTransactionBody().build();
Message innerBody = getInnerBody(defaultBody);
List<String> fieldNames = innerBody.getDescriptorForType().getFields().stream().map(FieldDescriptor::getName).collect(Collectors.toList());
for (String fieldName : fieldNames) {
switch(fieldName) {
case "adminKey":
entity.setKey(DEFAULT_KEY.toByteArray());
break;
case "autoRenewPeriod":
entity.setAutoRenewPeriod(DEFAULT_AUTO_RENEW_PERIOD.getSeconds());
break;
case "expiry":
case "expirationTime":
entity.setExpirationTimestamp(DomainUtils.timestampInNanosMax(DEFAULT_EXPIRATION_TIME));
break;
case "keys":
entity.setKey(DEFAULT_KEY_LIST.toByteArray());
break;
case "receiverSigRequired":
if (entity instanceof Entity) {
((Entity) entity).setReceiverSigRequired(DEFAULT_RECEIVER_SIG_REQUIRED);
}
break;
case "submitKey":
if (entity instanceof Entity) {
((Entity) entity).setSubmitKey(DEFAULT_SUBMIT_KEY.toByteArray());
}
break;
default:
break;
}
}
return entity;
}
Aggregations