1 | // Copyright 2012 Georg-August-Universität Göttingen, Germany |
---|
2 | // |
---|
3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
---|
4 | // you may not use this file except in compliance with the License. |
---|
5 | // You may obtain a copy of the License at |
---|
6 | // |
---|
7 | // http://www.apache.org/licenses/LICENSE-2.0 |
---|
8 | // |
---|
9 | // Unless required by applicable law or agreed to in writing, software |
---|
10 | // distributed under the License is distributed on an "AS IS" BASIS, |
---|
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
12 | // See the License for the specific language governing permissions and |
---|
13 | // limitations under the License. |
---|
14 | |
---|
15 | package de.ugoe.cs.autoquest.tasktrees.nodeequality; |
---|
16 | |
---|
17 | import static org.junit.Assert.*; |
---|
18 | |
---|
19 | import org.junit.Test; |
---|
20 | |
---|
21 | import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeAndSelectionComparisonRule; |
---|
22 | import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeEquality; |
---|
23 | import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeEqualityRuleManager; |
---|
24 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; |
---|
25 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeBuilder; |
---|
26 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; |
---|
27 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNodeFactory; |
---|
28 | import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeBuilder; |
---|
29 | import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeNode; |
---|
30 | import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeNodeFactory; |
---|
31 | |
---|
32 | /** |
---|
33 | * @author Patrick Harms |
---|
34 | */ |
---|
35 | public class NodeAndSelectionComparisonRuleTest { |
---|
36 | |
---|
37 | /** |
---|
38 | * |
---|
39 | */ |
---|
40 | @Test |
---|
41 | public void test() { |
---|
42 | NodeEqualityRuleManager manager = new NodeEqualityRuleManager(); |
---|
43 | manager.init(); |
---|
44 | |
---|
45 | ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); |
---|
46 | ITaskTreeBuilder treeBuilder = new TaskTreeBuilder(); |
---|
47 | |
---|
48 | NodeAndSelectionComparisonRule rule = new NodeAndSelectionComparisonRule(manager); |
---|
49 | |
---|
50 | ITaskTreeNode task1 = new TaskTreeNode("task1"); |
---|
51 | |
---|
52 | assertNull(rule.compare(task1, task1)); |
---|
53 | |
---|
54 | ISelection selection1 = treeNodeFactory.createNewSelection(); |
---|
55 | assertNull(rule.compare(selection1, selection1)); |
---|
56 | assertNull(rule.compare(task1, selection1)); |
---|
57 | assertNull(rule.compare(selection1, task1)); |
---|
58 | |
---|
59 | treeBuilder.addChild(selection1, task1); |
---|
60 | |
---|
61 | assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection1, task1)); |
---|
62 | assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(task1, selection1)); |
---|
63 | |
---|
64 | selection1 = treeNodeFactory.createNewSelection(); |
---|
65 | ISelection selection2 = treeNodeFactory.createNewSelection(); |
---|
66 | treeBuilder.addChild(selection2, task1); |
---|
67 | treeBuilder.addChild(selection1, selection2); |
---|
68 | |
---|
69 | assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection1, task1)); |
---|
70 | assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(task1, selection1)); |
---|
71 | } |
---|
72 | |
---|
73 | } |
---|