[927] | 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 | |
---|
[922] | 15 | package de.ugoe.cs.autoquest.tasktrees.nodeequality; |
---|
[807] | 16 | |
---|
| 17 | import static org.junit.Assert.*; |
---|
| 18 | |
---|
| 19 | import org.junit.Test; |
---|
| 20 | |
---|
[922] | 21 | import de.ugoe.cs.autoquest.tasktrees.nodeequality.IterationComparisonRule; |
---|
| 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.IIteration; |
---|
| 25 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; |
---|
| 26 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeBuilder; |
---|
| 27 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; |
---|
| 28 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNodeFactory; |
---|
| 29 | import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeBuilder; |
---|
| 30 | import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeNode; |
---|
| 31 | import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeNodeFactory; |
---|
[807] | 32 | |
---|
| 33 | /** |
---|
| 34 | * @author Patrick Harms |
---|
| 35 | */ |
---|
| 36 | public class IterationComparisonRuleTest { |
---|
| 37 | |
---|
| 38 | /** |
---|
| 39 | * |
---|
| 40 | */ |
---|
| 41 | @Test |
---|
| 42 | public void test() { |
---|
| 43 | NodeEqualityRuleManager manager = new NodeEqualityRuleManager(); |
---|
| 44 | manager.init(); |
---|
| 45 | |
---|
| 46 | ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory(); |
---|
| 47 | ITaskTreeBuilder treeBuilder = new TaskTreeBuilder(); |
---|
| 48 | |
---|
| 49 | IterationComparisonRule rule = new IterationComparisonRule(manager); |
---|
| 50 | |
---|
| 51 | ITaskTreeNode task1 = new TaskTreeNode("task1"); |
---|
| 52 | ITaskTreeNode task2 = new TaskTreeNode("task2"); |
---|
| 53 | |
---|
[1125] | 54 | assertFalse(rule.isApplicable(task1, task2)); |
---|
[807] | 55 | |
---|
| 56 | IIteration iteration1 = treeNodeFactory.createNewIteration(); |
---|
[1125] | 57 | assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(iteration1, iteration1)); |
---|
[807] | 58 | |
---|
| 59 | IIteration iteration2 = treeNodeFactory.createNewIteration(); |
---|
| 60 | |
---|
| 61 | assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(iteration1, iteration2)); |
---|
| 62 | assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(iteration2, iteration1)); |
---|
| 63 | |
---|
| 64 | treeBuilder.setChild(iteration1, task1); |
---|
| 65 | |
---|
| 66 | assertEquals(NodeEquality.UNEQUAL, rule.compare(iteration1, iteration2)); |
---|
| 67 | assertEquals(NodeEquality.UNEQUAL, rule.compare(iteration2, iteration1)); |
---|
| 68 | |
---|
| 69 | treeBuilder.setChild(iteration2, task1); |
---|
| 70 | |
---|
| 71 | assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(iteration1, iteration2)); |
---|
| 72 | assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(iteration2, iteration1)); |
---|
| 73 | |
---|
| 74 | treeBuilder.setChild(iteration1, task2); |
---|
| 75 | |
---|
| 76 | assertEquals(NodeEquality.UNEQUAL, rule.compare(iteration1, iteration2)); |
---|
| 77 | assertEquals(NodeEquality.UNEQUAL, rule.compare(iteration2, iteration1)); |
---|
| 78 | |
---|
| 79 | treeBuilder.setChild(iteration2, task2); |
---|
| 80 | |
---|
| 81 | assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(iteration1, iteration2)); |
---|
| 82 | assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(iteration2, iteration1)); |
---|
| 83 | |
---|
| 84 | ISelection selection1 = treeNodeFactory.createNewSelection(); |
---|
| 85 | treeBuilder.addChild(selection1, task2); |
---|
| 86 | treeBuilder.setChild(iteration1, selection1); |
---|
| 87 | |
---|
[817] | 88 | assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(iteration1, iteration2)); |
---|
| 89 | assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(iteration2, iteration1)); |
---|
[807] | 90 | |
---|
| 91 | ISelection selection2 = treeNodeFactory.createNewSelection(); |
---|
| 92 | treeBuilder.addChild(selection2, task2); |
---|
| 93 | treeBuilder.setChild(iteration2, selection2); |
---|
| 94 | |
---|
| 95 | assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(iteration1, iteration2)); |
---|
| 96 | assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(iteration2, iteration1)); |
---|
| 97 | |
---|
[1125] | 98 | assertFalse(rule.isApplicable(iteration1, selection1)); |
---|
| 99 | assertFalse(rule.isApplicable(selection1, iteration1)); |
---|
| 100 | assertFalse(rule.isApplicable(iteration2, selection1)); |
---|
| 101 | assertFalse(rule.isApplicable(selection1, iteration2)); |
---|
[807] | 102 | |
---|
[1125] | 103 | assertFalse(rule.isApplicable(iteration1, selection2)); |
---|
| 104 | assertFalse(rule.isApplicable(selection2, iteration1)); |
---|
| 105 | assertFalse(rule.isApplicable(iteration2, selection2)); |
---|
| 106 | assertFalse(rule.isApplicable(selection2, iteration2)); |
---|
[807] | 107 | } |
---|
| 108 | |
---|
| 109 | } |
---|