Mercurial > hg > Members > shoshi > TreeCMSv2
view src/treecms/test/TreeEditorTest.java @ 6:12604eb6b615
added javadoc
author | shoshi |
---|---|
date | Mon, 14 Mar 2011 23:24:38 +0900 |
parents | 87bba22e4fa2 |
children |
line wrap: on
line source
package treecms.test; import java.util.List; import java.util.LinkedList; import junit.framework.Assert; import org.junit.Before; import org.junit.Test; import treecms.api.Forest; import treecms.api.Node; import treecms.api.NodeID; import treecms.api.Tree; import treecms.api.TreeEditor; import treecms.tree.util.NodePathFinder; public class TreeEditorTest { Tree m_tree; TreeEditor m_editor; Node root,ch1,ch2,ch11,ch21,ch22,ch223,cloned; public TreeEditorTest(TreeEditor _editor,Tree _tree) { m_editor = _editor; m_tree = _tree; Forest forest = m_editor.getForest(); root = m_editor.getRoot(); ch1 = forest.create(); ch2 = forest.create(); ch11 = forest.create(); ch21 = forest.create(); ch22 = forest.create(); ch223 = forest.create(); //target LinkedList<Node> rootChildren = new LinkedList<Node>(); rootChildren.add(ch1); rootChildren.add(ch2); root.getData().add(rootChildren); ch1.getData().add(ch11); LinkedList<Node> ch2Children = new LinkedList<Node>(); ch2Children.add(ch21); ch2Children.add(ch22); ch2.getData().add(ch2Children); ch22.getData().add(ch223); //Edit cloned = m_editor.updateTree(ch223,ch223.getData()); } @Test public void testEdit() { NodePathFinder oldPath = new NodePathFinder(root,ch223); NodePathFinder newPath = new NodePathFinder(m_editor.getRoot(),cloned); List<Node> oldPathList = oldPath.list(); List<Node> newPathList = newPath.list(); //compare for(int i = 0;i < oldPathList.size();i ++){ Node node1 = oldPathList.get(i); Node node2 = newPathList.get(i); Assert.assertEquals(true,node1.getID().isFamily(node2.getID())); } } @Test public void testForceCommit() { m_editor.commit(true); NodeID rootID1 = m_editor.getRoot().getID(); NodeID rootID2 = m_tree.getRoot().getID(); Assert.assertEquals(true,rootID1.equals(rootID2)); } @Test public void testCommitFailsWhenTreeWasUpdated() { } @Test public void testCheck() { } @Test public void testUpdate() { } }