source: trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/nodeequality/SelectionComparisonRuleTest.java @ 922

Last change on this file since 922 was 922, checked in by sherbold, 12 years ago
  • renaming of packages from de.ugoe.cs.quest to de.ugoe.cs.autoquest
File size: 3.7 KB
Line 
1package de.ugoe.cs.autoquest.tasktrees.nodeequality;
2
3import static org.junit.Assert.*;
4
5import org.junit.Test;
6
7import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeEquality;
8import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeEqualityRuleManager;
9import de.ugoe.cs.autoquest.tasktrees.nodeequality.SelectionComparisonRule;
10import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection;
11import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence;
12import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeBuilder;
13import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode;
14import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNodeFactory;
15import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeBuilder;
16import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeNode;
17import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeNodeFactory;
18
19/**
20 * @author Patrick Harms
21 */
22public class SelectionComparisonRuleTest {
23
24    /**
25     *
26     */
27    @Test
28    public void test() {
29        NodeEqualityRuleManager manager = new NodeEqualityRuleManager();
30        manager.init();
31       
32        ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory();
33        ITaskTreeBuilder treeBuilder = new TaskTreeBuilder();
34       
35        SelectionComparisonRule rule = new SelectionComparisonRule(manager);
36       
37        ITaskTreeNode task1 = new TaskTreeNode("task1");
38        ITaskTreeNode task2 = new TaskTreeNode("task2");
39       
40        assertNull(rule.compare(task1, task2));
41       
42        ISelection selection1 = treeNodeFactory.createNewSelection();
43        assertEquals(NodeEquality.IDENTICAL, rule.compare(selection1, selection1));
44
45        ISelection selection2 = treeNodeFactory.createNewSelection();
46       
47        assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection1, selection2));
48        assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection2, selection1));
49       
50        treeBuilder.addChild(selection1, task1);
51       
52        assertEquals(NodeEquality.UNEQUAL, rule.compare(selection1, selection2));
53        assertEquals(NodeEquality.UNEQUAL, rule.compare(selection2, selection1));
54       
55        treeBuilder.addChild(selection2, task1);
56       
57        assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection1, selection2));
58        assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection2, selection1));
59       
60        treeBuilder.addChild(selection1, task2);
61       
62        assertEquals(NodeEquality.UNEQUAL, rule.compare(selection1, selection2));
63        assertEquals(NodeEquality.UNEQUAL, rule.compare(selection2, selection1));
64       
65        treeBuilder.addChild(selection2, task2);
66       
67        assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection1, selection2));
68        assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection2, selection1));
69       
70        ISelection selection3 = treeNodeFactory.createNewSelection();
71        treeBuilder.addChild(selection3, task2);
72        treeBuilder.addChild(selection3, task1);
73       
74        assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection1, selection3));
75        assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection3, selection1));
76       
77        assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection2, selection3));
78        assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection3, selection2));
79
80        ISequence sequence = treeNodeFactory.createNewSequence();
81        assertNull(rule.compare(selection1, sequence));
82        assertNull(rule.compare(sequence, selection1));
83        assertNull(rule.compare(selection2, sequence));
84        assertNull(rule.compare(sequence, selection2));
85        assertNull(rule.compare(selection3, sequence));
86        assertNull(rule.compare(sequence, selection3));
87    }
88
89}
Note: See TracBrowser for help on using the repository browser.