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);
}
Aggregations