1 | package de.ugoe.cs.autoquest.tasktrees.nodeequality; |
---|
2 | |
---|
3 | import static org.junit.Assert.*; |
---|
4 | |
---|
5 | import org.junit.Test; |
---|
6 | |
---|
7 | import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeEquality; |
---|
8 | import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeEqualityRuleManager; |
---|
9 | import de.ugoe.cs.autoquest.tasktrees.nodeequality.SelectionComparisonRule; |
---|
10 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; |
---|
11 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; |
---|
12 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeBuilder; |
---|
13 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; |
---|
14 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNodeFactory; |
---|
15 | import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeBuilder; |
---|
16 | import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeNode; |
---|
17 | import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeNodeFactory; |
---|
18 | |
---|
19 | /** |
---|
20 | * @author Patrick Harms |
---|
21 | */ |
---|
22 | public 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 | } |
---|