[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 | |
---|
[1146] | 15 | package de.ugoe.cs.autoquest.tasktrees.taskequality; |
---|
[807] | 16 | |
---|
| 17 | import static org.junit.Assert.*; |
---|
| 18 | |
---|
| 19 | import org.junit.Test; |
---|
| 20 | |
---|
[1146] | 21 | import de.ugoe.cs.autoquest.eventcore.IEventTarget; |
---|
| 22 | import de.ugoe.cs.autoquest.eventcore.IEventType; |
---|
| 23 | import de.ugoe.cs.autoquest.eventcore.StringEventType; |
---|
| 24 | import de.ugoe.cs.autoquest.tasktrees.taskequality.SelectionComparisonRule; |
---|
[922] | 25 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; |
---|
[1146] | 26 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; |
---|
| 27 | import de.ugoe.cs.autoquest.test.DummyGUIElement; |
---|
[807] | 28 | |
---|
| 29 | /** |
---|
| 30 | * @author Patrick Harms |
---|
| 31 | */ |
---|
[1294] | 32 | public class SelectionComparisonRuleTest extends AbstractComparisonRuleTest { |
---|
[807] | 33 | |
---|
| 34 | /** |
---|
[1294] | 35 | * |
---|
[807] | 36 | */ |
---|
| 37 | @Test |
---|
[1294] | 38 | public void test_isApplicable_01() { |
---|
| 39 | SelectionComparisonRule rule = new SelectionComparisonRule(); |
---|
[807] | 40 | |
---|
[1294] | 41 | ITask task1 = createNewSelection(); |
---|
| 42 | |
---|
| 43 | assertTrue(rule.isApplicable(task1, task1)); |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | /** |
---|
| 47 | * |
---|
| 48 | */ |
---|
| 49 | @Test |
---|
| 50 | public void test_isApplicable_02() { |
---|
[1190] | 51 | SelectionComparisonRule rule = new SelectionComparisonRule(); |
---|
[1294] | 52 | |
---|
| 53 | ITask task1 = createNewSelection(); |
---|
| 54 | ITask task2 = createNewSelection(); |
---|
[807] | 55 | |
---|
[1294] | 56 | assertTrue(rule.isApplicable(task1, task2)); |
---|
| 57 | assertTrue(rule.isApplicable(task2, task1)); |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | /** |
---|
| 61 | * |
---|
| 62 | */ |
---|
| 63 | @Test |
---|
| 64 | public void test_isApplicable_03() { |
---|
| 65 | SelectionComparisonRule rule = new SelectionComparisonRule(); |
---|
| 66 | |
---|
| 67 | ITask task1 = createNewSelection(); |
---|
| 68 | ITask task2 = createNewSequence(); |
---|
| 69 | |
---|
| 70 | assertFalse(rule.isApplicable(task1, task2)); |
---|
| 71 | assertFalse(rule.isApplicable(task2, task1)); |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | /** |
---|
| 75 | * |
---|
| 76 | */ |
---|
| 77 | @Test |
---|
| 78 | public void test_isApplicable_04() { |
---|
| 79 | SelectionComparisonRule rule = new SelectionComparisonRule(); |
---|
| 80 | |
---|
| 81 | ITask task1 = createNewSelection(); |
---|
| 82 | ITask task2 = createNewIteration(); |
---|
| 83 | |
---|
| 84 | assertFalse(rule.isApplicable(task1, task2)); |
---|
| 85 | assertFalse(rule.isApplicable(task2, task1)); |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | /** |
---|
| 89 | * |
---|
| 90 | */ |
---|
| 91 | @Test |
---|
| 92 | public void test_isApplicable_05() { |
---|
| 93 | SelectionComparisonRule rule = new SelectionComparisonRule(); |
---|
| 94 | |
---|
| 95 | ITask task1 = createNewSelection(); |
---|
| 96 | ITask task2 = createNewOptional(); |
---|
| 97 | |
---|
| 98 | assertFalse(rule.isApplicable(task1, task2)); |
---|
| 99 | assertFalse(rule.isApplicable(task2, task1)); |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | /** |
---|
| 103 | * |
---|
| 104 | */ |
---|
| 105 | @Test |
---|
| 106 | public void test_isApplicable_06() { |
---|
| 107 | SelectionComparisonRule rule = new SelectionComparisonRule(); |
---|
| 108 | |
---|
[1146] | 109 | IEventType eventType1 = new StringEventType("eventType1"); |
---|
| 110 | IEventTarget eventTarget1 = new DummyGUIElement("elem1"); |
---|
| 111 | |
---|
[1294] | 112 | ITask task1 = createNewSelection(); |
---|
| 113 | ITask task2 = createNewEventTask(eventType1, eventTarget1); |
---|
[807] | 114 | |
---|
[1125] | 115 | assertFalse(rule.isApplicable(task1, task2)); |
---|
[1294] | 116 | assertFalse(rule.isApplicable(task2, task1)); |
---|
| 117 | } |
---|
| 118 | |
---|
| 119 | /** |
---|
| 120 | * |
---|
| 121 | */ |
---|
| 122 | @Test |
---|
| 123 | public void test_compare_01() { |
---|
| 124 | SelectionComparisonRule rule = new SelectionComparisonRule(); |
---|
[807] | 125 | |
---|
[1294] | 126 | ISelection selection1 = createNewSelection(); |
---|
| 127 | assertLexicallyEqual(rule, selection1, selection1); |
---|
| 128 | } |
---|
[807] | 129 | |
---|
[1294] | 130 | /** |
---|
| 131 | * |
---|
| 132 | */ |
---|
| 133 | @Test |
---|
| 134 | public void test_compare_02() { |
---|
| 135 | SelectionComparisonRule rule = new SelectionComparisonRule(); |
---|
[807] | 136 | |
---|
[1294] | 137 | ISelection selection1 = createNewSelection(); |
---|
| 138 | ISelection selection2 = createNewSelection(); |
---|
[807] | 139 | |
---|
[1294] | 140 | assertLexicallyEqual(rule, selection1, selection2); |
---|
| 141 | } |
---|
| 142 | |
---|
| 143 | /** |
---|
| 144 | * |
---|
| 145 | */ |
---|
| 146 | @Test |
---|
| 147 | public void test_compare_03() { |
---|
| 148 | SelectionComparisonRule rule = new SelectionComparisonRule(); |
---|
[807] | 149 | |
---|
[1294] | 150 | IEventType eventType1 = new StringEventType("eventType1"); |
---|
| 151 | IEventTarget eventTarget1 = new DummyGUIElement("elem1"); |
---|
| 152 | |
---|
| 153 | ITask task1 = createNewEventTask(eventType1, eventTarget1); |
---|
[807] | 154 | |
---|
[1294] | 155 | ISelection selection1 = createNewSelection(); |
---|
| 156 | ISelection selection2 = createNewSelection(); |
---|
[807] | 157 | |
---|
[1294] | 158 | addChild(selection1, task1); |
---|
[807] | 159 | |
---|
[1294] | 160 | assertUnequal(rule, selection1, selection2); |
---|
| 161 | } |
---|
| 162 | |
---|
| 163 | /** |
---|
| 164 | * |
---|
| 165 | */ |
---|
| 166 | @Test |
---|
| 167 | public void test_compare_04() { |
---|
| 168 | SelectionComparisonRule rule = new SelectionComparisonRule(); |
---|
[807] | 169 | |
---|
[1294] | 170 | IEventType eventType1 = new StringEventType("eventType1"); |
---|
| 171 | IEventTarget eventTarget1 = new DummyGUIElement("elem1"); |
---|
| 172 | |
---|
| 173 | ITask task1 = createNewEventTask(eventType1, eventTarget1); |
---|
[807] | 174 | |
---|
[1294] | 175 | ISelection selection1 = createNewSelection(); |
---|
| 176 | ISelection selection2 = createNewSelection(); |
---|
[807] | 177 | |
---|
[1294] | 178 | addChild(selection1, task1); |
---|
| 179 | addChild(selection2, task1); |
---|
[807] | 180 | |
---|
[1294] | 181 | assertLexicallyEqual(rule, selection1, selection2); |
---|
| 182 | } |
---|
| 183 | |
---|
| 184 | /** |
---|
| 185 | * |
---|
| 186 | */ |
---|
| 187 | @Test |
---|
| 188 | public void test_compare_05() { |
---|
| 189 | SelectionComparisonRule rule = new SelectionComparisonRule(); |
---|
[807] | 190 | |
---|
[1294] | 191 | IEventType eventType1 = new StringEventType("eventType1"); |
---|
| 192 | IEventTarget eventTarget1 = new DummyGUIElement("elem1"); |
---|
| 193 | |
---|
| 194 | IEventType eventType2 = new StringEventType("eventType2"); |
---|
| 195 | IEventTarget eventTarget2 = new DummyGUIElement("elem2"); |
---|
| 196 | |
---|
| 197 | ITask task1 = createNewEventTask(eventType1, eventTarget1); |
---|
| 198 | ITask task2 = createNewEventTask(eventType2, eventTarget2); |
---|
[807] | 199 | |
---|
[1294] | 200 | ISelection selection1 = createNewSelection(); |
---|
| 201 | ISelection selection2 = createNewSelection(); |
---|
| 202 | |
---|
| 203 | addChild(selection1, task1); |
---|
| 204 | addChild(selection2, task2); |
---|
| 205 | |
---|
| 206 | assertUnequal(rule, selection1, selection2); |
---|
| 207 | } |
---|
[807] | 208 | |
---|
[1294] | 209 | /** |
---|
| 210 | * |
---|
| 211 | */ |
---|
| 212 | @Test |
---|
| 213 | public void test_compare_06() { |
---|
| 214 | SelectionComparisonRule rule = new SelectionComparisonRule(); |
---|
| 215 | |
---|
| 216 | IEventType eventType1 = new StringEventType("eventType1"); |
---|
| 217 | IEventTarget eventTarget1 = new DummyGUIElement("elem1"); |
---|
| 218 | |
---|
| 219 | IEventType eventType2 = new StringEventType("eventType2"); |
---|
| 220 | IEventTarget eventTarget2 = new DummyGUIElement("elem2"); |
---|
| 221 | |
---|
| 222 | ITask task1 = createNewEventTask(eventType1, eventTarget1); |
---|
| 223 | ITask task2 = createNewEventTask(eventType2, eventTarget2); |
---|
| 224 | |
---|
| 225 | ISelection selection1 = createNewSelection(); |
---|
| 226 | ISelection selection2 = createNewSelection(); |
---|
| 227 | |
---|
| 228 | addChild(selection1, task1); |
---|
| 229 | addChild(selection2, task2); |
---|
| 230 | |
---|
| 231 | ISelection selection3 = createNewSelection(); |
---|
| 232 | addChild(selection3, task1); |
---|
| 233 | assertLexicallyEqual(rule, selection1, selection3); |
---|
| 234 | |
---|
| 235 | addChild(selection3, task2); |
---|
| 236 | assertLexicallyEqual(rule, selection2, selection3); |
---|
[807] | 237 | } |
---|
| 238 | |
---|
| 239 | } |
---|