Search in sources :

Example 1 with IterableAssert

use of org.assertj.core.api.IterableAssert in project drools-wb by kiegroup.

the class EnumIndexVisitorCDITest method testDependentEnumIndexing.

@Test
public void testDependentEnumIndexing() throws Exception {
    final String carFQN = "com.myteam.repro.Car";
    final Path testedPath = Paths.get(getClass().getResource("cars/src/main/resources/com/myteam/repro/cars.enumeration").toURI());
    final Set<KProperty<?>> properties = indexer.fillIndexBuilder(testedPath).build();
    final ModuleDataModelOracle oracle = indexer.getModuleDataModelOracle(testedPath);
    Assertions.assertThat(oracle.getModuleModelFields().keySet()).contains(carFQN);
    final IterableAssert carFields = Assertions.assertThat(properties).filteredOn("name", "ref:field:" + carFQN);
    carFields.filteredOn("value", "price").hasSize(1);
    carFields.filteredOn("value", "color").hasSize(1);
    final IterableAssert javaClasses = Assertions.assertThat(properties).filteredOn("name", "ref:java");
    javaClasses.filteredOn("value", carFQN).hasSize(1);
}
Also used : Path(org.uberfire.java.nio.file.Path) IterableAssert(org.assertj.core.api.IterableAssert) KProperty(org.uberfire.ext.metadata.model.KProperty) ModuleDataModelOracle(org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle) Test(org.junit.Test)

Example 2 with IterableAssert

use of org.assertj.core.api.IterableAssert in project hedera-mirror-node by hashgraph.

the class NftRepositoryTest method updateTreasury.

@Test
void updateTreasury() {
    long consensusTimestamp = 6L;
    EntityId newAccountId = EntityId.of("0.0.2", EntityType.ACCOUNT);
    Nft nft1 = nft("0.0.100", 1, 1);
    Nft nft2 = nft("0.0.100", 2, 2);
    Nft nft3 = nft("0.0.100", 3, 3);
    // Not updated since wrong token
    Nft nft4 = nft("0.0.101", 1, 4);
    // Not updated since wrong account
    Nft nft5 = nft("0.0.100", 4, 5);
    nft5.setAccountId(newAccountId);
    nftRepository.saveAll(List.of(nft1, nft2, nft3, nft4, nft5));
    EntityId tokenId = nft1.getId().getTokenId();
    EntityId previousAccountId = nft1.getAccountId();
    nftRepository.updateTreasury(tokenId.getId(), previousAccountId.getId(), newAccountId.getId(), consensusTimestamp, EntityId.of("0.0.200", EntityType.ACCOUNT).getId(), false);
    assertAccountUpdated(nft1, newAccountId);
    assertAccountUpdated(nft2, newAccountId);
    assertAccountUpdated(nft3, newAccountId);
    assertThat(nftRepository.findById(nft4.getId())).get().isEqualTo(nft4);
    assertThat(nftRepository.findById(nft5.getId())).get().isEqualTo(nft5);
    IterableAssert<NftTransfer> nftTransfers = assertThat(nftTransferRepository.findAll()).hasSize(3);
    nftTransfers.extracting(NftTransfer::getReceiverAccountId).containsOnly(newAccountId);
    nftTransfers.extracting(NftTransfer::getSenderAccountId).containsOnly(previousAccountId);
    nftTransfers.extracting(n -> n.getId().getTokenId()).containsOnly(tokenId);
    nftTransfers.extracting(n -> n.getId().getConsensusTimestamp()).containsOnly(consensusTimestamp);
    nftTransfers.extracting(n -> n.getId().getSerialNumber()).containsExactlyInAnyOrder(1L, 2L, 3L);
    nftTransfers.extracting(NftTransfer::getIsApproval).containsExactlyInAnyOrder(false, false, false);
}
Also used : EntityId(com.hedera.mirror.common.domain.entity.EntityId) Test(org.junit.jupiter.api.Test) NftId(com.hedera.mirror.common.domain.token.NftId) IterableAssert(org.assertj.core.api.IterableAssert) List(java.util.List) Nft(com.hedera.mirror.common.domain.token.Nft) EntityId(com.hedera.mirror.common.domain.entity.EntityId) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) NftTransfer(com.hedera.mirror.common.domain.token.NftTransfer) Resource(javax.annotation.Resource) AbstractObjectAssert(org.assertj.core.api.AbstractObjectAssert) EntityType(com.hedera.mirror.common.domain.entity.EntityType) NftTransfer(com.hedera.mirror.common.domain.token.NftTransfer) Nft(com.hedera.mirror.common.domain.token.Nft) Test(org.junit.jupiter.api.Test)

Aggregations

IterableAssert (org.assertj.core.api.IterableAssert)2 EntityId (com.hedera.mirror.common.domain.entity.EntityId)1 EntityType (com.hedera.mirror.common.domain.entity.EntityType)1 Nft (com.hedera.mirror.common.domain.token.Nft)1 NftId (com.hedera.mirror.common.domain.token.NftId)1 NftTransfer (com.hedera.mirror.common.domain.token.NftTransfer)1 List (java.util.List)1 Resource (javax.annotation.Resource)1 AbstractObjectAssert (org.assertj.core.api.AbstractObjectAssert)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Test (org.junit.Test)1 Test (org.junit.jupiter.api.Test)1 ModuleDataModelOracle (org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle)1 KProperty (org.uberfire.ext.metadata.model.KProperty)1 Path (org.uberfire.java.nio.file.Path)1