source: trunk/quest-core-tasktrees-test/src/test/java/de/ugoe/cs/quest/tasktrees/nodeequality/NodeAndSelectionComparisonRuleTest.java @ 817

Last change on this file since 817 was 817, checked in by pharms, 12 years ago
  • improved node comparison between iterations and other nodes as well as selections and other nodes
File size: 2.0 KB
Line 
1package de.ugoe.cs.quest.tasktrees.nodeequality;
2
3import static org.junit.Assert.*;
4
5import org.junit.Test;
6
7import de.ugoe.cs.quest.tasktrees.treeifc.ISelection;
8import de.ugoe.cs.quest.tasktrees.treeifc.ITaskTreeBuilder;
9import de.ugoe.cs.quest.tasktrees.treeifc.ITaskTreeNode;
10import de.ugoe.cs.quest.tasktrees.treeifc.ITaskTreeNodeFactory;
11import de.ugoe.cs.quest.tasktrees.treeimpl.TaskTreeBuilder;
12import de.ugoe.cs.quest.tasktrees.treeimpl.TaskTreeNodeFactory;
13import de.ugoe.cs.quest.tasktrees.treeimpl.TaskTreeNode;
14
15/**
16 * @author Patrick Harms
17 */
18public class NodeAndSelectionComparisonRuleTest {
19
20    /**
21     *
22     */
23    @Test
24    public void test() {
25        NodeEqualityRuleManager manager = new NodeEqualityRuleManager();
26        manager.init();
27       
28        ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory();
29        ITaskTreeBuilder treeBuilder = new TaskTreeBuilder();
30       
31        NodeAndSelectionComparisonRule rule = new NodeAndSelectionComparisonRule(manager);
32       
33        ITaskTreeNode task1 = new TaskTreeNode("task1");
34       
35        assertNull(rule.compare(task1, task1));
36       
37        ISelection selection1 = treeNodeFactory.createNewSelection();
38        assertNull(rule.compare(selection1, selection1));
39        assertNull(rule.compare(task1, selection1));
40        assertNull(rule.compare(selection1, task1));
41
42        treeBuilder.addChild(selection1, task1);
43       
44        assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection1, task1));
45        assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(task1, selection1));
46       
47        selection1 = treeNodeFactory.createNewSelection();
48        ISelection selection2 = treeNodeFactory.createNewSelection();
49        treeBuilder.addChild(selection2, task1);
50        treeBuilder.addChild(selection1, selection2);
51       
52        assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection1, task1));
53        assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(task1, selection1));
54    }
55
56}
Note: See TracBrowser for help on using the repository browser.