Search in sources :

Example 11 with MerkleStateInfo

use of io.nem.symbol.sdk.model.blockchain.MerkleStateInfo in project nem2-sdk-java by nemtech.

the class RestrictionMosaicRepositoryOkHttpImplTest method getMosaicRestrictionsMerkle.

@Test
public void getMosaicRestrictionsMerkle() throws Exception {
    mockRemoteCall(new MerkleStateInfoDTO().raw("abc"));
    MerkleStateInfo merkle = repository.getMosaicRestrictionsMerkle("abc").toFuture().get();
    Assertions.assertEquals("abc", merkle.getRaw());
}
Also used : MerkleStateInfo(io.nem.symbol.sdk.model.blockchain.MerkleStateInfo) MerkleStateInfoDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.MerkleStateInfoDTO) Test(org.junit.jupiter.api.Test)

Example 12 with MerkleStateInfo

use of io.nem.symbol.sdk.model.blockchain.MerkleStateInfo in project nem2-sdk-java by nemtech.

the class MerkleMapper method toMerkleStateInfo.

public MerkleStateInfo toMerkleStateInfo(MerkleStateInfoDTO dto) {
    MerkleTreeLeaf leaf = dto.getTree().stream().map(this::toLeaf).filter(Objects::nonNull).findFirst().orElse(null);
    List<MerkleTreeBranch> branches = dto.getTree().stream().map(this::toBranch).filter(Objects::nonNull).collect(Collectors.toList());
    MerkleTree tree = new MerkleTree(branches, leaf);
    return new MerkleStateInfo(dto.getRaw(), tree);
}
Also used : MerkleTree(io.nem.symbol.sdk.model.state.MerkleTree) MerkleStateInfo(io.nem.symbol.sdk.model.blockchain.MerkleStateInfo) Objects(java.util.Objects) MerkleTreeLeaf(io.nem.symbol.sdk.model.state.MerkleTreeLeaf) MerkleTreeBranch(io.nem.symbol.sdk.model.state.MerkleTreeBranch)

Example 13 with MerkleStateInfo

use of io.nem.symbol.sdk.model.blockchain.MerkleStateInfo in project nem2-sdk-java by nemtech.

the class NamespaceRepositoryOkHttpImplTest method getNamespaceMerkle.

@Test
public void getNamespaceMerkle() throws Exception {
    NamespaceId namespaceId = NamespaceId.createFromName("accountalias");
    mockRemoteCall(new MerkleStateInfoDTO().raw("abc"));
    MerkleStateInfo merkle = repository.getNamespaceMerkle(namespaceId).toFuture().get();
    Assertions.assertEquals("abc", merkle.getRaw());
}
Also used : MerkleStateInfo(io.nem.symbol.sdk.model.blockchain.MerkleStateInfo) NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId) MerkleStateInfoDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.MerkleStateInfoDTO) Test(org.junit.jupiter.api.Test)

Example 14 with MerkleStateInfo

use of io.nem.symbol.sdk.model.blockchain.MerkleStateInfo in project nem2-sdk-java by nemtech.

the class MetadataRepositoryOkHttpImplTest method getMetadataMerkle.

@Test
public void getMetadataMerkle() throws Exception {
    mockRemoteCall(new MerkleStateInfoDTO().raw("abc"));
    MerkleStateInfo merkle = repository.getMetadataMerkle("abc").toFuture().get();
    Assertions.assertEquals("abc", merkle.getRaw());
}
Also used : MerkleStateInfo(io.nem.symbol.sdk.model.blockchain.MerkleStateInfo) MerkleStateInfoDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.MerkleStateInfoDTO) Test(org.junit.jupiter.api.Test)

Example 15 with MerkleStateInfo

use of io.nem.symbol.sdk.model.blockchain.MerkleStateInfo in project nem2-sdk-java by nemtech.

the class RestrictionMosaicRepositoryVertxImplTest method getMosaicRestrictionsMerkle.

@Test
public void getMosaicRestrictionsMerkle() throws Exception {
    mockRemoteCall(new MerkleStateInfoDTO().raw("abc"));
    MerkleStateInfo merkle = repository.getMosaicRestrictionsMerkle("hash").toFuture().get();
    Assertions.assertEquals("abc", merkle.getRaw());
}
Also used : MerkleStateInfo(io.nem.symbol.sdk.model.blockchain.MerkleStateInfo) MerkleStateInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.MerkleStateInfoDTO) Test(org.junit.jupiter.api.Test)

Aggregations

MerkleStateInfo (io.nem.symbol.sdk.model.blockchain.MerkleStateInfo)21 Test (org.junit.jupiter.api.Test)17 MerkleStateInfoDTO (io.nem.symbol.sdk.openapi.vertx.model.MerkleStateInfoDTO)10 MerkleStateInfoDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.MerkleStateInfoDTO)9 Address (io.nem.symbol.sdk.model.account.Address)4 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)2 NamespaceId (io.nem.symbol.sdk.model.namespace.NamespaceId)2 MerkleTree (io.nem.symbol.sdk.model.state.MerkleTree)2 MerkleTreeBranch (io.nem.symbol.sdk.model.state.MerkleTreeBranch)2 MerkleTreeLeaf (io.nem.symbol.sdk.model.state.MerkleTreeLeaf)2 Objects (java.util.Objects)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2