Search in sources :

Example 1 with AssessedCustomFeeWrapper

use of com.hedera.mirror.importer.domain.AssessedCustomFeeWrapper in project hedera-mirror-node by hashgraph.

the class BatchInserterTest method assessedCustomFees.

@Test
void assessedCustomFees() {
    long consensusTimestamp = 10L;
    EntityId collectorId1 = EntityId.of("0.0.2000", EntityType.ACCOUNT);
    EntityId collectorId2 = EntityId.of("0.0.2001", EntityType.ACCOUNT);
    EntityId payerId1 = EntityId.of("0.0.3000", EntityType.ACCOUNT);
    EntityId payerId2 = EntityId.of("0.0.3001", EntityType.ACCOUNT);
    EntityId tokenId1 = EntityId.of("0.0.5000", EntityType.TOKEN);
    EntityId tokenId2 = EntityId.of("0.0.5001", EntityType.TOKEN);
    // fee paid in HBAR with empty effective payer list
    AssessedCustomFee assessedCustomFee1 = new AssessedCustomFee();
    assessedCustomFee1.setAmount(10L);
    assessedCustomFee1.setId(new AssessedCustomFee.Id(collectorId1, consensusTimestamp));
    assessedCustomFee1.setPayerAccountId(payerId1);
    AssessedCustomFee assessedCustomFee2 = new AssessedCustomFee();
    assessedCustomFee2.setAmount(20L);
    assessedCustomFee2.setEffectivePayerAccountIds(List.of(payerId1.getId()));
    assessedCustomFee2.setTokenId(tokenId1);
    assessedCustomFee2.setId(new AssessedCustomFee.Id(collectorId2, consensusTimestamp));
    assessedCustomFee2.setPayerAccountId(payerId1);
    AssessedCustomFee assessedCustomFee3 = new AssessedCustomFee();
    assessedCustomFee3.setAmount(30L);
    assessedCustomFee3.setEffectivePayerAccountIds(List.of(payerId1.getId(), payerId2.getId()));
    assessedCustomFee3.setTokenId(tokenId2);
    assessedCustomFee3.setId(new AssessedCustomFee.Id(collectorId2, consensusTimestamp));
    assessedCustomFee3.setPayerAccountId(payerId2);
    List<AssessedCustomFee> assessedCustomFees = List.of(assessedCustomFee1, assessedCustomFee2, assessedCustomFee3);
    // when
    batchInserter.persist(assessedCustomFees);
    // then
    List<AssessedCustomFeeWrapper> actual = jdbcTemplate.query(AssessedCustomFeeWrapper.SELECT_QUERY, AssessedCustomFeeWrapper.ROW_MAPPER);
    assertThat(actual).map(AssessedCustomFeeWrapper::getAssessedCustomFee).containsExactlyInAnyOrderElementsOf(assessedCustomFees);
}
Also used : EntityId(com.hedera.mirror.common.domain.entity.EntityId) AssessedCustomFeeWrapper(com.hedera.mirror.importer.domain.AssessedCustomFeeWrapper) AssessedCustomFee(com.hedera.mirror.common.domain.transaction.AssessedCustomFee) Test(org.junit.jupiter.api.Test) IntegrationTest(com.hedera.mirror.importer.IntegrationTest)

Aggregations

EntityId (com.hedera.mirror.common.domain.entity.EntityId)1 AssessedCustomFee (com.hedera.mirror.common.domain.transaction.AssessedCustomFee)1 IntegrationTest (com.hedera.mirror.importer.IntegrationTest)1 AssessedCustomFeeWrapper (com.hedera.mirror.importer.domain.AssessedCustomFeeWrapper)1 Test (org.junit.jupiter.api.Test)1