[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 | |
---|
[922] | 21 | import de.ugoe.cs.autoquest.eventcore.IEventTarget; |
---|
| 22 | import de.ugoe.cs.autoquest.eventcore.IEventType; |
---|
| 23 | import de.ugoe.cs.autoquest.eventcore.StringEventType; |
---|
[1146] | 24 | import de.ugoe.cs.autoquest.tasktrees.taskequality.EventTaskComparisonRule; |
---|
| 25 | import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality; |
---|
| 26 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; |
---|
| 27 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory; |
---|
| 28 | import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskFactory; |
---|
[922] | 29 | import de.ugoe.cs.autoquest.test.DummyGUIElement; |
---|
[807] | 30 | |
---|
| 31 | /** |
---|
| 32 | * @author Patrick Harms |
---|
| 33 | */ |
---|
| 34 | public class EventTaskComparisonRuleTest { |
---|
| 35 | |
---|
| 36 | /** |
---|
| 37 | * |
---|
| 38 | */ |
---|
| 39 | @Test |
---|
[1125] | 40 | public void test_isApplicable_01() { |
---|
[1146] | 41 | ITaskFactory taskFactory = new TaskFactory(); |
---|
[1125] | 42 | |
---|
| 43 | EventTaskComparisonRule rule = new EventTaskComparisonRule(); |
---|
| 44 | |
---|
| 45 | IEventType eventType1 = new StringEventType("eventType1"); |
---|
| 46 | IEventTarget eventTarget1 = new DummyGUIElement("elem1"); |
---|
[1146] | 47 | ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); |
---|
[1125] | 48 | |
---|
| 49 | assertTrue(rule.isApplicable(task1, task1)); |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | /** |
---|
| 53 | * |
---|
| 54 | */ |
---|
| 55 | @Test |
---|
| 56 | public void test_isApplicable_02() { |
---|
[1146] | 57 | ITaskFactory taskFactory = new TaskFactory(); |
---|
[1125] | 58 | |
---|
| 59 | EventTaskComparisonRule rule = new EventTaskComparisonRule(); |
---|
| 60 | |
---|
| 61 | IEventType eventType1 = new StringEventType("eventType1"); |
---|
| 62 | IEventTarget eventTarget1 = new DummyGUIElement("elem1"); |
---|
[1146] | 63 | ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); |
---|
[1125] | 64 | |
---|
| 65 | IEventType eventType2 = new StringEventType("eventType2"); |
---|
| 66 | IEventTarget eventTarget2 = new DummyGUIElement("elem2"); |
---|
[1146] | 67 | ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2); |
---|
[1125] | 68 | |
---|
| 69 | assertTrue(rule.isApplicable(task1, task2)); |
---|
| 70 | assertTrue(rule.isApplicable(task2, task1)); |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | /** |
---|
| 74 | * |
---|
| 75 | */ |
---|
| 76 | @Test |
---|
| 77 | public void test_isApplicable_03() { |
---|
[1146] | 78 | ITaskFactory taskFactory = new TaskFactory(); |
---|
[1125] | 79 | |
---|
| 80 | EventTaskComparisonRule rule = new EventTaskComparisonRule(); |
---|
| 81 | |
---|
| 82 | IEventType eventType1 = new StringEventType("eventType1"); |
---|
| 83 | IEventTarget eventTarget1 = new DummyGUIElement("elem1"); |
---|
[1146] | 84 | ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); |
---|
[1125] | 85 | |
---|
[1146] | 86 | ITask selection = taskFactory.createNewSelection(); |
---|
[1125] | 87 | |
---|
| 88 | assertFalse(rule.isApplicable(task1, selection)); |
---|
| 89 | assertFalse(rule.isApplicable(selection, task1)); |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | /** |
---|
| 93 | * |
---|
| 94 | */ |
---|
| 95 | @Test |
---|
| 96 | public void test_isApplicable_04() { |
---|
[1146] | 97 | ITaskFactory taskFactory = new TaskFactory(); |
---|
[1125] | 98 | |
---|
| 99 | EventTaskComparisonRule rule = new EventTaskComparisonRule(); |
---|
| 100 | |
---|
| 101 | IEventType eventType1 = new StringEventType("eventType1"); |
---|
| 102 | IEventTarget eventTarget1 = new DummyGUIElement("elem1"); |
---|
[1146] | 103 | ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); |
---|
[1125] | 104 | |
---|
[1146] | 105 | ITask sequence = taskFactory.createNewSequence(); |
---|
[1125] | 106 | |
---|
| 107 | assertFalse(rule.isApplicable(task1, sequence)); |
---|
| 108 | assertFalse(rule.isApplicable(sequence, task1)); |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | /** |
---|
| 112 | * |
---|
| 113 | */ |
---|
| 114 | @Test |
---|
| 115 | public void test_isApplicable_05() { |
---|
[1146] | 116 | ITaskFactory taskFactory = new TaskFactory(); |
---|
[1125] | 117 | |
---|
| 118 | EventTaskComparisonRule rule = new EventTaskComparisonRule(); |
---|
| 119 | |
---|
| 120 | IEventType eventType1 = new StringEventType("eventType1"); |
---|
| 121 | IEventTarget eventTarget1 = new DummyGUIElement("elem1"); |
---|
[1146] | 122 | ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); |
---|
[1125] | 123 | |
---|
[1146] | 124 | ITask iteration = taskFactory.createNewIteration(); |
---|
[1125] | 125 | |
---|
| 126 | assertFalse(rule.isApplicable(task1, iteration)); |
---|
| 127 | assertFalse(rule.isApplicable(iteration, task1)); |
---|
| 128 | } |
---|
| 129 | |
---|
| 130 | /** |
---|
| 131 | * |
---|
| 132 | */ |
---|
| 133 | @Test |
---|
| 134 | public void test_isApplicable_06() { |
---|
[1146] | 135 | ITaskFactory taskFactory = new TaskFactory(); |
---|
[1125] | 136 | |
---|
| 137 | EventTaskComparisonRule rule = new EventTaskComparisonRule(); |
---|
| 138 | |
---|
| 139 | IEventType eventType1 = new StringEventType("eventType1"); |
---|
| 140 | IEventTarget eventTarget1 = new DummyGUIElement("elem1"); |
---|
[1146] | 141 | ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); |
---|
[1125] | 142 | |
---|
[1146] | 143 | ITask optional = taskFactory.createNewOptional(); |
---|
[1125] | 144 | |
---|
| 145 | assertFalse(rule.isApplicable(task1, optional)); |
---|
| 146 | assertFalse(rule.isApplicable(optional, task1)); |
---|
| 147 | } |
---|
| 148 | |
---|
| 149 | /** |
---|
| 150 | * |
---|
| 151 | */ |
---|
| 152 | @Test |
---|
| 153 | public void test_compare_01() { |
---|
[1146] | 154 | ITaskFactory taskFactory = new TaskFactory(); |
---|
[807] | 155 | |
---|
| 156 | EventTaskComparisonRule rule = new EventTaskComparisonRule(); |
---|
| 157 | |
---|
| 158 | IEventType eventType1 = new StringEventType("eventType1"); |
---|
| 159 | IEventTarget eventTarget1 = new DummyGUIElement("elem1"); |
---|
[1146] | 160 | ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); |
---|
[807] | 161 | |
---|
[1146] | 162 | assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(task1, task1)); |
---|
[1125] | 163 | assertTrue(rule.areLexicallyEqual(task1, task1)); |
---|
| 164 | assertTrue(rule.areSyntacticallyEqual(task1, task1)); |
---|
| 165 | assertTrue(rule.areSemanticallyEqual(task1, task1)); |
---|
| 166 | } |
---|
| 167 | |
---|
| 168 | /** |
---|
| 169 | * |
---|
| 170 | */ |
---|
| 171 | @Test |
---|
| 172 | public void test_compare_02() { |
---|
[1146] | 173 | ITaskFactory taskFactory = new TaskFactory(); |
---|
[1125] | 174 | |
---|
| 175 | EventTaskComparisonRule rule = new EventTaskComparisonRule(); |
---|
| 176 | |
---|
| 177 | IEventType eventType1 = new StringEventType("eventType1"); |
---|
| 178 | IEventTarget eventTarget1 = new DummyGUIElement("elem1"); |
---|
[1146] | 179 | ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); |
---|
[1125] | 180 | |
---|
[1146] | 181 | ITask task2 = taskFactory.createNewEventTask(eventType1, eventTarget1); |
---|
[807] | 182 | |
---|
[1146] | 183 | assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(task1, task2)); |
---|
[1125] | 184 | assertTrue(rule.areLexicallyEqual(task1, task2)); |
---|
| 185 | assertTrue(rule.areSyntacticallyEqual(task1, task2)); |
---|
| 186 | assertTrue(rule.areSemanticallyEqual(task1, task2)); |
---|
| 187 | |
---|
[1146] | 188 | assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(task2, task1)); |
---|
[1125] | 189 | assertTrue(rule.areLexicallyEqual(task2, task1)); |
---|
| 190 | assertTrue(rule.areSyntacticallyEqual(task2, task1)); |
---|
| 191 | assertTrue(rule.areSemanticallyEqual(task2, task1)); |
---|
| 192 | } |
---|
| 193 | |
---|
| 194 | /** |
---|
| 195 | * |
---|
| 196 | */ |
---|
| 197 | @Test |
---|
| 198 | public void test_compare_03() { |
---|
[1146] | 199 | ITaskFactory taskFactory = new TaskFactory(); |
---|
[807] | 200 | |
---|
[1125] | 201 | EventTaskComparisonRule rule = new EventTaskComparisonRule(); |
---|
| 202 | |
---|
| 203 | IEventType eventType1 = new StringEventType("eventType1"); |
---|
| 204 | IEventTarget eventTarget1 = new DummyGUIElement("elem1"); |
---|
[1146] | 205 | ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); |
---|
[1125] | 206 | |
---|
[807] | 207 | IEventType eventType2 = new StringEventType("eventType2"); |
---|
[1146] | 208 | ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1); |
---|
[807] | 209 | |
---|
[1146] | 210 | assertEquals(TaskEquality.UNEQUAL, rule.compare(task1, task2)); |
---|
[1125] | 211 | assertFalse(rule.areLexicallyEqual(task1, task2)); |
---|
| 212 | assertFalse(rule.areSyntacticallyEqual(task1, task2)); |
---|
| 213 | assertFalse(rule.areSemanticallyEqual(task1, task2)); |
---|
| 214 | |
---|
[1146] | 215 | assertEquals(TaskEquality.UNEQUAL, rule.compare(task2, task1)); |
---|
[1125] | 216 | assertFalse(rule.areLexicallyEqual(task2, task1)); |
---|
| 217 | assertFalse(rule.areSyntacticallyEqual(task2, task1)); |
---|
| 218 | assertFalse(rule.areSemanticallyEqual(task2, task1)); |
---|
| 219 | } |
---|
| 220 | |
---|
| 221 | /** |
---|
| 222 | * |
---|
| 223 | */ |
---|
| 224 | @Test |
---|
| 225 | public void test_compare_04() { |
---|
[1146] | 226 | ITaskFactory taskFactory = new TaskFactory(); |
---|
[807] | 227 | |
---|
[1125] | 228 | EventTaskComparisonRule rule = new EventTaskComparisonRule(); |
---|
| 229 | |
---|
| 230 | IEventType eventType1 = new StringEventType("eventType1"); |
---|
| 231 | IEventTarget eventTarget1 = new DummyGUIElement("elem1"); |
---|
[1146] | 232 | ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); |
---|
[1125] | 233 | |
---|
[807] | 234 | IEventTarget eventTarget2 = new DummyGUIElement("elem2"); |
---|
[1146] | 235 | ITask task2 = taskFactory.createNewEventTask(eventType1, eventTarget2); |
---|
[807] | 236 | |
---|
[1146] | 237 | assertEquals(TaskEquality.UNEQUAL, rule.compare(task1, task2)); |
---|
[1125] | 238 | assertFalse(rule.areLexicallyEqual(task1, task2)); |
---|
| 239 | assertFalse(rule.areSyntacticallyEqual(task1, task2)); |
---|
| 240 | assertFalse(rule.areSemanticallyEqual(task1, task2)); |
---|
| 241 | |
---|
[1146] | 242 | assertEquals(TaskEquality.UNEQUAL, rule.compare(task2, task1)); |
---|
[1125] | 243 | assertFalse(rule.areLexicallyEqual(task2, task1)); |
---|
| 244 | assertFalse(rule.areSyntacticallyEqual(task2, task1)); |
---|
| 245 | assertFalse(rule.areSemanticallyEqual(task2, task1)); |
---|
| 246 | } |
---|
| 247 | |
---|
| 248 | |
---|
| 249 | /** |
---|
| 250 | * |
---|
| 251 | */ |
---|
| 252 | @Test |
---|
| 253 | public void test_compare_05() { |
---|
[1146] | 254 | ITaskFactory taskFactory = new TaskFactory(); |
---|
[807] | 255 | |
---|
[1125] | 256 | EventTaskComparisonRule rule = new EventTaskComparisonRule(); |
---|
[807] | 257 | |
---|
[1125] | 258 | IEventType eventType1 = new StringEventType("eventType1"); |
---|
| 259 | IEventTarget eventTarget1 = new DummyGUIElement("elem1"); |
---|
[1146] | 260 | ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); |
---|
[1125] | 261 | |
---|
| 262 | IEventType eventType2 = new StringEventType("eventType2"); |
---|
| 263 | IEventTarget eventTarget2 = new DummyGUIElement("elem2"); |
---|
[1146] | 264 | ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2); |
---|
[1125] | 265 | |
---|
[1146] | 266 | assertEquals(TaskEquality.UNEQUAL, rule.compare(task1, task2)); |
---|
[1125] | 267 | assertFalse(rule.areLexicallyEqual(task1, task2)); |
---|
| 268 | assertFalse(rule.areSyntacticallyEqual(task1, task2)); |
---|
| 269 | assertFalse(rule.areSemanticallyEqual(task1, task2)); |
---|
| 270 | |
---|
[1146] | 271 | assertEquals(TaskEquality.UNEQUAL, rule.compare(task2, task1)); |
---|
[1125] | 272 | assertFalse(rule.areLexicallyEqual(task2, task1)); |
---|
| 273 | assertFalse(rule.areSyntacticallyEqual(task2, task1)); |
---|
| 274 | assertFalse(rule.areSemanticallyEqual(task2, task1)); |
---|
[807] | 275 | } |
---|
| 276 | |
---|
| 277 | } |
---|