use of io.nem.symbol.sdk.model.state.MerkleTree in project nem2-sdk-java by nemtech.
the class MerkleStateInfoTest method equals.
@Test
void equals() {
MerkleTree tree1 = new MerkleTree(Collections.singletonList(createBranch("abc")), createLeaf("ABCD"));
MerkleStateInfo info1 = new MerkleStateInfo("1234", tree1);
MerkleTree tree2 = new MerkleTree(Collections.singletonList(createBranch("abc")), createLeaf("ABCD"));
MerkleStateInfo info2 = new MerkleStateInfo("1234", tree2);
MerkleTree tree3 = new MerkleTree(Collections.singletonList(createBranch("abc")), createLeaf("1234"));
MerkleStateInfo info3 = new MerkleStateInfo("1234", tree3);
Assertions.assertEquals(info1, info1);
Assertions.assertEquals(info2, info1);
Assertions.assertNotEquals(info2, info3);
}
use of io.nem.symbol.sdk.model.state.MerkleTree 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);
}
use of io.nem.symbol.sdk.model.state.MerkleTree 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);
}
use of io.nem.symbol.sdk.model.state.MerkleTree in project nem2-sdk-java by nemtech.
the class MerkleStateInfoTest method constructor.
@Test
void constructor() {
MerkleTree tree = new MerkleTree(Collections.singletonList(createBranch("abc")), createLeaf("ABCD"));
MerkleStateInfo info = new MerkleStateInfo("1234", tree);
Assertions.assertEquals("1234", info.getRaw());
Assertions.assertEquals(tree, info.getTree());
}
Aggregations