Mercurial > hg > Members > shoshi > jungle > jungle-core
changeset 276:71a2ee428081
add DifferencialChildrenTest.java
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/Differencial/DifferencialTreeNodeChildren.java Fri Dec 16 02:56:47 2016 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/Differencial/DifferencialTreeNodeChildren.java Sat Dec 17 18:40:36 2016 +0900 @@ -29,11 +29,7 @@ @Override public Either<Error, TreeNode> addNewChildAt(int _pos) { - if (!boundaryCheck(_pos)) { - return DefaultEither.newA(NodeEditorError.INDEX_OUT_OF_BOUNDS); - } - children.add(_pos, new DifferencialTreeNode()); - return DefaultEither.newB(node); + return addNewChildAt(_pos, new DifferencialTreeNode()); } @Override
--- a/src/test/java/DefaultJungleTreeTest.java Fri Dec 16 02:56:47 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -import jp.ac.u_ryukyu.ie.cr.jungle.DefaultJungle; -import jp.ac.u_ryukyu.ie.cr.jungle.Jungle; -import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.DefaultNodePath; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.jungleTreeEditor.JungleTreeEditor; -import jp.ac.u_ryukyu.ie.cr.jungle.traverser.DefaultTraverser; -import jp.ac.u_ryukyu.ie.cr.jungle.tree.JungleTree; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; -import junit.framework.Assert; -import junit.framework.TestCase; - -import java.nio.ByteBuffer; - -public class DefaultJungleTreeTest extends TestCase { - public Jungle instance() { - Jungle j = new DefaultJungle(null, "hogehoge", new DefaultTraverser()); - return j; - } - - public static final String key = "KEY"; - public static final ByteBuffer value = ByteBuffer.wrap(key.getBytes()); - - public void testSampleTest() { - Jungle j = instance(); - j.createNewTree("tree"); - JungleTree tree = j.getTreeByName("tree"); - Assert.assertEquals(0, tree.revision()); - JungleTreeEditor editor1 = tree.getJungleTreeEditor(); - JungleTreeEditor editor2 = tree.getJungleTreeEditor(); - - DefaultNodePath root = new DefaultNodePath(); - - Either<Error, JungleTreeEditor> either = editor1.putAttribute(root, key, value); - if (either.isA()) { - Assert.fail(); - } - editor1 = either.b(); - editor1.success(); - - // check the value ; - TreeNode node = tree.getRootNode(); - ByteBuffer v = node.getAttributes().get(key); - Assert.assertEquals(0, v.compareTo(value)); - Assert.assertEquals(1, tree.revision()); - // editor2 must fail transction - either = editor2.putAttribute(root, key, value); - if (either.isA()) { - Assert.fail(); - } - editor2 = either.b(); - Either<Error, JungleTreeEditor> r = editor2.success(); - Assert.assertTrue(r.isA()); - } - - public void testIsolation() { - - } -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/tree/DefaultTree/DefaultJungleTreeTest.java Sat Dec 17 18:40:36 2016 +0900 @@ -0,0 +1,61 @@ +package jp.ac.u_ryukyu.ie.cr.jungle.core.tree.DefaultTree; + +import jp.ac.u_ryukyu.ie.cr.jungle.DefaultJungle; +import jp.ac.u_ryukyu.ie.cr.jungle.Jungle; +import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.DefaultNodePath; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.jungleTreeEditor.JungleTreeEditor; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.traverser.DefaultTraverser; +import jp.ac.u_ryukyu.ie.cr.jungle.tree.JungleTree; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; +import junit.framework.Assert; +import junit.framework.TestCase; + +import java.nio.ByteBuffer; + +public class DefaultJungleTreeTest extends TestCase { + public Jungle instance() { + Jungle j = new DefaultJungle(null, "hogehoge", new DefaultTraverser()); + return j; + } + + public static final String key = "KEY"; + public static final ByteBuffer value = ByteBuffer.wrap(key.getBytes()); + + public void testSampleTest() { + Jungle j = instance(); + j.createNewTree("tree"); + JungleTree tree = j.getTreeByName("tree"); + Assert.assertEquals(0, tree.revision()); + JungleTreeEditor editor1 = tree.getJungleTreeEditor(); + JungleTreeEditor editor2 = tree.getJungleTreeEditor(); + + DefaultNodePath root = new DefaultNodePath(); + + Either<Error, JungleTreeEditor> either = editor1.putAttribute(root, key, value); + if (either.isA()) { + Assert.fail(); + } + editor1 = either.b(); + editor1.success(); + + // check the value ; + TreeNode node = tree.getRootNode(); + ByteBuffer v = node.getAttributes().get(key); + Assert.assertEquals(0, v.compareTo(value)); + Assert.assertEquals(1, tree.revision()); + // editor2 must fail transction + either = editor2.putAttribute(root, key, value); + if (either.isA()) { + Assert.fail(); + } + editor2 = either.b(); + Either<Error, JungleTreeEditor> r = editor2.success(); + Assert.assertTrue(r.isA()); + } + + public void testIsolation() { + + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/impl/defaultnode/DefaultAttributesTest.java Sat Dec 17 18:40:36 2016 +0900 @@ -0,0 +1,29 @@ +package jp.ac.u_ryukyu.ie.cr.jungle.impl.defaultnode; + +import jp.ac.u_ryukyu.ie.cr.jungle.core.AttributesTest; +import jp.ac.u_ryukyu.ie.cr.jungle.data.list.List; +import jp.ac.u_ryukyu.ie.cr.jungle.data.treemap.TreeMap; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Default.DefaultTreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNodeAttributes; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Pair; + +import java.nio.ByteBuffer; + +public class DefaultAttributesTest extends AttributesTest +{ + public TreeNodeAttributes instance() + { + List<TreeNode> rawList = new List(); + TreeMap<String,ByteBuffer> rawMap = new TreeMap(); + + // add attributes + + for(Pair<String, ByteBuffer> entry : ENTRIES){ + rawMap = rawMap.put(entry.left(),entry.right()); + } + + TreeNode node = new DefaultTreeNode(rawList,rawMap); + return node.getAttributes(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/impl/defaultnode/DefaultChildrenTest.java Sat Dec 17 18:40:36 2016 +0900 @@ -0,0 +1,34 @@ +package jp.ac.u_ryukyu.ie.cr.jungle.impl.defaultnode; + + +import jp.ac.u_ryukyu.ie.cr.jungle.core.ChildrenTest; +import jp.ac.u_ryukyu.ie.cr.jungle.data.list.List; +import jp.ac.u_ryukyu.ie.cr.jungle.data.treemap.TreeMap; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Default.DefaultTreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Default.DefaultTreeNodeChildren; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; + +import java.nio.ByteBuffer; + +public class DefaultChildrenTest extends ChildrenTest<TreeNode> +{ + + @Override + public DefaultTreeNodeChildren instance() + { + List<TreeNode> rawList = new List(); + for(int i = 0;i < expectSize();i ++){ + rawList = rawList.addLast(new DefaultTreeNode()); + } + + TreeMap<String,ByteBuffer> rawMap = new TreeMap(); + + return new DefaultTreeNode(rawList,rawMap).getChildren(); + } + + @Override + public int expectSize() + { + return 3; + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/impl/defaultnode/FilteringKeyTest.java Sat Dec 17 18:40:36 2016 +0900 @@ -0,0 +1,41 @@ +package jp.ac.u_ryukyu.ie.cr.jungle.impl.defaultnode; + +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNodeAttributes; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Default.DefaultTreeNode; +import org.junit.Assert; +import org.junit.Test; + +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * Created by e115731 on 2016/11/19. + */ +public class FilteringKeyTest { + @Test + public void FilteringKeyTest(){ + TreeNode node = new DefaultTreeNode(); + TreeNodeAttributes attribute = node.getAttributes(); + node = attribute.put("1", ByteBuffer.wrap("1".getBytes())).b(); + attribute = node.getAttributes(); + node = attribute.put("2", ByteBuffer.wrap("2".getBytes())).b(); + attribute = node.getAttributes(); + node = attribute.put("3", ByteBuffer.wrap("3".getBytes())).b(); + attribute = node.getAttributes(); + node = attribute.put("4", ByteBuffer.wrap("4".getBytes())).b(); + attribute = node.getAttributes(); + List<String> filter = new ArrayList<>(); + filter.add("1"); + filter.add("2"); + Iterator<String> keys = attribute.getFilteringKey(filter); + while (keys.hasNext()) { + String key = keys.next(); + System.out.println(key); + Assert.assertNotEquals(key,"1"); + Assert.assertNotEquals(key,"2"); + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/impl/defaultnode/GetNodePath.java Sat Dec 17 18:40:36 2016 +0900 @@ -0,0 +1,80 @@ +package jp.ac.u_ryukyu.ie.cr.jungle.impl.defaultnode; + + +import jp.ac.u_ryukyu.ie.cr.jungle.DefaultJungle; +import jp.ac.u_ryukyu.ie.cr.jungle.Jungle; +import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.NodePath; +import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.DefaultNodePath; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Default.DefaultTreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.jungleTreeEditor.JungleTreeEditor; +import jp.ac.u_ryukyu.ie.cr.jungle.traverser.DefaultTraverser; +import jp.ac.u_ryukyu.ie.cr.jungle.traverser.InterfaceTraverser; +import jp.ac.u_ryukyu.ie.cr.jungle.tree.JungleTree; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; +import junit.framework.Assert; +import org.junit.Test; + +import java.nio.ByteBuffer; +import java.util.Iterator; + +public class GetNodePath { + @Test + public void getNodePathTest(){ + Jungle jungle = new DefaultJungle(null, "hogehoge",new DefaultTraverser()); + jungle.createNewTree("tree"); + JungleTree tree = jungle.getTreeByName("tree"); + JungleTreeEditor editor = tree.getJungleTreeEditor(); + + editor = createTree(editor,0,3,new DefaultNodePath()); + + editor.success(); + InterfaceTraverser traverser = tree.getTraverser(true); + + Iterator<TreeNode> iterator = traverser.find((TreeNode node) -> { // no index find + String value = node.getAttributes().getString(key); + if (value == null) + return false; + if (value.equals("<-1,2,0>")) + return true; + return false; + }); + + Assert.assertTrue(iterator.hasNext()); + TreeNode node = iterator.next(); + NodePath path = tree.getNodePath(node); + String pathtring = path.toString(); + Assert.assertEquals("<-1,2,0>",pathtring); + } + + public static String key = "KEY"; + public static String indexKey = "INDEXKEY"; + public static DefaultTreeNode factory = new DefaultTreeNode(); + + public JungleTreeEditor createTree(JungleTreeEditor editor, int _curY, int _maxHeight, NodePath path) { + + if (_curY == _maxHeight) { + return editor; + } + for (int i = 0; i < 3; i++) { + + Either<Error, JungleTreeEditor> either = editor.addNewChildAt(path, i); + if (either.isA()) + Assert.fail(); + editor = either.b(); + String value = path.add(i).toString(); + either = editor.putAttribute(path.add(i), key, ByteBuffer.wrap(value.getBytes())); + if (either.isA()) + Assert.fail(); + editor = either.b(); + String value2 = value + "+ index"; + either = editor.putAttribute(path.add(i), indexKey, ByteBuffer.wrap(value2.getBytes())); + if (either.isA()) + Assert.fail(); + editor = either.b(); + editor = createTree(editor, _curY + 1, _maxHeight, path.add(i)); + } + return editor; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/impl/differencialnode/DifferencialChildrenTest.java Sat Dec 17 18:40:36 2016 +0900 @@ -0,0 +1,74 @@ +package jp.ac.u_ryukyu.ie.cr.jungle.impl.differencialnode; + +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Differencial.DifferencialTreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNodeChildren; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; +import org.junit.Assert; +import org.junit.Test; + +/** + * Created by e115731 on 2016/12/17. + */ +public class DifferencialChildrenTest { + @Test + public void DifferencialNodeTest() { + TreeNode node = new DifferencialTreeNode(); + TreeNodeChildren children = node.getChildren(); + Either<Error, TreeNode> either = children.addNewChildAt(0, new DifferencialTreeNode()); //Nodeの追加 + Assert.assertFalse(either.isA()); + TreeNode newNode = either.b(); + Assert.assertEquals(node, newNode); + + either = children.addNewChildAt(3, new DifferencialTreeNode());//追加できない場所へのNodeの追加 + Assert.assertTrue(either.isA()); + + TreeNode child = children.at(0).b(); + either = children.addNewChildAt(0, new DifferencialTreeNode());//Nodeの割り込み挿入 + Assert.assertFalse(either.isA()); + TreeNode child2 = children.at(1).b(); + Assert.assertEquals(child, child2); + + either = children.moveChild(0,"up");//0番目の子ノードを上に動かす(失敗する + Assert.assertTrue(either.isA()); + + children = node.getChildren(); + child = children.at(1).b(); + either = children.moveChild(1,"up");//0番目の子ノードを上に動かす(失敗する + Assert.assertFalse(either.isA()); + child2 = children.at(0).b(); + Assert.assertEquals(child,child2); + + either = children.moveChild(1,"down");//1番目の子ノードを下に動かす(失敗する + Assert.assertTrue(either.isA()); + + child = children.at(0).b(); + either = children.moveChild(0,"down");//0番目の子ノードを上に動かす(失敗する + Assert.assertFalse(either.isA()); + child2 = children.at(1).b(); + Assert.assertEquals(child,child2); + + int expectSize = 2; + int size = children.size(); + Assert.assertEquals(expectSize,size); + + children = node.getChildren(); + either = children.deleteChildAt(4);//存在しないノードを削除 + Assert.assertTrue(either.isA()); + + children = node.getChildren(); + child = children.at(0).b(); + either = children.deleteChildAt(0);//ノードを削除 + Assert.assertFalse(either.isA()); + + for (TreeNode n : node.getChildren()) { //childrenの1番目のノードは削除したので存在しない + Assert.assertNotEquals(n,child); + } + + expectSize = 1; + size = children.size(); + Assert.assertEquals(expectSize,size); + + } +}
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/impl/node/DefaultAttributesTest.java Fri Dec 16 02:56:47 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.jungle.impl.node; - -import jp.ac.u_ryukyu.ie.cr.jungle.core.AttributesTest; -import jp.ac.u_ryukyu.ie.cr.jungle.data.list.List; -import jp.ac.u_ryukyu.ie.cr.jungle.data.treemap.TreeMap; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Default.DefaultTreeNode; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNodeAttributes; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Pair; - -import java.nio.ByteBuffer; - -public class DefaultAttributesTest extends AttributesTest -{ - public TreeNodeAttributes instance() - { - List<TreeNode> rawList = new List(); - TreeMap<String,ByteBuffer> rawMap = new TreeMap(); - - // add attributes - - for(Pair<String, ByteBuffer> entry : ENTRIES){ - rawMap = rawMap.put(entry.left(),entry.right()); - } - - TreeNode node = new DefaultTreeNode(rawList,rawMap); - return node.getAttributes(); - } -}
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/impl/node/DefaultChildrenTest.java Fri Dec 16 02:56:47 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.jungle.impl.node; - - -import jp.ac.u_ryukyu.ie.cr.jungle.core.ChildrenTest; -import jp.ac.u_ryukyu.ie.cr.jungle.data.list.List; -import jp.ac.u_ryukyu.ie.cr.jungle.data.treemap.TreeMap; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Default.DefaultTreeNode; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Default.DefaultTreeNodeChildren; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; - -import java.nio.ByteBuffer; - -public class DefaultChildrenTest extends ChildrenTest<TreeNode> -{ - - @Override - public DefaultTreeNodeChildren instance() - { - List<TreeNode> rawList = new List(); - for(int i = 0;i < expectSize();i ++){ - rawList = rawList.addLast(new DefaultTreeNode()); - } - - TreeMap<String,ByteBuffer> rawMap = new TreeMap(); - - return new DefaultTreeNode(rawList,rawMap).getChildren(); - } - - @Override - public int expectSize() - { - return 3; - } -} \ No newline at end of file
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/impl/node/FilteringKeyTest.java Fri Dec 16 02:56:47 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.jungle.impl.node; - -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNodeAttributes; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Default.DefaultTreeNode; -import org.junit.Assert; -import org.junit.Test; - -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** - * Created by e115731 on 2016/11/19. - */ -public class FilteringKeyTest { - @Test - public void FilteringKeyTest(){ - TreeNode node = new DefaultTreeNode(); - TreeNodeAttributes attribute = node.getAttributes(); - node = attribute.put("1", ByteBuffer.wrap("1".getBytes())).b(); - attribute = node.getAttributes(); - node = attribute.put("2", ByteBuffer.wrap("2".getBytes())).b(); - attribute = node.getAttributes(); - node = attribute.put("3", ByteBuffer.wrap("3".getBytes())).b(); - attribute = node.getAttributes(); - node = attribute.put("4", ByteBuffer.wrap("4".getBytes())).b(); - attribute = node.getAttributes(); - List<String> filter = new ArrayList<>(); - filter.add("1"); - filter.add("2"); - Iterator<String> keys = attribute.getFilteringKey(filter); - while (keys.hasNext()) { - String key = keys.next(); - System.out.println(key); - Assert.assertNotEquals(key,"1"); - Assert.assertNotEquals(key,"2"); - } - } -}
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/impl/node/GetNodePath.java Fri Dec 16 02:56:47 2016 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,80 +0,0 @@ -package jp.ac.u_ryukyu.ie.cr.jungle.impl.node; - - -import jp.ac.u_ryukyu.ie.cr.jungle.DefaultJungle; -import jp.ac.u_ryukyu.ie.cr.jungle.Jungle; -import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.NodePath; -import jp.ac.u_ryukyu.ie.cr.jungle.store.nodepath.DefaultNodePath; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.TreeNode; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.node.Default.DefaultTreeNode; -import jp.ac.u_ryukyu.ie.cr.jungle.transaction.editor.jungleTreeEditor.JungleTreeEditor; -import jp.ac.u_ryukyu.ie.cr.jungle.traverser.DefaultTraverser; -import jp.ac.u_ryukyu.ie.cr.jungle.traverser.InterfaceTraverser; -import jp.ac.u_ryukyu.ie.cr.jungle.tree.JungleTree; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; -import jp.ac.u_ryukyu.ie.cr.jungle.util.Error.Error; -import junit.framework.Assert; -import org.junit.Test; - -import java.nio.ByteBuffer; -import java.util.Iterator; - -public class GetNodePath { - @Test - public void getNodePathTest(){ - Jungle jungle = new DefaultJungle(null, "hogehoge",new DefaultTraverser()); - jungle.createNewTree("tree"); - JungleTree tree = jungle.getTreeByName("tree"); - JungleTreeEditor editor = tree.getJungleTreeEditor(); - - editor = createTree(editor,0,3,new DefaultNodePath()); - - editor.success(); - InterfaceTraverser traverser = tree.getTraverser(true); - - Iterator<TreeNode> iterator = traverser.find((TreeNode node) -> { // no index find - String value = node.getAttributes().getString(key); - if (value == null) - return false; - if (value.equals("<-1,2,0>")) - return true; - return false; - }); - - Assert.assertTrue(iterator.hasNext()); - TreeNode node = iterator.next(); - NodePath path = tree.getNodePath(node); - String pathtring = path.toString(); - Assert.assertEquals("<-1,2,0>",pathtring); - } - - public static String key = "KEY"; - public static String indexKey = "INDEXKEY"; - public static DefaultTreeNode factory = new DefaultTreeNode(); - - public JungleTreeEditor createTree(JungleTreeEditor editor, int _curY, int _maxHeight, NodePath path) { - - if (_curY == _maxHeight) { - return editor; - } - for (int i = 0; i < 3; i++) { - - Either<Error, JungleTreeEditor> either = editor.addNewChildAt(path, i); - if (either.isA()) - Assert.fail(); - editor = either.b(); - String value = path.add(i).toString(); - either = editor.putAttribute(path.add(i), key, ByteBuffer.wrap(value.getBytes())); - if (either.isA()) - Assert.fail(); - editor = either.b(); - String value2 = value + "+ index"; - either = editor.putAttribute(path.add(i), indexKey, ByteBuffer.wrap(value2.getBytes())); - if (either.isA()) - Assert.fail(); - editor = either.b(); - editor = createTree(editor, _curY + 1, _maxHeight, path.add(i)); - } - return editor; - } -}