1 | package de.ugoe.cs.quest.tasktrees.nodeequality; |
---|
2 | |
---|
3 | import static org.junit.Assert.*; |
---|
4 | |
---|
5 | import org.junit.Test; |
---|
6 | |
---|
7 | import de.ugoe.cs.quest.tasktrees.treeifc.IIteration; |
---|
8 | import de.ugoe.cs.quest.tasktrees.treeifc.ISelection; |
---|
9 | import de.ugoe.cs.quest.tasktrees.treeifc.ITaskTreeBuilder; |
---|
10 | import de.ugoe.cs.quest.tasktrees.treeifc.ITaskTreeNode; |
---|
11 | import de.ugoe.cs.quest.tasktrees.treeifc.ITaskTreeNodeFactory; |
---|
12 | import de.ugoe.cs.quest.tasktrees.treeimpl.TaskTreeBuilder; |
---|
13 | import de.ugoe.cs.quest.tasktrees.treeimpl.TaskTreeNodeFactory; |
---|
14 | import de.ugoe.cs.quest.tasktrees.treeimpl.TaskTreeNode; |
---|
15 | |
---|
16 | /** |
---|
17 | * @author Patrick Harms |
---|
18 | */ |
---|
19 | public class IterationComparisonRuleTest { |
---|
20 | |
---|
21 | /** |
---|
22 | * |
---|
23 | */ |
---|
24 | @Test |
---|
25 | public void test() { |
---|
26 | NodeEqualityRuleManager manager = new NodeEqualityRuleManager(); |
---|
27 | manager.init(); |
---|
28 | |
---|
29 | ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); |
---|
30 | ITaskTreeBuilder treeBuilder = new TaskTreeBuilder(); |
---|
31 | |
---|
32 | IterationComparisonRule rule = new IterationComparisonRule(manager); |
---|
33 | |
---|
34 | ITaskTreeNode task1 = new TaskTreeNode("task1"); |
---|
35 | ITaskTreeNode task2 = new TaskTreeNode("task2"); |
---|
36 | |
---|
37 | assertNull(rule.compare(task1, task2)); |
---|
38 | |
---|
39 | IIteration iteration1 = treeNodeFactory.createNewIteration(); |
---|
40 | assertEquals(NodeEquality.IDENTICAL, rule.compare(iteration1, iteration1)); |
---|
41 | |
---|
42 | IIteration iteration2 = treeNodeFactory.createNewIteration(); |
---|
43 | |
---|
44 | assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(iteration1, iteration2)); |
---|
45 | assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(iteration2, iteration1)); |
---|
46 | |
---|
47 | treeBuilder.setChild(iteration1, task1); |
---|
48 | |
---|
49 | assertEquals(NodeEquality.UNEQUAL, rule.compare(iteration1, iteration2)); |
---|
50 | assertEquals(NodeEquality.UNEQUAL, rule.compare(iteration2, iteration1)); |
---|
51 | |
---|
52 | treeBuilder.setChild(iteration2, task1); |
---|
53 | |
---|
54 | assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(iteration1, iteration2)); |
---|
55 | assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(iteration2, iteration1)); |
---|
56 | |
---|
57 | treeBuilder.setChild(iteration1, task2); |
---|
58 | |
---|
59 | assertEquals(NodeEquality.UNEQUAL, rule.compare(iteration1, iteration2)); |
---|
60 | assertEquals(NodeEquality.UNEQUAL, rule.compare(iteration2, iteration1)); |
---|
61 | |
---|
62 | treeBuilder.setChild(iteration2, task2); |
---|
63 | |
---|
64 | assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(iteration1, iteration2)); |
---|
65 | assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(iteration2, iteration1)); |
---|
66 | |
---|
67 | ISelection selection1 = treeNodeFactory.createNewSelection(); |
---|
68 | treeBuilder.addChild(selection1, task2); |
---|
69 | treeBuilder.setChild(iteration1, selection1); |
---|
70 | |
---|
71 | assertEquals(NodeEquality.SYNTACTICALLY_EQUAL, rule.compare(iteration1, iteration2)); |
---|
72 | assertEquals(NodeEquality.SYNTACTICALLY_EQUAL, rule.compare(iteration2, iteration1)); |
---|
73 | |
---|
74 | ISelection selection2 = treeNodeFactory.createNewSelection(); |
---|
75 | treeBuilder.addChild(selection2, task2); |
---|
76 | treeBuilder.setChild(iteration2, selection2); |
---|
77 | |
---|
78 | assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(iteration1, iteration2)); |
---|
79 | assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(iteration2, iteration1)); |
---|
80 | |
---|
81 | assertNull(rule.compare(iteration1, selection1)); |
---|
82 | assertNull(rule.compare(selection1, iteration1)); |
---|
83 | assertNull(rule.compare(iteration2, selection1)); |
---|
84 | assertNull(rule.compare(selection1, iteration2)); |
---|
85 | |
---|
86 | assertNull(rule.compare(iteration1, selection2)); |
---|
87 | assertNull(rule.compare(selection2, iteration1)); |
---|
88 | assertNull(rule.compare(iteration2, selection2)); |
---|
89 | assertNull(rule.compare(selection2, iteration2)); |
---|
90 | } |
---|
91 | |
---|
92 | } |
---|