Changeset 1294
- Timestamp:
- 08/14/13 17:04:42 (11 years ago)
- Location:
- trunk
- Files:
-
- 11 added
- 47 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/manager/TaskTreeManagerTest.java
r1285 r1294 68 68 public void testOneEventOnOneElement() { 69 69 simulateEvent(new DummyInteraction("bla", 1), new DummyGUIElement("elem1")); 70 new TaskTreeChecker().assert TaskInstanceList70 new TaskTreeChecker().assertUserSession 71 71 ("UserSession session {" + 72 72 " Event bla {}" + … … 86 86 simulateEvent(new DummyInteraction("ble", 1), eventTarget); 87 87 88 new TaskTreeChecker().assert TaskInstanceList88 new TaskTreeChecker().assertUserSession 89 89 ("UserSession session {" + 90 90 " Event bla {}" + … … 114 114 simulateEvent(new DummyInteraction("blum", 1), eventTarget6); 115 115 116 new TaskTreeChecker(true).assert TaskInstanceList116 new TaskTreeChecker(true).assertUserSession 117 117 ("UserSession session {" + 118 118 " Event bla {}" + … … 152 152 simulateEvent(new DummyInteraction("blop", 1), eventTarget6); 153 153 154 new TaskTreeChecker().assert TaskInstanceList154 new TaskTreeChecker().assertUserSession 155 155 ("UserSession session {" + 156 156 " Event bla {}" + … … 181 181 simulateEvent(event1, eventTarget1); 182 182 simulateEvent(event1, eventTarget1); 183 new TaskTreeChecker().assert TaskInstanceList183 new TaskTreeChecker().assertUserSession 184 184 ("UserSession session {" + 185 185 " Iteration iteration1 {" + … … 201 201 } 202 202 203 new TaskTreeChecker().assert TaskInstanceList203 new TaskTreeChecker().assertUserSession 204 204 ("UserSession session {" + 205 205 " Iteration iteration1 {" + … … 240 240 simulateEvent(event5, eventTarget1); 241 241 242 new TaskTreeChecker().assert TaskInstanceList242 new TaskTreeChecker().assertUserSession 243 243 ("UserSession session {" + 244 244 " Event bli {}" + … … 285 285 } 286 286 287 new TaskTreeChecker(true).assert TaskInstanceList287 new TaskTreeChecker(true).assertUserSession 288 288 ("UserSession session {" + 289 289 " Iteration iteration2 {" + … … 426 426 simulateEvent(event3, eventTarget1); 427 427 428 new TaskTreeChecker().assert TaskInstanceList428 new TaskTreeChecker().assertUserSession 429 429 ("UserSession session {" + 430 430 " Iteration iteration1 {" + … … 459 459 } 460 460 461 new TaskTreeChecker().assert TaskInstanceList461 new TaskTreeChecker().assertUserSession 462 462 ("UserSession session {" + 463 463 " Iteration iteration1 {" + … … 540 540 simulateEvent(event6, eventTarget1); 541 541 542 new TaskTreeChecker().assert TaskInstanceList542 new TaskTreeChecker().assertUserSession 543 543 ("UserSession session {" + 544 544 " Event ble {}" + … … 610 610 } 611 611 612 new TaskTreeChecker().assert TaskInstanceList612 new TaskTreeChecker().assertUserSession 613 613 ("UserSession session {" + 614 614 " Iteration iteration3 {" + -
trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/taskequality/EventTaskComparisonRuleTest.java
r1146 r1294 25 25 import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality; 26 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;29 27 import de.ugoe.cs.autoquest.test.DummyGUIElement; 30 28 … … 32 30 * @author Patrick Harms 33 31 */ 34 public class EventTaskComparisonRuleTest {32 public class EventTaskComparisonRuleTest extends AbstractComparisonRuleTest { 35 33 36 34 /** … … 39 37 @Test 40 38 public void test_isApplicable_01() { 41 ITaskFactory taskFactory = new TaskFactory(); 42 43 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 44 45 IEventType eventType1 = new StringEventType("eventType1"); 46 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 47 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 39 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 40 41 IEventType eventType1 = new StringEventType("eventType1"); 42 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 43 ITask task1 = createNewEventTask(eventType1, eventTarget1); 48 44 49 45 assertTrue(rule.isApplicable(task1, task1)); … … 55 51 @Test 56 52 public void test_isApplicable_02() { 57 ITaskFactory taskFactory = new TaskFactory(); 58 59 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 60 61 IEventType eventType1 = new StringEventType("eventType1"); 62 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 63 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 53 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 54 55 IEventType eventType1 = new StringEventType("eventType1"); 56 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 57 ITask task1 = createNewEventTask(eventType1, eventTarget1); 64 58 65 59 IEventType eventType2 = new StringEventType("eventType2"); 66 60 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 67 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2);61 ITask task2 = createNewEventTask(eventType2, eventTarget2); 68 62 69 63 assertTrue(rule.isApplicable(task1, task2)); … … 76 70 @Test 77 71 public void test_isApplicable_03() { 78 ITaskFactory taskFactory = new TaskFactory(); 79 80 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 81 82 IEventType eventType1 = new StringEventType("eventType1"); 83 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 84 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 72 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 73 74 IEventType eventType1 = new StringEventType("eventType1"); 75 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 76 ITask task1 = createNewEventTask(eventType1, eventTarget1); 85 77 86 ITask selection = taskFactory.createNewSelection();78 ITask selection = createNewSelection(); 87 79 88 80 assertFalse(rule.isApplicable(task1, selection)); … … 95 87 @Test 96 88 public void test_isApplicable_04() { 97 ITaskFactory taskFactory = new TaskFactory(); 98 99 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 100 101 IEventType eventType1 = new StringEventType("eventType1"); 102 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 103 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 104 105 ITask sequence = taskFactory.createNewSequence(); 89 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 90 91 IEventType eventType1 = new StringEventType("eventType1"); 92 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 93 ITask task1 = createNewEventTask(eventType1, eventTarget1); 94 95 ITask sequence = createNewSequence(); 106 96 107 97 assertFalse(rule.isApplicable(task1, sequence)); … … 114 104 @Test 115 105 public void test_isApplicable_05() { 116 ITaskFactory taskFactory = new TaskFactory(); 117 118 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 119 120 IEventType eventType1 = new StringEventType("eventType1"); 121 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 122 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 123 124 ITask iteration = taskFactory.createNewIteration(); 106 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 107 108 IEventType eventType1 = new StringEventType("eventType1"); 109 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 110 ITask task1 = createNewEventTask(eventType1, eventTarget1); 111 112 ITask iteration = createNewIteration(); 125 113 126 114 assertFalse(rule.isApplicable(task1, iteration)); … … 133 121 @Test 134 122 public void test_isApplicable_06() { 135 ITaskFactory taskFactory = new TaskFactory(); 136 137 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 138 139 IEventType eventType1 = new StringEventType("eventType1"); 140 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 141 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 142 143 ITask optional = taskFactory.createNewOptional(); 123 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 124 125 IEventType eventType1 = new StringEventType("eventType1"); 126 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 127 ITask task1 = createNewEventTask(eventType1, eventTarget1); 128 129 ITask optional = createNewOptional(); 144 130 145 131 assertFalse(rule.isApplicable(task1, optional)); … … 151 137 */ 152 138 @Test 139 public void test_isApplicable_07() { 140 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 141 142 IEventType eventType1 = new StringEventType("eventType1"); 143 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 144 ITask task1 = createNewEventTask(eventType1, eventTarget1); 145 146 assertTrue(rule.isApplicable(task1.getInstances().iterator().next(), 147 task1.getInstances().iterator().next())); 148 } 149 150 /** 151 * 152 */ 153 @Test 154 public void test_isApplicable_08() { 155 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 156 157 IEventType eventType1 = new StringEventType("eventType1"); 158 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 159 ITask task1 = createNewEventTask(eventType1, eventTarget1); 160 161 IEventType eventType2 = new StringEventType("eventType2"); 162 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 163 ITask task2 = createNewEventTask(eventType2, eventTarget2); 164 165 assertTrue(rule.isApplicable(task1.getInstances().iterator().next(), 166 task2.getInstances().iterator().next())); 167 assertTrue(rule.isApplicable(task2.getInstances().iterator().next(), 168 task1.getInstances().iterator().next())); 169 } 170 171 /** 172 * 173 */ 174 @Test 175 public void test_isApplicable_09() { 176 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 177 178 IEventType eventType1 = new StringEventType("eventType1"); 179 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 180 ITask task1 = createNewEventTask(eventType1, eventTarget1); 181 182 ITask selection = createNewSelection(); 183 184 assertFalse(rule.isApplicable(task1.getInstances().iterator().next(), 185 selection.getInstances().iterator().next())); 186 assertFalse(rule.isApplicable(selection.getInstances().iterator().next(), 187 task1.getInstances().iterator().next())); 188 } 189 190 /** 191 * 192 */ 193 @Test 194 public void test_isApplicable_10() { 195 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 196 197 IEventType eventType1 = new StringEventType("eventType1"); 198 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 199 ITask task1 = createNewEventTask(eventType1, eventTarget1); 200 201 ITask sequence = createNewSequence(); 202 203 assertFalse(rule.isApplicable(task1.getInstances().iterator().next(), 204 sequence.getInstances().iterator().next())); 205 assertFalse(rule.isApplicable(sequence.getInstances().iterator().next(), 206 task1.getInstances().iterator().next())); 207 } 208 209 /** 210 * 211 */ 212 @Test 213 public void test_isApplicable_11() { 214 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 215 216 IEventType eventType1 = new StringEventType("eventType1"); 217 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 218 ITask task1 = createNewEventTask(eventType1, eventTarget1); 219 220 ITask iteration = createNewIteration(); 221 222 assertFalse(rule.isApplicable(task1.getInstances().iterator().next(), 223 iteration.getInstances().iterator().next())); 224 assertFalse(rule.isApplicable(iteration.getInstances().iterator().next(), 225 task1.getInstances().iterator().next())); 226 } 227 228 /** 229 * 230 */ 231 @Test 232 public void test_isApplicable_12() { 233 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 234 235 IEventType eventType1 = new StringEventType("eventType1"); 236 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 237 ITask task1 = createNewEventTask(eventType1, eventTarget1); 238 239 ITask optional = createNewOptional(); 240 241 assertFalse(rule.isApplicable(task1.getInstances().iterator().next(), 242 optional.getInstances().iterator().next())); 243 assertFalse(rule.isApplicable(optional.getInstances().iterator().next(), 244 task1.getInstances().iterator().next())); 245 } 246 247 /** 248 * 249 */ 250 @Test 153 251 public void test_compare_01() { 154 ITaskFactory taskFactory = new TaskFactory(); 155 156 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 157 158 IEventType eventType1 = new StringEventType("eventType1"); 159 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 160 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 252 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 253 254 IEventType eventType1 = new StringEventType("eventType1"); 255 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 256 ITask task1 = createNewEventTask(eventType1, eventTarget1); 161 257 162 258 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(task1, task1)); … … 171 267 @Test 172 268 public void test_compare_02() { 173 ITaskFactory taskFactory = new TaskFactory(); 174 175 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 176 177 IEventType eventType1 = new StringEventType("eventType1"); 178 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 179 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 180 181 ITask task2 = taskFactory.createNewEventTask(eventType1, eventTarget1); 269 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 270 271 IEventType eventType1 = new StringEventType("eventType1"); 272 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 273 ITask task1 = createNewEventTask(eventType1, eventTarget1); 274 275 ITask task2 = createNewEventTask(eventType1, eventTarget1); 182 276 183 277 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(task1, task2)); … … 197 291 @Test 198 292 public void test_compare_03() { 199 ITaskFactory taskFactory = new TaskFactory(); 200 201 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 202 203 IEventType eventType1 = new StringEventType("eventType1"); 204 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 205 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 293 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 294 295 IEventType eventType1 = new StringEventType("eventType1"); 296 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 297 ITask task1 = createNewEventTask(eventType1, eventTarget1); 206 298 207 299 IEventType eventType2 = new StringEventType("eventType2"); 208 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);300 ITask task2 = createNewEventTask(eventType2, eventTarget1); 209 301 210 302 assertEquals(TaskEquality.UNEQUAL, rule.compare(task1, task2)); … … 224 316 @Test 225 317 public void test_compare_04() { 226 ITaskFactory taskFactory = new TaskFactory(); 227 228 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 229 230 IEventType eventType1 = new StringEventType("eventType1"); 231 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 232 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 318 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 319 320 IEventType eventType1 = new StringEventType("eventType1"); 321 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 322 ITask task1 = createNewEventTask(eventType1, eventTarget1); 233 323 234 324 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 235 ITask task2 = taskFactory.createNewEventTask(eventType1, eventTarget2);325 ITask task2 = createNewEventTask(eventType1, eventTarget2); 236 326 237 327 assertEquals(TaskEquality.UNEQUAL, rule.compare(task1, task2)); … … 252 342 @Test 253 343 public void test_compare_05() { 254 ITaskFactory taskFactory = new TaskFactory(); 255 256 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 257 258 IEventType eventType1 = new StringEventType("eventType1"); 259 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 260 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 344 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 345 346 IEventType eventType1 = new StringEventType("eventType1"); 347 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 348 ITask task1 = createNewEventTask(eventType1, eventTarget1); 261 349 262 350 IEventType eventType2 = new StringEventType("eventType2"); 263 351 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 264 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2);352 ITask task2 = createNewEventTask(eventType2, eventTarget2); 265 353 266 354 assertEquals(TaskEquality.UNEQUAL, rule.compare(task1, task2)); … … 275 363 } 276 364 365 366 /** 367 * 368 */ 369 @Test 370 public void test_compare_06() { 371 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 372 373 IEventType eventType1 = new StringEventType("eventType1"); 374 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 375 ITask task1 = createNewEventTask(eventType1, eventTarget1); 376 377 assertEquals(TaskEquality.LEXICALLY_EQUAL, 378 rule.compare(task1.getInstances().iterator().next(), 379 task1.getInstances().iterator().next())); 380 assertTrue(rule.areLexicallyEqual(task1.getInstances().iterator().next(), 381 task1.getInstances().iterator().next())); 382 assertTrue(rule.areSyntacticallyEqual(task1.getInstances().iterator().next(), 383 task1.getInstances().iterator().next())); 384 assertTrue(rule.areSemanticallyEqual(task1.getInstances().iterator().next(), 385 task1.getInstances().iterator().next())); 386 } 387 388 /** 389 * 390 */ 391 @Test 392 public void test_compare_07() { 393 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 394 395 IEventType eventType1 = new StringEventType("eventType1"); 396 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 397 ITask task1 = createNewEventTask(eventType1, eventTarget1); 398 399 ITask task2 = createNewEventTask(eventType1, eventTarget1); 400 401 assertEquals(TaskEquality.LEXICALLY_EQUAL, 402 rule.compare(task1.getInstances().iterator().next(), 403 task2.getInstances().iterator().next())); 404 assertTrue(rule.areLexicallyEqual(task1.getInstances().iterator().next(), 405 task2.getInstances().iterator().next())); 406 assertTrue(rule.areSyntacticallyEqual(task1.getInstances().iterator().next(), 407 task2.getInstances().iterator().next())); 408 assertTrue(rule.areSemanticallyEqual(task1.getInstances().iterator().next(), 409 task2.getInstances().iterator().next())); 410 411 assertEquals(TaskEquality.LEXICALLY_EQUAL, 412 rule.compare(task2.getInstances().iterator().next(), 413 task1.getInstances().iterator().next())); 414 assertTrue(rule.areLexicallyEqual(task2.getInstances().iterator().next(), 415 task1.getInstances().iterator().next())); 416 assertTrue(rule.areSyntacticallyEqual(task2.getInstances().iterator().next(), 417 task1.getInstances().iterator().next())); 418 assertTrue(rule.areSemanticallyEqual(task2.getInstances().iterator().next(), 419 task1.getInstances().iterator().next())); 420 } 421 422 /** 423 * 424 */ 425 @Test 426 public void test_compare_08() { 427 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 428 429 IEventType eventType1 = new StringEventType("eventType1"); 430 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 431 ITask task1 = createNewEventTask(eventType1, eventTarget1); 432 433 IEventType eventType2 = new StringEventType("eventType2"); 434 ITask task2 = createNewEventTask(eventType2, eventTarget1); 435 436 assertEquals(TaskEquality.UNEQUAL, 437 rule.compare(task1.getInstances().iterator().next(), 438 task2.getInstances().iterator().next())); 439 assertFalse(rule.areLexicallyEqual(task1.getInstances().iterator().next(), 440 task2.getInstances().iterator().next())); 441 assertFalse(rule.areSyntacticallyEqual(task1.getInstances().iterator().next(), 442 task2.getInstances().iterator().next())); 443 assertFalse(rule.areSemanticallyEqual(task1.getInstances().iterator().next(), 444 task2.getInstances().iterator().next())); 445 446 assertEquals(TaskEquality.UNEQUAL, 447 rule.compare(task2.getInstances().iterator().next(), 448 task1.getInstances().iterator().next())); 449 assertFalse(rule.areLexicallyEqual(task2.getInstances().iterator().next(), 450 task1.getInstances().iterator().next())); 451 assertFalse(rule.areSyntacticallyEqual(task2.getInstances().iterator().next(), 452 task1.getInstances().iterator().next())); 453 assertFalse(rule.areSemanticallyEqual(task2.getInstances().iterator().next(), 454 task1.getInstances().iterator().next())); 455 } 456 457 /** 458 * 459 */ 460 @Test 461 public void test_compare_09() { 462 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 463 464 IEventType eventType1 = new StringEventType("eventType1"); 465 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 466 ITask task1 = createNewEventTask(eventType1, eventTarget1); 467 468 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 469 ITask task2 = createNewEventTask(eventType1, eventTarget2); 470 471 assertEquals(TaskEquality.UNEQUAL, 472 rule.compare(task1.getInstances().iterator().next(), 473 task2.getInstances().iterator().next())); 474 assertFalse(rule.areLexicallyEqual(task1.getInstances().iterator().next(), 475 task2.getInstances().iterator().next())); 476 assertFalse(rule.areSyntacticallyEqual(task1.getInstances().iterator().next(), 477 task2.getInstances().iterator().next())); 478 assertFalse(rule.areSemanticallyEqual(task1.getInstances().iterator().next(), 479 task2.getInstances().iterator().next())); 480 481 assertEquals(TaskEquality.UNEQUAL, 482 rule.compare(task2.getInstances().iterator().next(), 483 task1.getInstances().iterator().next())); 484 assertFalse(rule.areLexicallyEqual(task2.getInstances().iterator().next(), 485 task1.getInstances().iterator().next())); 486 assertFalse(rule.areSyntacticallyEqual(task2.getInstances().iterator().next(), 487 task1.getInstances().iterator().next())); 488 assertFalse(rule.areSemanticallyEqual(task2.getInstances().iterator().next(), 489 task1.getInstances().iterator().next())); 490 } 491 492 493 /** 494 * 495 */ 496 @Test 497 public void test_compare_10() { 498 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 499 500 IEventType eventType1 = new StringEventType("eventType1"); 501 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 502 ITask task1 = createNewEventTask(eventType1, eventTarget1); 503 504 IEventType eventType2 = new StringEventType("eventType2"); 505 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 506 ITask task2 = createNewEventTask(eventType2, eventTarget2); 507 508 assertEquals(TaskEquality.UNEQUAL, 509 rule.compare(task1.getInstances().iterator().next(), 510 task2.getInstances().iterator().next())); 511 assertFalse(rule.areLexicallyEqual(task1.getInstances().iterator().next(), 512 task2.getInstances().iterator().next())); 513 assertFalse(rule.areSyntacticallyEqual(task1.getInstances().iterator().next(), 514 task2.getInstances().iterator().next())); 515 assertFalse(rule.areSemanticallyEqual(task1.getInstances().iterator().next(), 516 task2.getInstances().iterator().next())); 517 518 assertEquals(TaskEquality.UNEQUAL, 519 rule.compare(task2.getInstances().iterator().next(), 520 task1.getInstances().iterator().next())); 521 assertFalse(rule.areLexicallyEqual(task2.getInstances().iterator().next(), 522 task1.getInstances().iterator().next())); 523 assertFalse(rule.areSyntacticallyEqual(task2.getInstances().iterator().next(), 524 task1.getInstances().iterator().next())); 525 assertFalse(rule.areSemanticallyEqual(task2.getInstances().iterator().next(), 526 task1.getInstances().iterator().next())); 527 } 528 277 529 } -
trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/taskequality/GUIEventTaskComparisonRuleTest.java
r1146 r1294 42 42 import de.ugoe.cs.autoquest.keyboardmaps.VirtualKey; 43 43 import de.ugoe.cs.autoquest.tasktrees.taskequality.EventTaskComparisonRule; 44 import de.ugoe.cs.autoquest.tasktrees.taskequality.GUIEventTaskComparisonRule;45 import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality;46 44 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 47 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory;48 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskFactory;49 45 import de.ugoe.cs.autoquest.test.DummyGUIElement; 50 46 … … 52 48 * @author Patrick Harms 53 49 */ 54 public class GUIEventTaskComparisonRuleTest {50 public class GUIEventTaskComparisonRuleTest extends AbstractComparisonRuleTest { 55 51 56 52 /** … … 59 55 @Test 60 56 public void test_isApplicable_01() { 61 ITaskFactory taskFactory = new TaskFactory(); 62 63 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 64 65 IEventType eventType1 = new StringEventType("eventType1"); 66 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 67 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 57 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 58 59 IEventType eventType1 = new StringEventType("eventType1"); 60 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 61 ITask task1 = createNewEventTask(eventType1, eventTarget1); 68 62 69 63 assertTrue(rule.isApplicable(task1, task1)); … … 75 69 @Test 76 70 public void test_isApplicable_02() { 77 ITaskFactory taskFactory = new TaskFactory(); 78 79 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 80 81 IEventType eventType1 = new StringEventType("eventType1"); 82 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 83 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 71 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 72 73 IEventType eventType1 = new StringEventType("eventType1"); 74 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 75 ITask task1 = createNewEventTask(eventType1, eventTarget1); 84 76 85 77 IEventType eventType2 = new StringEventType("eventType2"); 86 78 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 87 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2);79 ITask task2 = createNewEventTask(eventType2, eventTarget2); 88 80 89 81 assertTrue(rule.isApplicable(task1, task2)); … … 96 88 @Test 97 89 public void test_isApplicable_03() { 98 ITaskFactory taskFactory = new TaskFactory();99 100 90 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 101 91 102 92 IEventType eventType1 = new KeyboardFocusChange(); 103 93 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 104 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);94 ITask task1 = createNewEventTask(eventType1, eventTarget1); 105 95 106 96 IEventType eventType2 = new KeyboardFocusChange(); 107 97 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 108 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2);98 ITask task2 = createNewEventTask(eventType2, eventTarget2); 109 99 110 100 assertTrue(rule.isApplicable(task1, task2)); … … 117 107 @Test 118 108 public void test_isApplicable_04() { 119 ITaskFactory taskFactory = new TaskFactory();120 121 109 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 122 110 123 111 IEventType eventType1 = new KeyPressed(VirtualKey.LETTER_A); 124 112 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 125 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);113 ITask task1 = createNewEventTask(eventType1, eventTarget1); 126 114 127 115 IEventType eventType2 = new KeyReleased(VirtualKey.LETTER_B); 128 116 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 129 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2);117 ITask task2 = createNewEventTask(eventType2, eventTarget2); 130 118 131 119 assertTrue(rule.isApplicable(task1, task2)); … … 138 126 @Test 139 127 public void test_isApplicable_05() { 140 ITaskFactory taskFactory = new TaskFactory();141 142 128 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 143 129 144 130 IEventType eventType1 = new KeyTyped(VirtualKey.LETTER_C); 145 131 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 146 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);132 ITask task1 = createNewEventTask(eventType1, eventTarget1); 147 133 148 134 IEventType eventType2 = new KeyTyped(VirtualKey.LETTER_D); 149 135 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 150 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2);136 ITask task2 = createNewEventTask(eventType2, eventTarget2); 151 137 152 138 assertTrue(rule.isApplicable(task1, task2)); … … 159 145 @Test 160 146 public void test_isApplicable_06() { 161 ITaskFactory taskFactory = new TaskFactory();162 163 147 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 164 148 165 149 IEventType eventType1 = new MouseButtonDown(MouseButtonInteraction.Button.LEFT, 5, 6); 166 150 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 167 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);151 ITask task1 = createNewEventTask(eventType1, eventTarget1); 168 152 169 153 IEventType eventType2 = new MouseButtonUp(MouseButtonInteraction.Button.MIDDLE, 3, 1); 170 154 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 171 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2);155 ITask task2 = createNewEventTask(eventType2, eventTarget2); 172 156 173 157 assertTrue(rule.isApplicable(task1, task2)); … … 180 164 @Test 181 165 public void test_isApplicable_07() { 182 ITaskFactory taskFactory = new TaskFactory();183 184 166 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 185 167 186 168 IEventType eventType1 = new MouseClick(MouseButtonInteraction.Button.RIGHT, 4, 7); 187 169 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 188 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);170 ITask task1 = createNewEventTask(eventType1, eventTarget1); 189 171 190 172 IEventType eventType2 = new MouseDoubleClick(MouseButtonInteraction.Button.X, 9, 12); 191 173 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 192 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2);174 ITask task2 = createNewEventTask(eventType2, eventTarget2); 193 175 194 176 assertTrue(rule.isApplicable(task1, task2)); … … 201 183 @Test 202 184 public void test_isApplicable_08() { 203 ITaskFactory taskFactory = new TaskFactory();204 205 185 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 206 186 207 187 IEventType eventType1 = new MouseDragAndDrop(1, 2, 3, 4); 208 188 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 209 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);189 ITask task1 = createNewEventTask(eventType1, eventTarget1); 210 190 211 191 IEventType eventType2 = new MouseDragAndDrop(5, 6, 7, 8); 212 192 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 213 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2);193 ITask task2 = createNewEventTask(eventType2, eventTarget2); 214 194 215 195 assertTrue(rule.isApplicable(task1, task2)); … … 222 202 @Test 223 203 public void test_isApplicable_09() { 224 ITaskFactory taskFactory = new TaskFactory();225 226 204 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 227 205 228 206 IEventType eventType1 = new Scroll(1, 2); 229 207 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 230 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);208 ITask task1 = createNewEventTask(eventType1, eventTarget1); 231 209 232 210 IEventType eventType2 = new Scroll(3, 4); 233 211 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 234 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2);212 ITask task2 = createNewEventTask(eventType2, eventTarget2); 235 213 236 214 assertTrue(rule.isApplicable(task1, task2)); … … 243 221 @Test 244 222 public void test_isApplicable_10() { 245 ITaskFactory taskFactory = new TaskFactory();246 247 223 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 248 224 … … 250 226 IEventType eventType1 = new TextInput("text1", inputEvents); 251 227 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 252 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);228 ITask task1 = createNewEventTask(eventType1, eventTarget1); 253 229 254 230 IEventType eventType2 = new TextInput("text2", inputEvents); 255 231 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 256 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2);232 ITask task2 = createNewEventTask(eventType2, eventTarget2); 257 233 258 234 assertTrue(rule.isApplicable(task1, task2)); … … 265 241 @Test 266 242 public void test_isApplicable_11() { 267 ITaskFactory taskFactory = new TaskFactory();268 269 243 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 270 244 271 245 IEventType eventType1 = new TextSelection(); 272 246 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 273 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);247 ITask task1 = createNewEventTask(eventType1, eventTarget1); 274 248 275 249 IEventType eventType2 = new ValueSelection<String>("value"); 276 250 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 277 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2);251 ITask task2 = createNewEventTask(eventType2, eventTarget2); 278 252 279 253 assertTrue(rule.isApplicable(task1, task2)); … … 286 260 @Test 287 261 public void test_isApplicable_12() { 288 ITaskFactory taskFactory = new TaskFactory(); 289 290 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 291 292 IEventType eventType1 = new StringEventType("eventType1"); 293 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 294 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 295 296 ITask selection = taskFactory.createNewSelection(); 262 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 263 264 IEventType eventType1 = new StringEventType("eventType1"); 265 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 266 ITask task1 = createNewEventTask(eventType1, eventTarget1); 267 268 ITask selection = createNewSelection(); 297 269 298 270 assertFalse(rule.isApplicable(task1, selection)); … … 305 277 @Test 306 278 public void test_isApplicable_13() { 307 ITaskFactory taskFactory = new TaskFactory(); 308 309 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 310 311 IEventType eventType1 = new StringEventType("eventType1"); 312 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 313 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 314 315 ITask sequence = taskFactory.createNewSequence(); 279 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 280 281 IEventType eventType1 = new StringEventType("eventType1"); 282 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 283 ITask task1 = createNewEventTask(eventType1, eventTarget1); 284 285 ITask sequence = createNewSequence(); 316 286 317 287 assertFalse(rule.isApplicable(task1, sequence)); … … 324 294 @Test 325 295 public void test_isApplicable_14() { 326 ITaskFactory taskFactory = new TaskFactory(); 327 328 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 329 330 IEventType eventType1 = new StringEventType("eventType1"); 331 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 332 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 333 334 ITask iteration = taskFactory.createNewIteration(); 296 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 297 298 IEventType eventType1 = new StringEventType("eventType1"); 299 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 300 ITask task1 = createNewEventTask(eventType1, eventTarget1); 301 302 ITask iteration = createNewIteration(); 335 303 336 304 assertFalse(rule.isApplicable(task1, iteration)); … … 343 311 @Test 344 312 public void test_isApplicable_15() { 345 ITaskFactory taskFactory = new TaskFactory(); 346 347 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 348 349 IEventType eventType1 = new StringEventType("eventType1"); 350 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 351 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 352 353 ITask optional = taskFactory.createNewOptional(); 313 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 314 315 IEventType eventType1 = new StringEventType("eventType1"); 316 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 317 ITask task1 = createNewEventTask(eventType1, eventTarget1); 318 319 ITask optional = createNewOptional(); 354 320 355 321 assertFalse(rule.isApplicable(task1, optional)); … … 357 323 } 358 324 325 326 /** 327 * 328 */ 329 @Test 330 public void test_isApplicable_16() { 331 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 332 333 IEventType eventType1 = new StringEventType("eventType1"); 334 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 335 ITask task1 = createNewEventTask(eventType1, eventTarget1); 336 337 assertTrue(rule.isApplicable(task1.getInstances().iterator().next(), 338 task1.getInstances().iterator().next())); 339 } 340 341 /** 342 * 343 */ 344 @Test 345 public void test_isApplicable_17() { 346 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 347 348 IEventType eventType1 = new StringEventType("eventType1"); 349 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 350 ITask task1 = createNewEventTask(eventType1, eventTarget1); 351 352 IEventType eventType2 = new StringEventType("eventType2"); 353 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 354 ITask task2 = createNewEventTask(eventType2, eventTarget2); 355 356 assertTrue(rule.isApplicable(task1.getInstances().iterator().next(), 357 task2.getInstances().iterator().next())); 358 assertTrue(rule.isApplicable(task2.getInstances().iterator().next(), 359 task1.getInstances().iterator().next())); 360 } 361 362 /** 363 * 364 */ 365 @Test 366 public void test_isApplicable_18() { 367 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 368 369 IEventType eventType1 = new KeyboardFocusChange(); 370 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 371 ITask task1 = createNewEventTask(eventType1, eventTarget1); 372 373 IEventType eventType2 = new KeyboardFocusChange(); 374 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 375 ITask task2 = createNewEventTask(eventType2, eventTarget2); 376 377 assertTrue(rule.isApplicable(task1.getInstances().iterator().next(), 378 task2.getInstances().iterator().next())); 379 assertTrue(rule.isApplicable(task2.getInstances().iterator().next(), 380 task1.getInstances().iterator().next())); 381 } 382 383 /** 384 * 385 */ 386 @Test 387 public void test_isApplicable_19() { 388 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 389 390 IEventType eventType1 = new KeyPressed(VirtualKey.LETTER_A); 391 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 392 ITask task1 = createNewEventTask(eventType1, eventTarget1); 393 394 IEventType eventType2 = new KeyReleased(VirtualKey.LETTER_B); 395 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 396 ITask task2 = createNewEventTask(eventType2, eventTarget2); 397 398 assertTrue(rule.isApplicable(task1.getInstances().iterator().next(), 399 task2.getInstances().iterator().next())); 400 assertTrue(rule.isApplicable(task2.getInstances().iterator().next(), 401 task1.getInstances().iterator().next())); 402 } 403 404 /** 405 * 406 */ 407 @Test 408 public void test_isApplicable_20() { 409 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 410 411 IEventType eventType1 = new KeyTyped(VirtualKey.LETTER_C); 412 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 413 ITask task1 = createNewEventTask(eventType1, eventTarget1); 414 415 IEventType eventType2 = new KeyTyped(VirtualKey.LETTER_D); 416 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 417 ITask task2 = createNewEventTask(eventType2, eventTarget2); 418 419 assertTrue(rule.isApplicable(task1.getInstances().iterator().next(), 420 task2.getInstances().iterator().next())); 421 assertTrue(rule.isApplicable(task2.getInstances().iterator().next(), 422 task1.getInstances().iterator().next())); 423 } 424 425 /** 426 * 427 */ 428 @Test 429 public void test_isApplicable_21() { 430 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 431 432 IEventType eventType1 = new MouseButtonDown(MouseButtonInteraction.Button.LEFT, 5, 6); 433 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 434 ITask task1 = createNewEventTask(eventType1, eventTarget1); 435 436 IEventType eventType2 = new MouseButtonUp(MouseButtonInteraction.Button.MIDDLE, 3, 1); 437 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 438 ITask task2 = createNewEventTask(eventType2, eventTarget2); 439 440 assertTrue(rule.isApplicable(task1.getInstances().iterator().next(), 441 task2.getInstances().iterator().next())); 442 assertTrue(rule.isApplicable(task2.getInstances().iterator().next(), 443 task1.getInstances().iterator().next())); 444 } 445 446 /** 447 * 448 */ 449 @Test 450 public void test_isApplicable_22() { 451 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 452 453 IEventType eventType1 = new MouseClick(MouseButtonInteraction.Button.RIGHT, 4, 7); 454 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 455 ITask task1 = createNewEventTask(eventType1, eventTarget1); 456 457 IEventType eventType2 = new MouseDoubleClick(MouseButtonInteraction.Button.X, 9, 12); 458 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 459 ITask task2 = createNewEventTask(eventType2, eventTarget2); 460 461 assertTrue(rule.isApplicable(task1.getInstances().iterator().next(), 462 task2.getInstances().iterator().next())); 463 assertTrue(rule.isApplicable(task2.getInstances().iterator().next(), 464 task1.getInstances().iterator().next())); 465 } 466 467 /** 468 * 469 */ 470 @Test 471 public void test_isApplicable_23() { 472 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 473 474 IEventType eventType1 = new MouseDragAndDrop(1, 2, 3, 4); 475 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 476 ITask task1 = createNewEventTask(eventType1, eventTarget1); 477 478 IEventType eventType2 = new MouseDragAndDrop(5, 6, 7, 8); 479 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 480 ITask task2 = createNewEventTask(eventType2, eventTarget2); 481 482 assertTrue(rule.isApplicable(task1.getInstances().iterator().next(), 483 task2.getInstances().iterator().next())); 484 assertTrue(rule.isApplicable(task2.getInstances().iterator().next(), 485 task1.getInstances().iterator().next())); 486 } 487 488 /** 489 * 490 */ 491 @Test 492 public void test_isApplicable_24() { 493 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 494 495 IEventType eventType1 = new Scroll(1, 2); 496 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 497 ITask task1 = createNewEventTask(eventType1, eventTarget1); 498 499 IEventType eventType2 = new Scroll(3, 4); 500 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 501 ITask task2 = createNewEventTask(eventType2, eventTarget2); 502 503 assertTrue(rule.isApplicable(task1.getInstances().iterator().next(), 504 task2.getInstances().iterator().next())); 505 assertTrue(rule.isApplicable(task2.getInstances().iterator().next(), 506 task1.getInstances().iterator().next())); 507 } 508 509 /** 510 * 511 */ 512 @Test 513 public void test_isApplicable_25() { 514 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 515 516 List<Event> inputEvents = new ArrayList<Event>(); 517 IEventType eventType1 = new TextInput("text1", inputEvents); 518 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 519 ITask task1 = createNewEventTask(eventType1, eventTarget1); 520 521 IEventType eventType2 = new TextInput("text2", inputEvents); 522 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 523 ITask task2 = createNewEventTask(eventType2, eventTarget2); 524 525 assertTrue(rule.isApplicable(task1.getInstances().iterator().next(), task2.getInstances().iterator().next())); 526 assertTrue(rule.isApplicable(task2.getInstances().iterator().next(), task1.getInstances().iterator().next())); 527 } 528 529 /** 530 * 531 */ 532 @Test 533 public void test_isApplicable_26() { 534 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 535 536 IEventType eventType1 = new TextSelection(); 537 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 538 ITask task1 = createNewEventTask(eventType1, eventTarget1); 539 540 IEventType eventType2 = new ValueSelection<String>("value"); 541 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 542 ITask task2 = createNewEventTask(eventType2, eventTarget2); 543 544 assertTrue(rule.isApplicable(task1.getInstances().iterator().next(), 545 task2.getInstances().iterator().next())); 546 assertTrue(rule.isApplicable(task2.getInstances().iterator().next(), 547 task1.getInstances().iterator().next())); 548 } 549 550 /** 551 * 552 */ 553 @Test 554 public void test_isApplicable_27() { 555 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 556 557 IEventType eventType1 = new StringEventType("eventType1"); 558 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 559 ITask task1 = createNewEventTask(eventType1, eventTarget1); 560 561 ITask selection = createNewSelection(); 562 563 assertFalse(rule.isApplicable(task1.getInstances().iterator().next(), 564 selection.getInstances().iterator().next())); 565 assertFalse(rule.isApplicable(selection.getInstances().iterator().next(), 566 task1.getInstances().iterator().next())); 567 } 568 569 /** 570 * 571 */ 572 @Test 573 public void test_isApplicable_28() { 574 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 575 576 IEventType eventType1 = new StringEventType("eventType1"); 577 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 578 ITask task1 = createNewEventTask(eventType1, eventTarget1); 579 580 ITask sequence = createNewSequence(); 581 582 assertFalse(rule.isApplicable(task1.getInstances().iterator().next(), 583 sequence.getInstances().iterator().next())); 584 assertFalse(rule.isApplicable(sequence.getInstances().iterator().next(), 585 task1.getInstances().iterator().next())); 586 } 587 588 /** 589 * 590 */ 591 @Test 592 public void test_isApplicable_29() { 593 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 594 595 IEventType eventType1 = new StringEventType("eventType1"); 596 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 597 ITask task1 = createNewEventTask(eventType1, eventTarget1); 598 599 ITask iteration = createNewIteration(); 600 601 assertFalse(rule.isApplicable(task1.getInstances().iterator().next(), 602 iteration.getInstances().iterator().next())); 603 assertFalse(rule.isApplicable(iteration.getInstances().iterator().next(), 604 task1.getInstances().iterator().next())); 605 } 606 607 /** 608 * 609 */ 610 @Test 611 public void test_isApplicable_30() { 612 EventTaskComparisonRule rule = new EventTaskComparisonRule(); 613 614 IEventType eventType1 = new StringEventType("eventType1"); 615 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 616 ITask task1 = createNewEventTask(eventType1, eventTarget1); 617 618 ITask optional = createNewOptional(); 619 620 assertFalse(rule.isApplicable(task1.getInstances().iterator().next(), 621 optional.getInstances().iterator().next())); 622 assertFalse(rule.isApplicable(optional.getInstances().iterator().next(), 623 task1.getInstances().iterator().next())); 624 } 625 359 626 /** 360 627 * … … 362 629 @Test 363 630 public void test_compare_KeyboardFocusChange_01() { 364 ITaskFactory taskFactory = new TaskFactory();365 366 631 IEventType eventType1 = new KeyboardFocusChange(); 367 632 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 368 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);369 370 assertLexicallyEqual( task1, task1);633 ITask task1 = createNewEventTask(eventType1, eventTarget1); 634 635 assertLexicallyEqual(new GUIEventTaskComparisonRule(), task1, task1); 371 636 } 372 637 … … 376 641 @Test 377 642 public void test_compare_KeyboardFocusChange_02() { 378 ITaskFactory taskFactory = new TaskFactory();379 380 643 IEventType eventType1 = new KeyboardFocusChange(); 381 644 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 382 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);645 ITask task1 = createNewEventTask(eventType1, eventTarget1); 383 646 384 647 IEventType eventType2 = new KeyboardFocusChange(); 385 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);386 387 assertLexicallyEqual( task1, task2);648 ITask task2 = createNewEventTask(eventType2, eventTarget1); 649 650 assertLexicallyEqual(new GUIEventTaskComparisonRule(), task1, task2); 388 651 } 389 652 … … 393 656 @Test 394 657 public void test_compare_KeyboardFocusChange_03() { 395 ITaskFactory taskFactory = new TaskFactory();396 397 658 IEventType eventType1 = new KeyboardFocusChange(); 398 659 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 399 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);660 ITask task1 = createNewEventTask(eventType1, eventTarget1); 400 661 401 662 IEventType eventType2 = new KeyboardFocusChange(); 402 663 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 403 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2);404 405 assertUnequal( task1, task2);664 ITask task2 = createNewEventTask(eventType2, eventTarget2); 665 666 assertUnequal(new GUIEventTaskComparisonRule(), task1, task2); 406 667 } 407 668 … … 411 672 @Test 412 673 public void test_compare_KeyPressed_01() { 413 ITaskFactory taskFactory = new TaskFactory();414 415 674 IEventType eventType1 = new KeyPressed(VirtualKey.LETTER_A); 416 675 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 417 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);418 419 assertLexicallyEqual( task1, task1);676 ITask task1 = createNewEventTask(eventType1, eventTarget1); 677 678 assertLexicallyEqual(new GUIEventTaskComparisonRule(), task1, task1); 420 679 } 421 680 … … 425 684 @Test 426 685 public void test_compare_KeyPressed_02() { 427 ITaskFactory taskFactory = new TaskFactory();428 429 686 IEventType eventType1 = new KeyPressed(VirtualKey.LETTER_A); 430 687 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 431 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);688 ITask task1 = createNewEventTask(eventType1, eventTarget1); 432 689 433 690 IEventType eventType2 = new KeyPressed(VirtualKey.LETTER_A); 434 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);435 436 assertLexicallyEqual( task1, task2);691 ITask task2 = createNewEventTask(eventType2, eventTarget1); 692 693 assertLexicallyEqual(new GUIEventTaskComparisonRule(), task1, task2); 437 694 } 438 695 … … 442 699 @Test 443 700 public void test_compare_KeyPressed_03() { 444 ITaskFactory taskFactory = new TaskFactory();445 446 701 IEventType eventType1 = new KeyPressed(VirtualKey.LETTER_A); 447 702 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 448 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);703 ITask task1 = createNewEventTask(eventType1, eventTarget1); 449 704 450 705 IEventType eventType2 = new KeyPressed(VirtualKey.LETTER_B); 451 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);452 453 assertSemanticallyEqual( task1, task2);706 ITask task2 = createNewEventTask(eventType2, eventTarget1); 707 708 assertSemanticallyEqual(new GUIEventTaskComparisonRule(), task1, task2); 454 709 } 455 710 … … 459 714 @Test 460 715 public void test_compare_KeyPressed_04() { 461 ITaskFactory taskFactory = new TaskFactory();462 463 716 IEventType eventType1 = new KeyPressed(VirtualKey.LETTER_A); 464 717 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 465 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);718 ITask task1 = createNewEventTask(eventType1, eventTarget1); 466 719 467 720 IEventType eventType2 = new KeyPressed(VirtualKey.LETTER_A); 468 721 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 469 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2);470 471 assertUnequal( task1, task2);722 ITask task2 = createNewEventTask(eventType2, eventTarget2); 723 724 assertUnequal(new GUIEventTaskComparisonRule(), task1, task2); 472 725 } 473 726 … … 477 730 @Test 478 731 public void test_compare_KeyReleased_01() { 479 ITaskFactory taskFactory = new TaskFactory();480 481 732 IEventType eventType1 = new KeyReleased(VirtualKey.LETTER_A); 482 733 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 483 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);484 485 assertLexicallyEqual( task1, task1);734 ITask task1 = createNewEventTask(eventType1, eventTarget1); 735 736 assertLexicallyEqual(new GUIEventTaskComparisonRule(), task1, task1); 486 737 } 487 738 … … 491 742 @Test 492 743 public void test_compare_KeyReleased_02() { 493 ITaskFactory taskFactory = new TaskFactory();494 495 744 IEventType eventType1 = new KeyReleased(VirtualKey.LETTER_A); 496 745 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 497 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);746 ITask task1 = createNewEventTask(eventType1, eventTarget1); 498 747 499 748 IEventType eventType2 = new KeyReleased(VirtualKey.LETTER_A); 500 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);501 502 assertLexicallyEqual( task1, task2);749 ITask task2 = createNewEventTask(eventType2, eventTarget1); 750 751 assertLexicallyEqual(new GUIEventTaskComparisonRule(), task1, task2); 503 752 } 504 753 … … 508 757 @Test 509 758 public void test_compare_KeyReleased_03() { 510 ITaskFactory taskFactory = new TaskFactory();511 512 759 IEventType eventType1 = new KeyReleased(VirtualKey.LETTER_A); 513 760 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 514 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);761 ITask task1 = createNewEventTask(eventType1, eventTarget1); 515 762 516 763 IEventType eventType2 = new KeyReleased(VirtualKey.LETTER_B); 517 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);518 519 assertSemanticallyEqual( task1, task2);764 ITask task2 = createNewEventTask(eventType2, eventTarget1); 765 766 assertSemanticallyEqual(new GUIEventTaskComparisonRule(), task1, task2); 520 767 } 521 768 … … 525 772 @Test 526 773 public void test_compare_KeyReleased_04() { 527 ITaskFactory taskFactory = new TaskFactory();528 529 774 IEventType eventType1 = new KeyReleased(VirtualKey.LETTER_A); 530 775 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 531 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);776 ITask task1 = createNewEventTask(eventType1, eventTarget1); 532 777 533 778 IEventType eventType2 = new KeyReleased(VirtualKey.LETTER_A); 534 779 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 535 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2);536 537 assertUnequal( task1, task2);780 ITask task2 = createNewEventTask(eventType2, eventTarget2); 781 782 assertUnequal(new GUIEventTaskComparisonRule(), task1, task2); 538 783 } 539 784 … … 543 788 @Test 544 789 public void test_compare_KeyTyped_01() { 545 ITaskFactory taskFactory = new TaskFactory();546 547 790 IEventType eventType1 = new KeyTyped(VirtualKey.LETTER_A); 548 791 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 549 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);550 551 assertLexicallyEqual( task1, task1);792 ITask task1 = createNewEventTask(eventType1, eventTarget1); 793 794 assertLexicallyEqual(new GUIEventTaskComparisonRule(), task1, task1); 552 795 } 553 796 … … 557 800 @Test 558 801 public void test_compare_KeyTyped_02() { 559 ITaskFactory taskFactory = new TaskFactory();560 561 802 IEventType eventType1 = new KeyTyped(VirtualKey.LETTER_A); 562 803 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 563 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);804 ITask task1 = createNewEventTask(eventType1, eventTarget1); 564 805 565 806 IEventType eventType2 = new KeyTyped(VirtualKey.LETTER_A); 566 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);567 568 assertLexicallyEqual( task1, task2);807 ITask task2 = createNewEventTask(eventType2, eventTarget1); 808 809 assertLexicallyEqual(new GUIEventTaskComparisonRule(), task1, task2); 569 810 } 570 811 … … 574 815 @Test 575 816 public void test_compare_KeyTyped_03() { 576 ITaskFactory taskFactory = new TaskFactory();577 578 817 IEventType eventType1 = new KeyTyped(VirtualKey.LETTER_A); 579 818 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 580 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);819 ITask task1 = createNewEventTask(eventType1, eventTarget1); 581 820 582 821 IEventType eventType2 = new KeyTyped(VirtualKey.LETTER_B); 583 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);584 585 assertSemanticallyEqual( task1, task2);822 ITask task2 = createNewEventTask(eventType2, eventTarget1); 823 824 assertSemanticallyEqual(new GUIEventTaskComparisonRule(), task1, task2); 586 825 } 587 826 … … 591 830 @Test 592 831 public void test_compare_KeyTyped_04() { 593 ITaskFactory taskFactory = new TaskFactory();594 595 832 IEventType eventType1 = new KeyTyped(VirtualKey.LETTER_A); 596 833 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 597 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);834 ITask task1 = createNewEventTask(eventType1, eventTarget1); 598 835 599 836 IEventType eventType2 = new KeyTyped(VirtualKey.LETTER_A); 600 837 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 601 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2);602 603 assertUnequal( task1, task2);838 ITask task2 = createNewEventTask(eventType2, eventTarget2); 839 840 assertUnequal(new GUIEventTaskComparisonRule(), task1, task2); 604 841 } 605 842 … … 609 846 @Test 610 847 public void test_compare_MouseButtonDown_01() { 611 ITaskFactory taskFactory = new TaskFactory();612 613 848 IEventType eventType1 = new MouseButtonDown(MouseButtonInteraction.Button.LEFT, 1, 2); 614 849 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 615 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);616 617 assertLexicallyEqual( task1, task1);850 ITask task1 = createNewEventTask(eventType1, eventTarget1); 851 852 assertLexicallyEqual(new GUIEventTaskComparisonRule(), task1, task1); 618 853 } 619 854 … … 623 858 @Test 624 859 public void test_compare_MouseButtonDown_02() { 625 ITaskFactory taskFactory = new TaskFactory();626 627 860 IEventType eventType1 = new MouseButtonDown(MouseButtonInteraction.Button.LEFT, 1, 2); 628 861 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 629 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);862 ITask task1 = createNewEventTask(eventType1, eventTarget1); 630 863 631 864 IEventType eventType2 = new MouseButtonDown(MouseButtonInteraction.Button.LEFT, 1, 2); 632 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);633 634 assertLexicallyEqual( task1, task2);865 ITask task2 = createNewEventTask(eventType2, eventTarget1); 866 867 assertLexicallyEqual(new GUIEventTaskComparisonRule(), task1, task2); 635 868 } 636 869 … … 640 873 @Test 641 874 public void test_compare_MouseButtonDown_03() { 642 ITaskFactory taskFactory = new TaskFactory();643 644 875 IEventType eventType1 = new MouseButtonDown(MouseButtonInteraction.Button.LEFT, 1, 2); 645 876 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 646 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);877 ITask task1 = createNewEventTask(eventType1, eventTarget1); 647 878 648 879 IEventType eventType2 = new MouseButtonDown(MouseButtonInteraction.Button.LEFT, 1, 3); 649 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);650 651 assertSemanticallyEqual( task1, task2);880 ITask task2 = createNewEventTask(eventType2, eventTarget1); 881 882 assertSemanticallyEqual(new GUIEventTaskComparisonRule(), task1, task2); 652 883 } 653 884 … … 657 888 @Test 658 889 public void test_compare_MouseButtonDown_04() { 659 ITaskFactory taskFactory = new TaskFactory();660 661 890 IEventType eventType1 = new MouseButtonDown(MouseButtonInteraction.Button.LEFT, 1, 2); 662 891 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 663 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);892 ITask task1 = createNewEventTask(eventType1, eventTarget1); 664 893 665 894 IEventType eventType2 = new MouseButtonDown(MouseButtonInteraction.Button.LEFT, 3, 2); 666 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);667 668 assertSemanticallyEqual( task1, task2);895 ITask task2 = createNewEventTask(eventType2, eventTarget1); 896 897 assertSemanticallyEqual(new GUIEventTaskComparisonRule(), task1, task2); 669 898 } 670 899 … … 674 903 @Test 675 904 public void test_compare_MouseButtonDown_05() { 676 ITaskFactory taskFactory = new TaskFactory();677 678 905 IEventType eventType1 = new MouseButtonDown(MouseButtonInteraction.Button.LEFT, 1, 2); 679 906 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 680 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);907 ITask task1 = createNewEventTask(eventType1, eventTarget1); 681 908 682 909 IEventType eventType2 = new MouseButtonDown(MouseButtonInteraction.Button.RIGHT, 1, 2); 683 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);684 685 assertUnequal( task1, task2);910 ITask task2 = createNewEventTask(eventType2, eventTarget1); 911 912 assertUnequal(new GUIEventTaskComparisonRule(), task1, task2); 686 913 } 687 914 … … 691 918 @Test 692 919 public void test_compare_MouseButtonDown_06() { 693 ITaskFactory taskFactory = new TaskFactory();694 695 920 IEventType eventType1 = new MouseButtonDown(MouseButtonInteraction.Button.LEFT, 1, 2); 696 921 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 697 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);922 ITask task1 = createNewEventTask(eventType1, eventTarget1); 698 923 699 924 IEventType eventType2 = new MouseButtonDown(MouseButtonInteraction.Button.LEFT, 1, 2); 700 925 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 701 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2);702 703 assertUnequal( task1, task2);926 ITask task2 = createNewEventTask(eventType2, eventTarget2); 927 928 assertUnequal(new GUIEventTaskComparisonRule(), task1, task2); 704 929 } 705 930 … … 709 934 @Test 710 935 public void test_compare_MouseButtonUp_01() { 711 ITaskFactory taskFactory = new TaskFactory();712 713 936 IEventType eventType1 = new MouseButtonUp(MouseButtonInteraction.Button.LEFT, 1, 2); 714 937 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 715 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);716 717 assertLexicallyEqual( task1, task1);938 ITask task1 = createNewEventTask(eventType1, eventTarget1); 939 940 assertLexicallyEqual(new GUIEventTaskComparisonRule(), task1, task1); 718 941 } 719 942 … … 723 946 @Test 724 947 public void test_compare_MouseButtonUp_02() { 725 ITaskFactory taskFactory = new TaskFactory();726 727 948 IEventType eventType1 = new MouseButtonUp(MouseButtonInteraction.Button.LEFT, 1, 2); 728 949 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 729 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);950 ITask task1 = createNewEventTask(eventType1, eventTarget1); 730 951 731 952 IEventType eventType2 = new MouseButtonUp(MouseButtonInteraction.Button.LEFT, 1, 2); 732 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);733 734 assertLexicallyEqual( task1, task2);953 ITask task2 = createNewEventTask(eventType2, eventTarget1); 954 955 assertLexicallyEqual(new GUIEventTaskComparisonRule(), task1, task2); 735 956 } 736 957 … … 740 961 @Test 741 962 public void test_compare_MouseButtonUp_03() { 742 ITaskFactory taskFactory = new TaskFactory();743 744 963 IEventType eventType1 = new MouseButtonUp(MouseButtonInteraction.Button.LEFT, 1, 2); 745 964 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 746 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);965 ITask task1 = createNewEventTask(eventType1, eventTarget1); 747 966 748 967 IEventType eventType2 = new MouseButtonUp(MouseButtonInteraction.Button.LEFT, 1, 3); 749 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);750 751 assertSemanticallyEqual( task1, task2);968 ITask task2 = createNewEventTask(eventType2, eventTarget1); 969 970 assertSemanticallyEqual(new GUIEventTaskComparisonRule(), task1, task2); 752 971 } 753 972 … … 757 976 @Test 758 977 public void test_compare_MouseButtonUp_04() { 759 ITaskFactory taskFactory = new TaskFactory();760 761 978 IEventType eventType1 = new MouseButtonUp(MouseButtonInteraction.Button.LEFT, 1, 2); 762 979 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 763 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);980 ITask task1 = createNewEventTask(eventType1, eventTarget1); 764 981 765 982 IEventType eventType2 = new MouseButtonUp(MouseButtonInteraction.Button.LEFT, 3, 2); 766 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);767 768 assertSemanticallyEqual( task1, task2);983 ITask task2 = createNewEventTask(eventType2, eventTarget1); 984 985 assertSemanticallyEqual(new GUIEventTaskComparisonRule(), task1, task2); 769 986 } 770 987 … … 774 991 @Test 775 992 public void test_compare_MouseButtonUp_05() { 776 ITaskFactory taskFactory = new TaskFactory();777 778 993 IEventType eventType1 = new MouseButtonUp(MouseButtonInteraction.Button.LEFT, 1, 2); 779 994 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 780 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);995 ITask task1 = createNewEventTask(eventType1, eventTarget1); 781 996 782 997 IEventType eventType2 = new MouseButtonUp(MouseButtonInteraction.Button.RIGHT, 1, 2); 783 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);784 785 assertUnequal( task1, task2);998 ITask task2 = createNewEventTask(eventType2, eventTarget1); 999 1000 assertUnequal(new GUIEventTaskComparisonRule(), task1, task2); 786 1001 } 787 1002 … … 791 1006 @Test 792 1007 public void test_compare_MouseButtonUp_06() { 793 ITaskFactory taskFactory = new TaskFactory();794 795 1008 IEventType eventType1 = new MouseButtonUp(MouseButtonInteraction.Button.LEFT, 1, 2); 796 1009 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 797 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1010 ITask task1 = createNewEventTask(eventType1, eventTarget1); 798 1011 799 1012 IEventType eventType2 = new MouseButtonUp(MouseButtonInteraction.Button.LEFT, 1, 2); 800 1013 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 801 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2);802 803 assertUnequal( task1, task2);1014 ITask task2 = createNewEventTask(eventType2, eventTarget2); 1015 1016 assertUnequal(new GUIEventTaskComparisonRule(), task1, task2); 804 1017 } 805 1018 … … 809 1022 @Test 810 1023 public void test_compare_MouseClick_01() { 811 ITaskFactory taskFactory = new TaskFactory();812 813 1024 IEventType eventType1 = new MouseClick(MouseButtonInteraction.Button.LEFT, 1, 2); 814 1025 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 815 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);816 817 assertLexicallyEqual( task1, task1);1026 ITask task1 = createNewEventTask(eventType1, eventTarget1); 1027 1028 assertLexicallyEqual(new GUIEventTaskComparisonRule(), task1, task1); 818 1029 } 819 1030 … … 823 1034 @Test 824 1035 public void test_compare_MouseClick_02() { 825 ITaskFactory taskFactory = new TaskFactory();826 827 1036 IEventType eventType1 = new MouseClick(MouseButtonInteraction.Button.LEFT, 1, 2); 828 1037 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 829 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1038 ITask task1 = createNewEventTask(eventType1, eventTarget1); 830 1039 831 1040 IEventType eventType2 = new MouseClick(MouseButtonInteraction.Button.LEFT, 1, 2); 832 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);833 834 assertLexicallyEqual( task1, task2);1041 ITask task2 = createNewEventTask(eventType2, eventTarget1); 1042 1043 assertLexicallyEqual(new GUIEventTaskComparisonRule(), task1, task2); 835 1044 } 836 1045 … … 840 1049 @Test 841 1050 public void test_compare_MouseClick_03() { 842 ITaskFactory taskFactory = new TaskFactory();843 844 1051 IEventType eventType1 = new MouseClick(MouseButtonInteraction.Button.LEFT, 1, 2); 845 1052 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 846 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1053 ITask task1 = createNewEventTask(eventType1, eventTarget1); 847 1054 848 1055 IEventType eventType2 = new MouseClick(MouseButtonInteraction.Button.LEFT, 1, 3); 849 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);850 851 assertSemanticallyEqual( task1, task2);1056 ITask task2 = createNewEventTask(eventType2, eventTarget1); 1057 1058 assertSemanticallyEqual(new GUIEventTaskComparisonRule(), task1, task2); 852 1059 } 853 1060 … … 857 1064 @Test 858 1065 public void test_compare_MouseClick_04() { 859 ITaskFactory taskFactory = new TaskFactory();860 861 1066 IEventType eventType1 = new MouseClick(MouseButtonInteraction.Button.LEFT, 1, 2); 862 1067 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 863 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1068 ITask task1 = createNewEventTask(eventType1, eventTarget1); 864 1069 865 1070 IEventType eventType2 = new MouseClick(MouseButtonInteraction.Button.LEFT, 3, 2); 866 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);867 868 assertSemanticallyEqual( task1, task2);1071 ITask task2 = createNewEventTask(eventType2, eventTarget1); 1072 1073 assertSemanticallyEqual(new GUIEventTaskComparisonRule(), task1, task2); 869 1074 } 870 1075 … … 874 1079 @Test 875 1080 public void test_compare_MouseClick_05() { 876 ITaskFactory taskFactory = new TaskFactory();877 878 1081 IEventType eventType1 = new MouseClick(MouseButtonInteraction.Button.LEFT, 1, 2); 879 1082 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 880 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1083 ITask task1 = createNewEventTask(eventType1, eventTarget1); 881 1084 882 1085 IEventType eventType2 = new MouseClick(MouseButtonInteraction.Button.RIGHT, 1, 2); 883 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);884 885 assertUnequal( task1, task2);1086 ITask task2 = createNewEventTask(eventType2, eventTarget1); 1087 1088 assertUnequal(new GUIEventTaskComparisonRule(), task1, task2); 886 1089 } 887 1090 … … 891 1094 @Test 892 1095 public void test_compare_MouseClick_06() { 893 ITaskFactory taskFactory = new TaskFactory();894 895 1096 IEventType eventType1 = new MouseClick(MouseButtonInteraction.Button.LEFT, 1, 2); 896 1097 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 897 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1098 ITask task1 = createNewEventTask(eventType1, eventTarget1); 898 1099 899 1100 IEventType eventType2 = new MouseClick(MouseButtonInteraction.Button.LEFT, 1, 2); 900 1101 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 901 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2);902 903 assertUnequal( task1, task2);1102 ITask task2 = createNewEventTask(eventType2, eventTarget2); 1103 1104 assertUnequal(new GUIEventTaskComparisonRule(), task1, task2); 904 1105 } 905 1106 … … 909 1110 @Test 910 1111 public void test_compare_MouseDoubleClick_01() { 911 ITaskFactory taskFactory = new TaskFactory();912 913 1112 IEventType eventType1 = new MouseDoubleClick(MouseButtonInteraction.Button.LEFT, 1, 2); 914 1113 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 915 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);916 917 assertLexicallyEqual( task1, task1);1114 ITask task1 = createNewEventTask(eventType1, eventTarget1); 1115 1116 assertLexicallyEqual(new GUIEventTaskComparisonRule(), task1, task1); 918 1117 } 919 1118 … … 923 1122 @Test 924 1123 public void test_compare_MouseDoubleClick_02() { 925 ITaskFactory taskFactory = new TaskFactory();926 927 1124 IEventType eventType1 = new MouseDoubleClick(MouseButtonInteraction.Button.LEFT, 1, 2); 928 1125 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 929 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1126 ITask task1 = createNewEventTask(eventType1, eventTarget1); 930 1127 931 1128 IEventType eventType2 = new MouseDoubleClick(MouseButtonInteraction.Button.LEFT, 1, 2); 932 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);933 934 assertLexicallyEqual( task1, task2);1129 ITask task2 = createNewEventTask(eventType2, eventTarget1); 1130 1131 assertLexicallyEqual(new GUIEventTaskComparisonRule(), task1, task2); 935 1132 } 936 1133 … … 940 1137 @Test 941 1138 public void test_compare_MouseDoubleClick_03() { 942 ITaskFactory taskFactory = new TaskFactory();943 944 1139 IEventType eventType1 = new MouseDoubleClick(MouseButtonInteraction.Button.LEFT, 1, 2); 945 1140 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 946 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1141 ITask task1 = createNewEventTask(eventType1, eventTarget1); 947 1142 948 1143 IEventType eventType2 = new MouseDoubleClick(MouseButtonInteraction.Button.LEFT, 1, 3); 949 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);950 951 assertSemanticallyEqual( task1, task2);1144 ITask task2 = createNewEventTask(eventType2, eventTarget1); 1145 1146 assertSemanticallyEqual(new GUIEventTaskComparisonRule(), task1, task2); 952 1147 } 953 1148 … … 957 1152 @Test 958 1153 public void test_compare_MouseDoubleClick_04() { 959 ITaskFactory taskFactory = new TaskFactory();960 961 1154 IEventType eventType1 = new MouseDoubleClick(MouseButtonInteraction.Button.LEFT, 1, 2); 962 1155 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 963 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1156 ITask task1 = createNewEventTask(eventType1, eventTarget1); 964 1157 965 1158 IEventType eventType2 = new MouseDoubleClick(MouseButtonInteraction.Button.LEFT, 3, 2); 966 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);967 968 assertSemanticallyEqual( task1, task2);1159 ITask task2 = createNewEventTask(eventType2, eventTarget1); 1160 1161 assertSemanticallyEqual(new GUIEventTaskComparisonRule(), task1, task2); 969 1162 } 970 1163 … … 974 1167 @Test 975 1168 public void test_compare_MouseDoubleClick_05() { 976 ITaskFactory taskFactory = new TaskFactory();977 978 1169 IEventType eventType1 = new MouseDoubleClick(MouseButtonInteraction.Button.LEFT, 1, 2); 979 1170 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 980 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1171 ITask task1 = createNewEventTask(eventType1, eventTarget1); 981 1172 982 1173 IEventType eventType2 = new MouseDoubleClick(MouseButtonInteraction.Button.RIGHT, 1, 2); 983 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);984 985 assertUnequal( task1, task2);1174 ITask task2 = createNewEventTask(eventType2, eventTarget1); 1175 1176 assertUnequal(new GUIEventTaskComparisonRule(), task1, task2); 986 1177 } 987 1178 … … 991 1182 @Test 992 1183 public void test_compare_MouseDoubleClick_06() { 993 ITaskFactory taskFactory = new TaskFactory();994 995 1184 IEventType eventType1 = new MouseDoubleClick(MouseButtonInteraction.Button.LEFT, 1, 2); 996 1185 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 997 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1186 ITask task1 = createNewEventTask(eventType1, eventTarget1); 998 1187 999 1188 IEventType eventType2 = new MouseDoubleClick(MouseButtonInteraction.Button.LEFT, 1, 2); 1000 1189 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 1001 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2);1002 1003 assertUnequal( task1, task2);1190 ITask task2 = createNewEventTask(eventType2, eventTarget2); 1191 1192 assertUnequal(new GUIEventTaskComparisonRule(), task1, task2); 1004 1193 } 1005 1194 … … 1009 1198 @Test 1010 1199 public void test_compare_MouseDragAndDrop_01() { 1011 ITaskFactory taskFactory = new TaskFactory();1012 1013 1200 IEventType eventType1 = new MouseDragAndDrop(1, 2, 3, 4); 1014 1201 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1015 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1016 1017 assertLexicallyEqual( task1, task1);1202 ITask task1 = createNewEventTask(eventType1, eventTarget1); 1203 1204 assertLexicallyEqual(new GUIEventTaskComparisonRule(), task1, task1); 1018 1205 } 1019 1206 … … 1023 1210 @Test 1024 1211 public void test_compare_MouseDragAndDrop_02() { 1025 ITaskFactory taskFactory = new TaskFactory();1026 1027 1212 IEventType eventType1 = new MouseDragAndDrop(1, 2, 3, 4); 1028 1213 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1029 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1214 ITask task1 = createNewEventTask(eventType1, eventTarget1); 1030 1215 1031 1216 IEventType eventType2 = new MouseDragAndDrop(1, 2, 3, 4); 1032 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);1033 1034 assertLexicallyEqual( task1, task2);1217 ITask task2 = createNewEventTask(eventType2, eventTarget1); 1218 1219 assertLexicallyEqual(new GUIEventTaskComparisonRule(), task1, task2); 1035 1220 } 1036 1221 … … 1040 1225 @Test 1041 1226 public void test_compare_MouseDragAndDrop_03() { 1042 ITaskFactory taskFactory = new TaskFactory();1043 1044 1227 IEventType eventType1 = new MouseDragAndDrop(1, 2, 3, 4); 1045 1228 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1046 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1229 ITask task1 = createNewEventTask(eventType1, eventTarget1); 1047 1230 1048 1231 IEventType eventType2 = new MouseDragAndDrop(5, 2, 3, 4); 1049 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);1050 1051 assertSemanticallyEqual( task1, task2);1232 ITask task2 = createNewEventTask(eventType2, eventTarget1); 1233 1234 assertSemanticallyEqual(new GUIEventTaskComparisonRule(), task1, task2); 1052 1235 } 1053 1236 … … 1057 1240 @Test 1058 1241 public void test_compare_MouseDragAndDrop_04() { 1059 ITaskFactory taskFactory = new TaskFactory();1060 1061 1242 IEventType eventType1 = new MouseDragAndDrop(1, 2, 3, 4); 1062 1243 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1063 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1244 ITask task1 = createNewEventTask(eventType1, eventTarget1); 1064 1245 1065 1246 IEventType eventType2 = new MouseDragAndDrop(1, 5, 3, 4); 1066 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);1067 1068 assertSemanticallyEqual( task1, task2);1247 ITask task2 = createNewEventTask(eventType2, eventTarget1); 1248 1249 assertSemanticallyEqual(new GUIEventTaskComparisonRule(), task1, task2); 1069 1250 } 1070 1251 … … 1074 1255 @Test 1075 1256 public void test_compare_MouseDragAndDrop_05() { 1076 ITaskFactory taskFactory = new TaskFactory();1077 1078 1257 IEventType eventType1 = new MouseDragAndDrop(1, 2, 3, 4); 1079 1258 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1080 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1259 ITask task1 = createNewEventTask(eventType1, eventTarget1); 1081 1260 1082 1261 IEventType eventType2 = new MouseDragAndDrop(1, 2, 5, 4); 1083 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);1084 1085 assertSemanticallyEqual( task1, task2);1262 ITask task2 = createNewEventTask(eventType2, eventTarget1); 1263 1264 assertSemanticallyEqual(new GUIEventTaskComparisonRule(), task1, task2); 1086 1265 } 1087 1266 … … 1091 1270 @Test 1092 1271 public void test_compare_MouseDragAndDrop_06() { 1093 ITaskFactory taskFactory = new TaskFactory();1094 1095 1272 IEventType eventType1 = new MouseDragAndDrop(1, 2, 3, 4); 1096 1273 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1097 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1274 ITask task1 = createNewEventTask(eventType1, eventTarget1); 1098 1275 1099 1276 IEventType eventType2 = new MouseDragAndDrop(1, 2, 3, 5); 1100 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);1101 1102 assertSemanticallyEqual( task1, task2);1277 ITask task2 = createNewEventTask(eventType2, eventTarget1); 1278 1279 assertSemanticallyEqual(new GUIEventTaskComparisonRule(), task1, task2); 1103 1280 } 1104 1281 … … 1108 1285 @Test 1109 1286 public void test_compare_MouseDragAndDrop_07() { 1110 ITaskFactory taskFactory = new TaskFactory();1111 1112 1287 IEventType eventType1 = new MouseDragAndDrop(1, 2, 3, 4); 1113 1288 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1114 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1289 ITask task1 = createNewEventTask(eventType1, eventTarget1); 1115 1290 1116 1291 IEventType eventType2 = new MouseDragAndDrop(1, 2, 3, 4); 1117 1292 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 1118 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2);1119 1120 assertUnequal( task1, task2);1293 ITask task2 = createNewEventTask(eventType2, eventTarget2); 1294 1295 assertUnequal(new GUIEventTaskComparisonRule(), task1, task2); 1121 1296 } 1122 1297 … … 1126 1301 @Test 1127 1302 public void test_compare_Scroll_01() { 1128 ITaskFactory taskFactory = new TaskFactory();1129 1130 1303 IEventType eventType1 = new Scroll(1, 2); 1131 1304 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1132 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1133 1134 assertLexicallyEqual( task1, task1);1305 ITask task1 = createNewEventTask(eventType1, eventTarget1); 1306 1307 assertLexicallyEqual(new GUIEventTaskComparisonRule(), task1, task1); 1135 1308 } 1136 1309 … … 1140 1313 @Test 1141 1314 public void test_compare_Scroll_02() { 1142 ITaskFactory taskFactory = new TaskFactory();1143 1144 1315 IEventType eventType1 = new Scroll(1, 2); 1145 1316 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1146 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1317 ITask task1 = createNewEventTask(eventType1, eventTarget1); 1147 1318 1148 1319 IEventType eventType2 = new Scroll(1, 2); 1149 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);1150 1151 assertLexicallyEqual( task1, task2);1320 ITask task2 = createNewEventTask(eventType2, eventTarget1); 1321 1322 assertLexicallyEqual(new GUIEventTaskComparisonRule(), task1, task2); 1152 1323 } 1153 1324 … … 1157 1328 @Test 1158 1329 public void test_compare_Scroll_03() { 1159 ITaskFactory taskFactory = new TaskFactory();1160 1161 1330 IEventType eventType1 = new Scroll(1, 2); 1162 1331 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1163 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1332 ITask task1 = createNewEventTask(eventType1, eventTarget1); 1164 1333 1165 1334 IEventType eventType2 = new Scroll(3, 2); 1166 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);1167 1168 assertSemanticallyEqual( task1, task2);1335 ITask task2 = createNewEventTask(eventType2, eventTarget1); 1336 1337 assertSemanticallyEqual(new GUIEventTaskComparisonRule(), task1, task2); 1169 1338 } 1170 1339 … … 1174 1343 @Test 1175 1344 public void test_compare_Scroll_04() { 1176 ITaskFactory taskFactory = new TaskFactory();1177 1178 1345 IEventType eventType1 = new Scroll(1, 2); 1179 1346 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1180 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1347 ITask task1 = createNewEventTask(eventType1, eventTarget1); 1181 1348 1182 1349 IEventType eventType2 = new Scroll(1, 3); 1183 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);1184 1185 assertSemanticallyEqual( task1, task2);1350 ITask task2 = createNewEventTask(eventType2, eventTarget1); 1351 1352 assertSemanticallyEqual(new GUIEventTaskComparisonRule(), task1, task2); 1186 1353 } 1187 1354 … … 1191 1358 @Test 1192 1359 public void test_compare_Scroll_05() { 1193 ITaskFactory taskFactory = new TaskFactory();1194 1195 1360 IEventType eventType1 = new Scroll(1, 2); 1196 1361 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1197 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1362 ITask task1 = createNewEventTask(eventType1, eventTarget1); 1198 1363 1199 1364 IEventType eventType2 = new Scroll(1, 2); 1200 1365 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 1201 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2);1202 1203 assertUnequal( task1, task2);1366 ITask task2 = createNewEventTask(eventType2, eventTarget2); 1367 1368 assertUnequal(new GUIEventTaskComparisonRule(), task1, task2); 1204 1369 } 1205 1370 … … 1209 1374 @Test 1210 1375 public void test_compare_TextInput_01() { 1211 ITaskFactory taskFactory = new TaskFactory();1212 1213 1376 IEventType eventType1 = new StringEventType("eventType1"); 1214 1377 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); … … 1216 1379 textInputEvents1.add(new Event(eventType1, eventTarget1)); 1217 1380 eventType1 = new TextInput("enteredText1", textInputEvents1); 1218 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1219 1220 assertLexicallyEqual( task1, task1);1381 ITask task1 = createNewEventTask(eventType1, eventTarget1); 1382 1383 assertLexicallyEqual(new GUIEventTaskComparisonRule(), task1, task1); 1221 1384 } 1222 1385 … … 1226 1389 @Test 1227 1390 public void test_compare_TextInput_02() { 1228 ITaskFactory taskFactory = new TaskFactory();1229 1230 1391 IEventType eventType1 = new StringEventType("eventType1"); 1231 1392 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); … … 1233 1394 textInputEvents1.add(new Event(eventType1, eventTarget1)); 1234 1395 eventType1 = new TextInput("enteredText1", textInputEvents1); 1235 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1396 ITask task1 = createNewEventTask(eventType1, eventTarget1); 1236 1397 1237 1398 IEventType eventType2 = new TextInput("enteredText1", textInputEvents1); 1238 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);1239 1240 assertLexicallyEqual( task1, task2);1399 ITask task2 = createNewEventTask(eventType2, eventTarget1); 1400 1401 assertLexicallyEqual(new GUIEventTaskComparisonRule(), task1, task2); 1241 1402 } 1242 1403 … … 1246 1407 @Test 1247 1408 public void test_compare_TextInput_03() { 1248 ITaskFactory taskFactory = new TaskFactory();1249 1250 1409 IEventType eventType1 = new StringEventType("eventType1"); 1251 1410 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); … … 1253 1412 textInputEvents1.add(new Event(eventType1, eventTarget1)); 1254 1413 eventType1 = new TextInput("enteredText1", textInputEvents1); 1255 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1414 ITask task1 = createNewEventTask(eventType1, eventTarget1); 1256 1415 1257 1416 IEventType eventType2 = new StringEventType("eventType2"); … … 1259 1418 textInputEvents2.add(new Event(eventType2, eventTarget1)); 1260 1419 eventType2 = new TextInput("enteredText1", textInputEvents2); 1261 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);1262 1263 assertSyntacticallyEqual( task1, task2);1420 ITask task2 = createNewEventTask(eventType2, eventTarget1); 1421 1422 assertSyntacticallyEqual(new GUIEventTaskComparisonRule(), task1, task2); 1264 1423 } 1265 1424 … … 1269 1428 @Test 1270 1429 public void test_compare_TextInput_04() { 1271 ITaskFactory taskFactory = new TaskFactory();1272 1273 1430 IEventType eventType1 = new StringEventType("eventType1"); 1274 1431 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); … … 1276 1433 textInputEvents1.add(new Event(eventType1, eventTarget1)); 1277 1434 eventType1 = new TextInput("enteredText1", textInputEvents1); 1278 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1435 ITask task1 = createNewEventTask(eventType1, eventTarget1); 1279 1436 1280 1437 IEventType eventType2 = new StringEventType("eventType2"); … … 1282 1439 textInputEvents2.add(new Event(eventType2, eventTarget1)); 1283 1440 eventType2 = new TextInput("enteredText2", textInputEvents2); 1284 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);1285 1286 assertSemanticallyEqual( task1, task2);1441 ITask task2 = createNewEventTask(eventType2, eventTarget1); 1442 1443 assertSemanticallyEqual(new GUIEventTaskComparisonRule(), task1, task2); 1287 1444 } 1288 1445 … … 1292 1449 @Test 1293 1450 public void test_compare_TextInput_05() { 1294 ITaskFactory taskFactory = new TaskFactory();1295 1296 1451 IEventType eventType1 = new StringEventType("eventType1"); 1297 1452 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); … … 1299 1454 textInputEvents1.add(new Event(eventType1, eventTarget1)); 1300 1455 eventType1 = new TextInput("enteredText1", textInputEvents1); 1301 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1302 1303 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 1304 ITask task2 = taskFactory.createNewEventTask(eventType1, eventTarget2);1305 1306 assertUnequal( task1, task2);1456 ITask task1 = createNewEventTask(eventType1, eventTarget1); 1457 1458 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 1459 ITask task2 = createNewEventTask(eventType1, eventTarget2); 1460 1461 assertUnequal(new GUIEventTaskComparisonRule(), task1, task2); 1307 1462 } 1308 1463 … … 1312 1467 @Test 1313 1468 public void test_compare_TextSelection_01() { 1314 ITaskFactory taskFactory = new TaskFactory();1315 1316 1469 IEventType eventType1 = new TextSelection(); 1317 1470 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1318 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1319 1320 assertLexicallyEqual( task1, task1);1471 ITask task1 = createNewEventTask(eventType1, eventTarget1); 1472 1473 assertLexicallyEqual(new GUIEventTaskComparisonRule(), task1, task1); 1321 1474 } 1322 1475 … … 1326 1479 @Test 1327 1480 public void test_compare_TextSelection_02() { 1328 ITaskFactory taskFactory = new TaskFactory();1329 1330 1481 IEventType eventType1 = new TextSelection(); 1331 1482 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1332 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1483 ITask task1 = createNewEventTask(eventType1, eventTarget1); 1333 1484 1334 1485 IEventType eventType2 = new TextSelection(); 1335 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);1336 1337 assertLexicallyEqual( task1, task2);1486 ITask task2 = createNewEventTask(eventType2, eventTarget1); 1487 1488 assertLexicallyEqual(new GUIEventTaskComparisonRule(), task1, task2); 1338 1489 } 1339 1490 … … 1343 1494 @Test 1344 1495 public void test_compare_TextSelection_03() { 1345 ITaskFactory taskFactory = new TaskFactory();1346 1347 1496 IEventType eventType1 = new TextSelection(); 1348 1497 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1349 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1498 ITask task1 = createNewEventTask(eventType1, eventTarget1); 1350 1499 1351 1500 IEventType eventType2 = new TextSelection(); 1352 1501 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 1353 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2);1354 1355 assertUnequal( task1, task2);1502 ITask task2 = createNewEventTask(eventType2, eventTarget2); 1503 1504 assertUnequal(new GUIEventTaskComparisonRule(), task1, task2); 1356 1505 } 1357 1506 … … 1361 1510 @Test 1362 1511 public void test_compare_ValueSelection_01() { 1363 ITaskFactory taskFactory = new TaskFactory();1364 1365 1512 IEventType eventType1 = new ValueSelection<String>("value1"); 1366 1513 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1367 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1368 1369 assertLexicallyEqual( task1, task1);1514 ITask task1 = createNewEventTask(eventType1, eventTarget1); 1515 1516 assertLexicallyEqual(new GUIEventTaskComparisonRule(), task1, task1); 1370 1517 } 1371 1518 … … 1375 1522 @Test 1376 1523 public void test_compare_ValueSelection_02() { 1377 ITaskFactory taskFactory = new TaskFactory();1378 1379 1524 IEventType eventType1 = new ValueSelection<String>("value1"); 1380 1525 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1381 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1526 ITask task1 = createNewEventTask(eventType1, eventTarget1); 1382 1527 1383 1528 IEventType eventType2 = new ValueSelection<String>("value1"); 1384 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);1385 1386 assertLexicallyEqual( task1, task2);1529 ITask task2 = createNewEventTask(eventType2, eventTarget1); 1530 1531 assertLexicallyEqual(new GUIEventTaskComparisonRule(), task1, task2); 1387 1532 } 1388 1533 … … 1392 1537 @Test 1393 1538 public void test_compare_ValueSelection_03() { 1394 ITaskFactory taskFactory = new TaskFactory();1395 1396 1539 IEventType eventType1 = new ValueSelection<String>("value1"); 1397 1540 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1398 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1541 ITask task1 = createNewEventTask(eventType1, eventTarget1); 1399 1542 1400 1543 IEventType eventType2 = new ValueSelection<String>("value2"); 1401 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);1402 1403 assertSemanticallyEqual( task1, task2);1544 ITask task2 = createNewEventTask(eventType2, eventTarget1); 1545 1546 assertSemanticallyEqual(new GUIEventTaskComparisonRule(), task1, task2); 1404 1547 } 1405 1548 … … 1409 1552 @Test 1410 1553 public void test_compare_ValueSelection_04() { 1411 ITaskFactory taskFactory = new TaskFactory();1412 1413 1554 IEventType eventType1 = new ValueSelection<String>("value1"); 1414 1555 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 1415 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1);1556 ITask task1 = createNewEventTask(eventType1, eventTarget1); 1416 1557 1417 1558 IEventType eventType2 = new ValueSelection<String>("value1"); 1418 1559 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 1419 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2); 1420 1421 assertUnequal(task1, task2); 1422 } 1423 1424 /** 1425 * 1426 */ 1427 private void assertLexicallyEqual(ITask task1, ITask task2) { 1428 GUIEventTaskComparisonRule rule = new GUIEventTaskComparisonRule(); 1429 1430 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(task1, task2)); 1431 assertTrue(rule.areLexicallyEqual(task1, task2)); 1432 assertTrue(rule.areSyntacticallyEqual(task1, task2)); 1433 assertTrue(rule.areSemanticallyEqual(task1, task2)); 1434 1435 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(task2, task1)); 1436 assertTrue(rule.areLexicallyEqual(task2, task1)); 1437 assertTrue(rule.areSyntacticallyEqual(task2, task1)); 1438 assertTrue(rule.areSemanticallyEqual(task2, task1)); 1439 } 1440 1441 /** 1442 * 1443 */ 1444 private void assertSyntacticallyEqual(ITask task1, ITask task2) { 1445 GUIEventTaskComparisonRule rule = new GUIEventTaskComparisonRule(); 1446 1447 assertEquals(TaskEquality.SYNTACTICALLY_EQUAL, rule.compare(task1, task2)); 1448 assertFalse(rule.areLexicallyEqual(task1, task2)); 1449 assertTrue(rule.areSyntacticallyEqual(task1, task2)); 1450 assertTrue(rule.areSemanticallyEqual(task1, task2)); 1451 1452 assertEquals(TaskEquality.SYNTACTICALLY_EQUAL, rule.compare(task2, task1)); 1453 assertFalse(rule.areLexicallyEqual(task2, task1)); 1454 assertTrue(rule.areSyntacticallyEqual(task2, task1)); 1455 assertTrue(rule.areSemanticallyEqual(task2, task1)); 1456 } 1457 1458 /** 1459 * 1460 */ 1461 private void assertSemanticallyEqual(ITask task1, ITask task2) { 1462 GUIEventTaskComparisonRule rule = new GUIEventTaskComparisonRule(); 1463 1464 assertEquals(TaskEquality.SEMANTICALLY_EQUAL, rule.compare(task1, task2)); 1465 assertFalse(rule.areLexicallyEqual(task1, task2)); 1466 assertFalse(rule.areSyntacticallyEqual(task1, task2)); 1467 assertTrue(rule.areSemanticallyEqual(task1, task2)); 1468 1469 assertEquals(TaskEquality.SEMANTICALLY_EQUAL, rule.compare(task2, task1)); 1470 assertFalse(rule.areLexicallyEqual(task2, task1)); 1471 assertFalse(rule.areSyntacticallyEqual(task2, task1)); 1472 assertTrue(rule.areSemanticallyEqual(task2, task1)); 1473 } 1474 1475 /** 1476 * 1477 */ 1478 private void assertUnequal(ITask task1, ITask task2) { 1479 GUIEventTaskComparisonRule rule = new GUIEventTaskComparisonRule(); 1480 1481 assertEquals(TaskEquality.UNEQUAL, rule.compare(task1, task2)); 1482 assertFalse(rule.areLexicallyEqual(task1, task2)); 1483 assertFalse(rule.areSyntacticallyEqual(task1, task2)); 1484 assertFalse(rule.areSemanticallyEqual(task1, task2)); 1485 1486 assertEquals(TaskEquality.UNEQUAL, rule.compare(task2, task1)); 1487 assertFalse(rule.areLexicallyEqual(task2, task1)); 1488 assertFalse(rule.areSyntacticallyEqual(task2, task1)); 1489 assertFalse(rule.areSemanticallyEqual(task2, task1)); 1560 ITask task2 = createNewEventTask(eventType2, eventTarget2); 1561 1562 assertUnequal(new GUIEventTaskComparisonRule(), task1, task2); 1490 1563 } 1491 1564 } -
trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/taskequality/IterationComparisonRuleTest.java
r1190 r1294 23 23 import de.ugoe.cs.autoquest.eventcore.StringEventType; 24 24 import de.ugoe.cs.autoquest.tasktrees.taskequality.IterationComparisonRule; 25 import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality;26 25 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 27 26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 28 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder;29 27 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 30 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory;31 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskBuilder;32 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskFactory;33 28 import de.ugoe.cs.autoquest.test.DummyGUIElement; 34 29 … … 36 31 * @author Patrick Harms 37 32 */ 38 public class IterationComparisonRuleTest { 39 40 /** 41 * 42 */ 43 @Test 44 public void test() { 45 ITaskFactory taskFactory = new TaskFactory(); 46 ITaskBuilder treeBuilder = new TaskBuilder(); 47 33 public class IterationComparisonRuleTest extends AbstractComparisonRuleTest { 34 35 /** 36 * 37 */ 38 @Test 39 public void test_isApplicable_01() { 40 IterationComparisonRule rule = new IterationComparisonRule(); 41 42 ITask task1 = createNewIteration(); 43 44 assertTrue(rule.isApplicable(task1, task1)); 45 } 46 47 /** 48 * 49 */ 50 @Test 51 public void test_isApplicable_02() { 52 IterationComparisonRule rule = new IterationComparisonRule(); 53 54 ITask task1 = createNewIteration(); 55 ITask task2 = createNewIteration(); 56 57 assertTrue(rule.isApplicable(task1, task2)); 58 assertTrue(rule.isApplicable(task2, task1)); 59 } 60 61 /** 62 * 63 */ 64 @Test 65 public void test_isApplicable_03() { 66 IterationComparisonRule rule = new IterationComparisonRule(); 67 68 ITask task1 = createNewIteration(); 69 ITask task2 = createNewSequence(); 70 71 assertFalse(rule.isApplicable(task1, task2)); 72 assertFalse(rule.isApplicable(task2, task1)); 73 } 74 75 /** 76 * 77 */ 78 @Test 79 public void test_isApplicable_04() { 80 IterationComparisonRule rule = new IterationComparisonRule(); 81 82 ITask task1 = createNewIteration(); 83 ITask task2 = createNewSelection(); 84 85 assertFalse(rule.isApplicable(task1, task2)); 86 assertFalse(rule.isApplicable(task2, task1)); 87 } 88 89 /** 90 * 91 */ 92 @Test 93 public void test_isApplicable_05() { 94 IterationComparisonRule rule = new IterationComparisonRule(); 95 96 ITask task1 = createNewIteration(); 97 ITask task2 = createNewOptional(); 98 99 assertFalse(rule.isApplicable(task1, task2)); 100 assertFalse(rule.isApplicable(task2, task1)); 101 } 102 103 /** 104 * 105 */ 106 @Test 107 public void test_isApplicable_06() { 108 IterationComparisonRule rule = new IterationComparisonRule(); 109 110 IEventType eventType1 = new StringEventType("eventType1"); 111 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 112 113 ITask task1 = createNewIteration(); 114 ITask task2 = createNewEventTask(eventType1, eventTarget1); 115 116 assertFalse(rule.isApplicable(task1, task2)); 117 assertFalse(rule.isApplicable(task2, task1)); 118 } 119 120 /** 121 * 122 */ 123 @Test 124 public void test_compare_01() { 125 IterationComparisonRule rule = new IterationComparisonRule(); 126 127 IIteration iteration1 = createNewIteration(); 128 129 assertLexicallyEqual(rule, iteration1, iteration1); 130 } 131 132 /** 133 * 134 */ 135 @Test 136 public void test_compare_02() { 137 IterationComparisonRule rule = new IterationComparisonRule(); 138 139 IIteration iteration1 = createNewIteration(); 140 IIteration iteration2 = createNewIteration(); 141 142 assertLexicallyEqual(rule, iteration1, iteration2); 143 } 144 145 /** 146 * 147 */ 148 @Test 149 public void test_compare_03() { 150 IterationComparisonRule rule = new IterationComparisonRule(); 151 152 IEventType eventType1 = new StringEventType("eventType1"); 153 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 154 155 ITask task1 = createNewEventTask(eventType1, eventTarget1); 156 157 IIteration iteration1 = createNewIteration(); 158 IIteration iteration2 = createNewIteration(); 159 160 setMarkedTask(iteration1, task1); 161 162 assertUnequal(rule, iteration1, iteration2); 163 } 164 165 /** 166 * 167 */ 168 @Test 169 public void test_compare_04() { 170 IterationComparisonRule rule = new IterationComparisonRule(); 171 172 IEventType eventType1 = new StringEventType("eventType1"); 173 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 174 175 ITask task1 = createNewEventTask(eventType1, eventTarget1); 176 177 IIteration iteration1 = createNewIteration(); 178 IIteration iteration2 = createNewIteration(); 179 180 setMarkedTask(iteration1, task1); 181 setMarkedTask(iteration2, task1); 182 183 assertLexicallyEqual(rule, iteration1, iteration2); 184 } 185 186 /** 187 * 188 */ 189 @Test 190 public void test_compare_05() { 48 191 IterationComparisonRule rule = new IterationComparisonRule(); 49 192 … … 54 197 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 55 198 56 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 57 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2); 58 59 assertFalse(rule.isApplicable(task1, task2)); 60 61 IIteration iteration1 = taskFactory.createNewIteration(); 62 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(iteration1, iteration1)); 63 64 IIteration iteration2 = taskFactory.createNewIteration(); 65 66 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(iteration1, iteration2)); 67 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(iteration2, iteration1)); 68 69 treeBuilder.setMarkedTask(iteration1, task1); 70 71 assertEquals(TaskEquality.UNEQUAL, rule.compare(iteration1, iteration2)); 72 assertEquals(TaskEquality.UNEQUAL, rule.compare(iteration2, iteration1)); 73 74 treeBuilder.setMarkedTask(iteration2, task1); 75 76 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(iteration1, iteration2)); 77 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(iteration2, iteration1)); 78 79 treeBuilder.setMarkedTask(iteration1, task2); 80 81 assertEquals(TaskEquality.UNEQUAL, rule.compare(iteration1, iteration2)); 82 assertEquals(TaskEquality.UNEQUAL, rule.compare(iteration2, iteration1)); 83 84 treeBuilder.setMarkedTask(iteration2, task2); 85 86 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(iteration1, iteration2)); 87 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(iteration2, iteration1)); 88 89 ISelection selection1 = taskFactory.createNewSelection(); 90 treeBuilder.addChild(selection1, task2); 91 treeBuilder.setMarkedTask(iteration1, selection1); 92 93 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(iteration1, iteration2)); 94 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(iteration2, iteration1)); 95 96 ISelection selection2 = taskFactory.createNewSelection(); 97 treeBuilder.addChild(selection2, task2); 98 treeBuilder.setMarkedTask(iteration2, selection2); 99 100 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(iteration1, iteration2)); 101 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(iteration2, iteration1)); 102 103 assertFalse(rule.isApplicable(iteration1, selection1)); 104 assertFalse(rule.isApplicable(selection1, iteration1)); 105 assertFalse(rule.isApplicable(iteration2, selection1)); 106 assertFalse(rule.isApplicable(selection1, iteration2)); 107 108 assertFalse(rule.isApplicable(iteration1, selection2)); 109 assertFalse(rule.isApplicable(selection2, iteration1)); 110 assertFalse(rule.isApplicable(iteration2, selection2)); 111 assertFalse(rule.isApplicable(selection2, iteration2)); 199 ITask task1 = createNewEventTask(eventType1, eventTarget1); 200 ITask task2 = createNewEventTask(eventType2, eventTarget2); 201 202 IIteration iteration1 = createNewIteration(); 203 IIteration iteration2 = createNewIteration(); 204 205 setMarkedTask(iteration1, task1); 206 setMarkedTask(iteration1, task2); 207 208 assertUnequal(rule, iteration1, iteration2); 209 } 210 211 /** 212 * 213 */ 214 @Test 215 public void test_compare_06() { 216 IterationComparisonRule rule = new IterationComparisonRule(); 217 218 IEventType eventType1 = new StringEventType("eventType1"); 219 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 220 221 ITask task1 = createNewEventTask(eventType1, eventTarget1); 222 223 IIteration iteration1 = createNewIteration(); 224 IIteration iteration2 = createNewIteration(); 225 226 ISelection selection1 = createNewSelection(); 227 addChild(selection1, task1); 228 setMarkedTask(iteration1, selection1); 229 230 setMarkedTask(iteration2, task1); 231 232 assertLexicallyEqual(rule, iteration1, iteration2); 233 } 234 235 /** 236 * 237 */ 238 @Test 239 public void test_compare_07() { 240 IterationComparisonRule rule = new IterationComparisonRule(); 241 242 IEventType eventType1 = new StringEventType("eventType1"); 243 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 244 245 ITask task1 = createNewEventTask(eventType1, eventTarget1); 246 247 IIteration iteration1 = createNewIteration(); 248 IIteration iteration2 = createNewIteration(); 249 250 ISelection selection1 = createNewSelection(); 251 addChild(selection1, task1); 252 setMarkedTask(iteration1, selection1); 253 254 ISelection selection2 = createNewSelection(); 255 addChild(selection2, task1); 256 setMarkedTask(iteration2, selection2); 257 258 assertLexicallyEqual(rule, iteration1, iteration2); 259 } 260 261 /** 262 * 263 */ 264 @Test 265 public void test_compare_08() { 266 IterationComparisonRule rule = new IterationComparisonRule(); 267 268 IEventType eventType1 = new StringEventType("eventType1"); 269 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 270 271 IEventType eventType2 = new StringEventType("eventType2"); 272 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 273 274 ITask task1 = createNewEventTask(eventType1, eventTarget1); 275 ITask task2 = createNewEventTask(eventType2, eventTarget2); 276 277 IIteration iteration1 = createNewIteration(); 278 IIteration iteration2 = createNewIteration(); 279 280 ISelection selection1 = createNewSelection(); 281 addChild(selection1, task1); 282 addChild(selection1, task2); 283 setMarkedTask(iteration1, selection1); 284 285 ISelection selection2 = createNewSelection(); 286 addChild(selection2, task2); 287 setMarkedTask(iteration2, selection2); 288 289 assertLexicallyEqual(rule, iteration1, iteration2); 112 290 } 113 291 -
trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/taskequality/SelectionComparisonRuleTest.java
r1190 r1294 22 22 import de.ugoe.cs.autoquest.eventcore.IEventType; 23 23 import de.ugoe.cs.autoquest.eventcore.StringEventType; 24 import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality;25 24 import de.ugoe.cs.autoquest.tasktrees.taskequality.SelectionComparisonRule; 26 25 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 27 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence;28 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder;29 26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 30 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory;31 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskBuilder;32 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskFactory;33 27 import de.ugoe.cs.autoquest.test.DummyGUIElement; 34 28 … … 36 30 * @author Patrick Harms 37 31 */ 38 public class SelectionComparisonRuleTest { 39 40 /** 41 * 42 */ 43 @Test 44 public void test() { 45 ITaskFactory taskFactory = new TaskFactory(); 46 ITaskBuilder treeBuilder = new TaskBuilder(); 47 32 public class SelectionComparisonRuleTest extends AbstractComparisonRuleTest { 33 34 /** 35 * 36 */ 37 @Test 38 public void test_isApplicable_01() { 39 SelectionComparisonRule rule = new SelectionComparisonRule(); 40 41 ITask task1 = createNewSelection(); 42 43 assertTrue(rule.isApplicable(task1, task1)); 44 } 45 46 /** 47 * 48 */ 49 @Test 50 public void test_isApplicable_02() { 51 SelectionComparisonRule rule = new SelectionComparisonRule(); 52 53 ITask task1 = createNewSelection(); 54 ITask task2 = createNewSelection(); 55 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 109 IEventType eventType1 = new StringEventType("eventType1"); 110 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 111 112 ITask task1 = createNewSelection(); 113 ITask task2 = createNewEventTask(eventType1, eventTarget1); 114 115 assertFalse(rule.isApplicable(task1, task2)); 116 assertFalse(rule.isApplicable(task2, task1)); 117 } 118 119 /** 120 * 121 */ 122 @Test 123 public void test_compare_01() { 124 SelectionComparisonRule rule = new SelectionComparisonRule(); 125 126 ISelection selection1 = createNewSelection(); 127 assertLexicallyEqual(rule, selection1, selection1); 128 } 129 130 /** 131 * 132 */ 133 @Test 134 public void test_compare_02() { 135 SelectionComparisonRule rule = new SelectionComparisonRule(); 136 137 ISelection selection1 = createNewSelection(); 138 ISelection selection2 = createNewSelection(); 139 140 assertLexicallyEqual(rule, selection1, selection2); 141 } 142 143 /** 144 * 145 */ 146 @Test 147 public void test_compare_03() { 148 SelectionComparisonRule rule = new SelectionComparisonRule(); 149 150 IEventType eventType1 = new StringEventType("eventType1"); 151 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 152 153 ITask task1 = createNewEventTask(eventType1, eventTarget1); 154 155 ISelection selection1 = createNewSelection(); 156 ISelection selection2 = createNewSelection(); 157 158 addChild(selection1, task1); 159 160 assertUnequal(rule, selection1, selection2); 161 } 162 163 /** 164 * 165 */ 166 @Test 167 public void test_compare_04() { 168 SelectionComparisonRule rule = new SelectionComparisonRule(); 169 170 IEventType eventType1 = new StringEventType("eventType1"); 171 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 172 173 ITask task1 = createNewEventTask(eventType1, eventTarget1); 174 175 ISelection selection1 = createNewSelection(); 176 ISelection selection2 = createNewSelection(); 177 178 addChild(selection1, task1); 179 addChild(selection2, task1); 180 181 assertLexicallyEqual(rule, selection1, selection2); 182 } 183 184 /** 185 * 186 */ 187 @Test 188 public void test_compare_05() { 48 189 SelectionComparisonRule rule = new SelectionComparisonRule(); 49 190 … … 54 195 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 55 196 56 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 57 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2); 58 59 assertFalse(rule.isApplicable(task1, task2)); 60 61 ISelection selection1 = taskFactory.createNewSelection(); 62 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(selection1, selection1)); 63 64 ISelection selection2 = taskFactory.createNewSelection(); 65 66 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(selection1, selection2)); 67 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(selection2, selection1)); 68 69 treeBuilder.addChild(selection1, task1); 70 71 assertEquals(TaskEquality.UNEQUAL, rule.compare(selection1, selection2)); 72 assertEquals(TaskEquality.UNEQUAL, rule.compare(selection2, selection1)); 73 74 treeBuilder.addChild(selection2, task1); 75 76 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(selection1, selection2)); 77 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(selection2, selection1)); 78 79 treeBuilder.addChild(selection1, task2); 80 81 assertEquals(TaskEquality.UNEQUAL, rule.compare(selection1, selection2)); 82 assertEquals(TaskEquality.UNEQUAL, rule.compare(selection2, selection1)); 83 84 treeBuilder.addChild(selection2, task2); 85 86 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(selection1, selection2)); 87 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(selection2, selection1)); 88 89 ISelection selection3 = taskFactory.createNewSelection(); 90 treeBuilder.addChild(selection3, task2); 91 treeBuilder.addChild(selection3, task1); 92 93 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(selection1, selection3)); 94 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(selection3, selection1)); 95 96 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(selection2, selection3)); 97 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(selection3, selection2)); 98 99 ISequence sequence = taskFactory.createNewSequence(); 100 assertFalse(rule.isApplicable(selection1, sequence)); 101 assertFalse(rule.isApplicable(sequence, selection1)); 102 assertFalse(rule.isApplicable(selection2, sequence)); 103 assertFalse(rule.isApplicable(sequence, selection2)); 104 assertFalse(rule.isApplicable(selection3, sequence)); 105 assertFalse(rule.isApplicable(sequence, selection3)); 197 ITask task1 = createNewEventTask(eventType1, eventTarget1); 198 ITask task2 = createNewEventTask(eventType2, eventTarget2); 199 200 ISelection selection1 = createNewSelection(); 201 ISelection selection2 = createNewSelection(); 202 203 addChild(selection1, task1); 204 addChild(selection2, task2); 205 206 assertUnequal(rule, selection1, selection2); 207 } 208 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); 106 237 } 107 238 -
trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/taskequality/SequenceComparisonRuleTest.java
r1190 r1294 22 22 import de.ugoe.cs.autoquest.eventcore.IEventType; 23 23 import de.ugoe.cs.autoquest.eventcore.StringEventType; 24 import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality;25 24 import de.ugoe.cs.autoquest.tasktrees.taskequality.SequenceComparisonRule; 26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection;27 25 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 28 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder;29 26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 30 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory;31 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskBuilder;32 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskFactory;33 27 import de.ugoe.cs.autoquest.test.DummyGUIElement; 34 28 … … 36 30 * @author Patrick Harms 37 31 */ 38 public class SequenceComparisonRuleTest { 39 40 /** 41 * 42 */ 43 @Test 44 public void test() { 45 ITaskFactory taskFactory = new TaskFactory(); 46 ITaskBuilder treeBuilder = new TaskBuilder(); 47 32 public class SequenceComparisonRuleTest extends AbstractComparisonRuleTest { 33 34 /** 35 * 36 */ 37 @Test 38 public void test_isApplicable_01() { 39 SequenceComparisonRule rule = new SequenceComparisonRule(); 40 41 ITask task1 = createNewSequence(); 42 43 assertTrue(rule.isApplicable(task1, task1)); 44 } 45 46 /** 47 * 48 */ 49 @Test 50 public void test_isApplicable_02() { 51 SequenceComparisonRule rule = new SequenceComparisonRule(); 52 53 ITask task1 = createNewSequence(); 54 ITask task2 = createNewSequence(); 55 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 SequenceComparisonRule rule = new SequenceComparisonRule(); 66 67 ITask task1 = createNewSequence(); 68 ITask task2 = createNewSelection(); 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 SequenceComparisonRule rule = new SequenceComparisonRule(); 80 81 ITask task1 = createNewSequence(); 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 SequenceComparisonRule rule = new SequenceComparisonRule(); 94 95 ITask task1 = createNewSequence(); 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 SequenceComparisonRule rule = new SequenceComparisonRule(); 108 109 IEventType eventType1 = new StringEventType("eventType1"); 110 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 111 112 ITask task1 = createNewSequence(); 113 ITask task2 = createNewEventTask(eventType1, eventTarget1); 114 115 assertFalse(rule.isApplicable(task1, task2)); 116 assertFalse(rule.isApplicable(task2, task1)); 117 } 118 119 /** 120 * 121 */ 122 @Test 123 public void test_compare_01() { 124 SequenceComparisonRule rule = new SequenceComparisonRule(); 125 126 ISequence sequence1 = createNewSequence(); 127 assertLexicallyEqual(rule, sequence1, sequence1); 128 } 129 130 /** 131 * 132 */ 133 @Test 134 public void test_compare_02() { 135 SequenceComparisonRule rule = new SequenceComparisonRule(); 136 137 ISequence sequence1 = createNewSequence(); 138 ISequence sequence2 = createNewSequence(); 139 140 assertLexicallyEqual(rule, sequence1, sequence2); 141 } 142 143 /** 144 * 145 */ 146 @Test 147 public void test_compare_03() { 148 SequenceComparisonRule rule = new SequenceComparisonRule(); 149 150 IEventType eventType1 = new StringEventType("eventType1"); 151 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 152 153 ITask task1 = createNewEventTask(eventType1, eventTarget1); 154 155 ISequence sequence1 = createNewSequence(); 156 ISequence sequence2 = createNewSequence(); 157 158 addChild(sequence1, task1); 159 160 assertUnequal(rule, sequence1, sequence2); 161 } 162 163 /** 164 * 165 */ 166 @Test 167 public void test_compare_04() { 168 SequenceComparisonRule rule = new SequenceComparisonRule(); 169 170 IEventType eventType1 = new StringEventType("eventType1"); 171 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 172 173 ITask task1 = createNewEventTask(eventType1, eventTarget1); 174 175 ISequence sequence1 = createNewSequence(); 176 ISequence sequence2 = createNewSequence(); 177 178 addChild(sequence1, task1); 179 addChild(sequence2, task1); 180 181 assertLexicallyEqual(rule, sequence1, sequence2); 182 } 183 184 /** 185 * 186 */ 187 @Test 188 public void test_compare_05() { 48 189 SequenceComparisonRule rule = new SequenceComparisonRule(); 49 190 … … 54 195 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 55 196 56 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 57 ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2); 58 59 assertFalse(rule.isApplicable(task1, task2)); 60 61 ISequence sequence1 = taskFactory.createNewSequence(); 62 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(sequence1, sequence1)); 63 64 ISequence sequence2 = taskFactory.createNewSequence(); 65 66 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(sequence1, sequence2)); 67 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(sequence2, sequence1)); 68 69 treeBuilder.addChild(sequence1, task1); 70 71 assertEquals(TaskEquality.UNEQUAL, rule.compare(sequence1, sequence2)); 72 assertEquals(TaskEquality.UNEQUAL, rule.compare(sequence2, sequence1)); 73 74 treeBuilder.addChild(sequence2, task1); 75 76 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(sequence1, sequence2)); 77 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(sequence2, sequence1)); 78 79 treeBuilder.addChild(sequence1, task2); 80 81 assertEquals(TaskEquality.UNEQUAL, rule.compare(sequence1, sequence2)); 82 assertEquals(TaskEquality.UNEQUAL, rule.compare(sequence2, sequence1)); 83 84 treeBuilder.addChild(sequence2, task2); 85 86 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(sequence1, sequence2)); 87 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(sequence2, sequence1)); 88 89 ISequence sequence3 = taskFactory.createNewSequence(); 90 treeBuilder.addChild(sequence3, task2); 91 treeBuilder.addChild(sequence3, task1); 92 93 assertEquals(TaskEquality.UNEQUAL, rule.compare(sequence1, sequence3)); 94 assertEquals(TaskEquality.UNEQUAL, rule.compare(sequence3, sequence1)); 95 assertEquals(TaskEquality.UNEQUAL, rule.compare(sequence2, sequence3)); 96 assertEquals(TaskEquality.UNEQUAL, rule.compare(sequence3, sequence2)); 97 98 ISelection selection = taskFactory.createNewSelection(); 99 assertFalse(rule.isApplicable(sequence1, selection)); 100 assertFalse(rule.isApplicable(selection, sequence1)); 101 assertFalse(rule.isApplicable(sequence2, selection)); 102 assertFalse(rule.isApplicable(selection, sequence2)); 103 assertFalse(rule.isApplicable(sequence3, selection)); 104 assertFalse(rule.isApplicable(selection, sequence3)); 197 ITask task1 = createNewEventTask(eventType1, eventTarget1); 198 ITask task2 = createNewEventTask(eventType2, eventTarget2); 199 200 ISequence sequence1 = createNewSequence(); 201 ISequence sequence2 = createNewSequence(); 202 203 addChild(sequence1, task1); 204 addChild(sequence2, task1); 205 206 addChild(sequence1, task2); 207 208 assertUnequal(rule, sequence1, sequence2); 209 } 210 211 /** 212 * 213 */ 214 @Test 215 public void test_compare_06() { 216 SequenceComparisonRule rule = new SequenceComparisonRule(); 217 218 IEventType eventType1 = new StringEventType("eventType1"); 219 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 220 221 IEventType eventType2 = new StringEventType("eventType2"); 222 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 223 224 ITask task1 = createNewEventTask(eventType1, eventTarget1); 225 ITask task2 = createNewEventTask(eventType2, eventTarget2); 226 227 ISequence sequence1 = createNewSequence(); 228 ISequence sequence2 = createNewSequence(); 229 230 addChild(sequence1, task1); 231 addChild(sequence2, task1); 232 233 addChild(sequence1, task2); 234 addChild(sequence2, task2); 235 236 assertLexicallyEqual(rule, sequence1, sequence2); 237 } 238 239 /** 240 * 241 */ 242 @Test 243 public void test_compare_07() { 244 SequenceComparisonRule rule = new SequenceComparisonRule(); 245 246 IEventType eventType1 = new StringEventType("eventType1"); 247 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 248 249 IEventType eventType2 = new StringEventType("eventType2"); 250 IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 251 252 ITask task1 = createNewEventTask(eventType1, eventTarget1); 253 ITask task2 = createNewEventTask(eventType2, eventTarget2); 254 255 ISequence sequence1 = createNewSequence(); 256 ISequence sequence2 = createNewSequence(); 257 258 addChild(sequence1, task1); 259 addChild(sequence1, task2); 260 261 addChild(sequence2, task2); 262 addChild(sequence2, task1); 263 264 assertUnequal(rule, sequence1, sequence2); 105 265 } 106 266 -
trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/taskequality/TaskAndIterationComparisonRuleTest.java
r1190 r1294 23 23 import de.ugoe.cs.autoquest.eventcore.StringEventType; 24 24 import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskAndIterationComparisonRule; 25 import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality;26 25 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 27 26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 28 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder;29 27 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 30 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory;31 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskBuilder;32 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskFactory;33 28 import de.ugoe.cs.autoquest.test.DummyGUIElement; 34 29 … … 36 31 * @author Patrick Harms 37 32 */ 38 public class TaskAndIterationComparisonRuleTest { 39 40 /** 41 * 42 */ 43 @Test 44 public void test() { 45 ITaskFactory taskFactory = new TaskFactory(); 46 ITaskBuilder treeBuilder = new TaskBuilder(); 47 48 TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); 49 50 IEventType eventType1 = new StringEventType("eventType1"); 51 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 52 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 53 54 assertNull(rule.compare(task1, task1)); 55 56 IIteration iteration1 = taskFactory.createNewIteration(); 57 assertNull(rule.compare(iteration1, iteration1)); 58 assertNull(rule.compare(task1, iteration1)); 59 assertNull(rule.compare(iteration1, task1)); 60 61 treeBuilder.setMarkedTask(iteration1, task1); 62 63 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(iteration1, task1)); 64 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(task1, iteration1)); 65 66 ISelection selection1 = taskFactory.createNewSelection(); 67 treeBuilder.addChild(selection1, task1); 68 treeBuilder.setMarkedTask(iteration1, selection1); 69 70 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(iteration1, task1)); 71 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(task1, iteration1)); 33 public class TaskAndIterationComparisonRuleTest extends AbstractComparisonRuleTest { 34 35 /** 36 * 37 */ 38 @Test 39 public void test_isApplicable_01() { 40 TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); 41 42 ITask task1 = createNewSequence(); 43 44 assertFalse(rule.isApplicable(task1, task1)); 45 } 46 47 /** 48 * 49 */ 50 @Test 51 public void test_isApplicable_02() { 52 TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); 53 54 ITask task1 = createNewSelection(); 55 56 assertFalse(rule.isApplicable(task1, task1)); 57 } 58 59 /** 60 * 61 */ 62 @Test 63 public void test_isApplicable_03() { 64 TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); 65 66 ITask task1 = createNewIteration(); 67 68 assertFalse(rule.isApplicable(task1, task1)); 69 } 70 71 /** 72 * 73 */ 74 @Test 75 public void test_isApplicable_04() { 76 TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); 77 78 ITask task1 = createNewOptional(); 79 80 assertFalse(rule.isApplicable(task1, task1)); 81 } 82 83 /** 84 * 85 */ 86 @Test 87 public void test_isApplicable_05() { 88 TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); 89 90 IEventType eventType1 = new StringEventType("eventType1"); 91 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 92 93 ITask task1 = createNewEventTask(eventType1, eventTarget1); 94 95 assertFalse(rule.isApplicable(task1, task1)); 96 } 97 98 /** 99 * 100 */ 101 @Test 102 public void test_isApplicable_06() { 103 TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); 104 105 ITask task1 = createNewIteration(); 106 ITask task2 = createNewSequence(); 107 108 assertTrue(rule.isApplicable(task1, task2)); 109 assertTrue(rule.isApplicable(task2, task1)); 110 } 111 112 /** 113 * 114 */ 115 @Test 116 public void test_isApplicable_07() { 117 TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); 118 119 ITask task1 = createNewIteration(); 120 ITask task2 = createNewSelection(); 121 122 assertTrue(rule.isApplicable(task1, task2)); 123 assertTrue(rule.isApplicable(task2, task1)); 124 } 125 126 /** 127 * 128 */ 129 @Test 130 public void test_isApplicable_08() { 131 TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); 132 133 ITask task1 = createNewIteration(); 134 ITask task2 = createNewOptional(); 135 136 assertTrue(rule.isApplicable(task1, task2)); 137 assertTrue(rule.isApplicable(task2, task1)); 138 } 139 140 /** 141 * 142 */ 143 @Test 144 public void test_isApplicable_09() { 145 TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); 146 147 ITask task1 = createNewIteration(); 148 149 IEventType eventType1 = new StringEventType("eventType1"); 150 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 151 152 ITask task2 = createNewEventTask(eventType1, eventTarget1); 153 154 assertTrue(rule.isApplicable(task1, task2)); 155 assertTrue(rule.isApplicable(task2, task1)); 156 } 157 158 /** 159 * 160 */ 161 @Test 162 public void test_isApplicable_10() { 163 TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); 164 165 ITask task1 = createNewSequence(); 166 ITask task2 = createNewSelection(); 167 168 assertFalse(rule.isApplicable(task1, task2)); 169 assertFalse(rule.isApplicable(task2, task1)); 170 } 171 172 /** 173 * 174 */ 175 @Test 176 public void test_isApplicable_11() { 177 TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); 178 179 ITask task1 = createNewSequence(); 180 ITask task2 = createNewOptional(); 181 182 assertFalse(rule.isApplicable(task1, task2)); 183 assertFalse(rule.isApplicable(task2, task1)); 184 } 185 186 /** 187 * 188 */ 189 @Test 190 public void test_isApplicable_12() { 191 TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); 192 193 ITask task1 = createNewSequence(); 194 195 IEventType eventType1 = new StringEventType("eventType1"); 196 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 197 198 ITask task2 = createNewEventTask(eventType1, eventTarget1); 199 200 assertFalse(rule.isApplicable(task1, task2)); 201 assertFalse(rule.isApplicable(task2, task1)); 202 } 203 204 /** 205 * 206 */ 207 @Test 208 public void test_isApplicable_13() { 209 TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); 210 211 ITask task1 = createNewSelection(); 212 ITask task2 = createNewOptional(); 213 214 assertFalse(rule.isApplicable(task1, task2)); 215 assertFalse(rule.isApplicable(task2, task1)); 216 } 217 218 /** 219 * 220 */ 221 @Test 222 public void test_isApplicable_14() { 223 TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); 224 225 ITask task1 = createNewSelection(); 226 227 IEventType eventType1 = new StringEventType("eventType1"); 228 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 229 230 ITask task2 = createNewEventTask(eventType1, eventTarget1); 231 232 assertFalse(rule.isApplicable(task1, task2)); 233 assertFalse(rule.isApplicable(task2, task1)); 234 } 235 236 /** 237 * 238 */ 239 @Test 240 public void test_compare_01() { 241 TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); 242 243 IEventType eventType1 = new StringEventType("eventType1"); 244 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 245 ITask task1 = createNewEventTask(eventType1, eventTarget1); 246 247 IIteration iteration1 = createNewIteration(); 248 249 assertNullEquality(rule, iteration1, task1); 250 } 251 252 /** 253 * 254 */ 255 @Test 256 public void test_compare_02() { 257 TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); 258 259 IEventType eventType1 = new StringEventType("eventType1"); 260 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 261 ITask task1 = createNewEventTask(eventType1, eventTarget1); 262 263 IIteration iteration1 = createNewIteration(); 264 setMarkedTask(iteration1, task1); 265 266 assertLexicallyEqual(rule, task1, iteration1); 267 } 268 269 /** 270 * 271 */ 272 @Test 273 public void test_compare_03() { 274 TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); 275 276 IEventType eventType1 = new StringEventType("eventType1"); 277 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 278 ITask task1 = createNewEventTask(eventType1, eventTarget1); 279 280 IIteration iteration1 = createNewIteration(); 281 282 ISelection selection1 = createNewSelection(); 283 addChild(selection1, task1); 284 setMarkedTask(iteration1, selection1); 285 286 assertLexicallyEqual(rule, task1, iteration1); 72 287 } 73 288 -
trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/taskequality/TaskAndSelectionComparisonRuleTest.java
r1190 r1294 23 23 import de.ugoe.cs.autoquest.eventcore.StringEventType; 24 24 import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskAndSelectionComparisonRule; 25 import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality;26 25 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 27 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder;28 26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 29 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory;30 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskBuilder;31 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskFactory;32 27 import de.ugoe.cs.autoquest.test.DummyGUIElement; 33 28 … … 35 30 * @author Patrick Harms 36 31 */ 37 public class TaskAndSelectionComparisonRuleTest { 38 39 /** 40 * 41 */ 42 @Test 43 public void test() { 44 ITaskFactory taskFactory = new TaskFactory(); 45 ITaskBuilder treeBuilder = new TaskBuilder(); 46 47 TaskAndSelectionComparisonRule rule = new TaskAndSelectionComparisonRule(); 48 49 IEventType eventType1 = new StringEventType("eventType1"); 50 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 51 ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); 52 53 assertNull(rule.compare(task1, task1)); 54 55 ISelection selection1 = taskFactory.createNewSelection(); 56 assertNull(rule.compare(selection1, selection1)); 57 assertNull(rule.compare(task1, selection1)); 58 assertNull(rule.compare(selection1, task1)); 59 60 treeBuilder.addChild(selection1, task1); 61 62 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(selection1, task1)); 63 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(task1, selection1)); 64 65 selection1 = taskFactory.createNewSelection(); 66 ISelection selection2 = taskFactory.createNewSelection(); 67 treeBuilder.addChild(selection2, task1); 68 treeBuilder.addChild(selection1, selection2); 69 70 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(selection1, task1)); 71 assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(task1, selection1)); 32 public class TaskAndSelectionComparisonRuleTest extends AbstractComparisonRuleTest { 33 34 /** 35 * 36 */ 37 @Test 38 public void test_isApplicable_01() { 39 TaskAndSelectionComparisonRule rule = new TaskAndSelectionComparisonRule(); 40 41 ITask task1 = createNewSequence(); 42 43 assertFalse(rule.isApplicable(task1, task1)); 44 } 45 46 /** 47 * 48 */ 49 @Test 50 public void test_isApplicable_02() { 51 TaskAndSelectionComparisonRule rule = new TaskAndSelectionComparisonRule(); 52 53 ITask task1 = createNewSelection(); 54 55 assertFalse(rule.isApplicable(task1, task1)); 56 } 57 58 /** 59 * 60 */ 61 @Test 62 public void test_isApplicable_03() { 63 TaskAndSelectionComparisonRule rule = new TaskAndSelectionComparisonRule(); 64 65 ITask task1 = createNewIteration(); 66 67 assertFalse(rule.isApplicable(task1, task1)); 68 } 69 70 /** 71 * 72 */ 73 @Test 74 public void test_isApplicable_04() { 75 TaskAndSelectionComparisonRule rule = new TaskAndSelectionComparisonRule(); 76 77 ITask task1 = createNewOptional(); 78 79 assertFalse(rule.isApplicable(task1, task1)); 80 } 81 82 /** 83 * 84 */ 85 @Test 86 public void test_isApplicable_05() { 87 TaskAndSelectionComparisonRule rule = new TaskAndSelectionComparisonRule(); 88 89 IEventType eventType1 = new StringEventType("eventType1"); 90 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 91 92 ITask task1 = createNewEventTask(eventType1, eventTarget1); 93 94 assertFalse(rule.isApplicable(task1, task1)); 95 } 96 97 /** 98 * 99 */ 100 @Test 101 public void test_isApplicable_06() { 102 TaskAndSelectionComparisonRule rule = new TaskAndSelectionComparisonRule(); 103 104 ITask task1 = createNewSelection(); 105 ITask task2 = createNewSequence(); 106 107 assertTrue(rule.isApplicable(task1, task2)); 108 assertTrue(rule.isApplicable(task2, task1)); 109 } 110 111 /** 112 * 113 */ 114 @Test 115 public void test_isApplicable_07() { 116 TaskAndSelectionComparisonRule rule = new TaskAndSelectionComparisonRule(); 117 118 ITask task1 = createNewSelection(); 119 ITask task2 = createNewIteration(); 120 121 assertTrue(rule.isApplicable(task1, task2)); 122 assertTrue(rule.isApplicable(task2, task1)); 123 } 124 125 /** 126 * 127 */ 128 @Test 129 public void test_isApplicable_08() { 130 TaskAndSelectionComparisonRule rule = new TaskAndSelectionComparisonRule(); 131 132 ITask task1 = createNewSelection(); 133 ITask task2 = createNewOptional(); 134 135 assertTrue(rule.isApplicable(task1, task2)); 136 assertTrue(rule.isApplicable(task2, task1)); 137 } 138 139 /** 140 * 141 */ 142 @Test 143 public void test_isApplicable_09() { 144 TaskAndSelectionComparisonRule rule = new TaskAndSelectionComparisonRule(); 145 146 ITask task1 = createNewSelection(); 147 148 IEventType eventType1 = new StringEventType("eventType1"); 149 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 150 151 ITask task2 = createNewEventTask(eventType1, eventTarget1); 152 153 assertTrue(rule.isApplicable(task1, task2)); 154 assertTrue(rule.isApplicable(task2, task1)); 155 } 156 157 /** 158 * 159 */ 160 @Test 161 public void test_isApplicable_10() { 162 TaskAndSelectionComparisonRule rule = new TaskAndSelectionComparisonRule(); 163 164 ITask task1 = createNewSequence(); 165 ITask task2 = createNewIteration(); 166 167 assertFalse(rule.isApplicable(task1, task2)); 168 assertFalse(rule.isApplicable(task2, task1)); 169 } 170 171 /** 172 * 173 */ 174 @Test 175 public void test_isApplicable_11() { 176 TaskAndSelectionComparisonRule rule = new TaskAndSelectionComparisonRule(); 177 178 ITask task1 = createNewSequence(); 179 ITask task2 = createNewOptional(); 180 181 assertFalse(rule.isApplicable(task1, task2)); 182 assertFalse(rule.isApplicable(task2, task1)); 183 } 184 185 /** 186 * 187 */ 188 @Test 189 public void test_isApplicable_12() { 190 TaskAndSelectionComparisonRule rule = new TaskAndSelectionComparisonRule(); 191 192 ITask task1 = createNewSequence(); 193 194 IEventType eventType1 = new StringEventType("eventType1"); 195 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 196 197 ITask task2 = createNewEventTask(eventType1, eventTarget1); 198 199 assertFalse(rule.isApplicable(task1, task2)); 200 assertFalse(rule.isApplicable(task2, task1)); 201 } 202 203 /** 204 * 205 */ 206 @Test 207 public void test_isApplicable_13() { 208 TaskAndSelectionComparisonRule rule = new TaskAndSelectionComparisonRule(); 209 210 ITask task1 = createNewIteration(); 211 ITask task2 = createNewOptional(); 212 213 assertFalse(rule.isApplicable(task1, task2)); 214 assertFalse(rule.isApplicable(task2, task1)); 215 } 216 217 /** 218 * 219 */ 220 @Test 221 public void test_isApplicable_14() { 222 TaskAndSelectionComparisonRule rule = new TaskAndSelectionComparisonRule(); 223 224 ITask task1 = createNewIteration(); 225 226 IEventType eventType1 = new StringEventType("eventType1"); 227 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 228 229 ITask task2 = createNewEventTask(eventType1, eventTarget1); 230 231 assertFalse(rule.isApplicable(task1, task2)); 232 assertFalse(rule.isApplicable(task2, task1)); 233 } 234 235 /** 236 * 237 */ 238 @Test 239 public void test_compare_01() { 240 TaskAndSelectionComparisonRule rule = new TaskAndSelectionComparisonRule(); 241 242 IEventType eventType1 = new StringEventType("eventType1"); 243 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 244 ITask task1 = createNewEventTask(eventType1, eventTarget1); 245 246 ISelection selection1 = createNewSelection(); 247 248 assertNullEquality(rule, task1, selection1); 249 } 250 251 /** 252 * 253 */ 254 @Test 255 public void test_compare_02() { 256 TaskAndSelectionComparisonRule rule = new TaskAndSelectionComparisonRule(); 257 258 IEventType eventType1 = new StringEventType("eventType1"); 259 IEventTarget eventTarget1 = new DummyGUIElement("elem1"); 260 ITask task1 = createNewEventTask(eventType1, eventTarget1); 261 262 ISelection selection1 = createNewSelection(); 263 addChild(selection1, task1); 264 265 assertLexicallyEqual(rule, task1, selection1); 72 266 } 73 267 -
trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/AbstractTemporalRelationshipTC.java
r1281 r1294 33 33 import de.ugoe.cs.autoquest.tasktrees.TaskTreeValidator; 34 34 import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality; 35 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 35 36 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList; 36 37 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; … … 74 75 * 75 76 */ 76 protected void applyRule(Class<? extends ITaskInstance ListScopeRule> ruleClass,77 String 78 String 77 protected void applyRule(Class<? extends ITaskInstanceScopeRule> ruleClass, 78 String inputSpec, 79 String expectedOutputSpec) 79 80 { 80 ITaskInstance ListScopeRule rule = null;81 ITaskInstanceScopeRule rule = null; 81 82 82 83 CONSTRUCTOR_ITERATION: … … 100 101 101 102 try { 102 rule = (ITaskInstance ListScopeRule) constructor.newInstance(parameters.toArray());103 rule = (ITaskInstanceScopeRule) constructor.newInstance(parameters.toArray()); 103 104 } 104 105 catch (IllegalArgumentException e) { … … 127 128 RuleApplicationStatus status; 128 129 129 ITaskInstance List inputList =decoder.decode(inputSpec);130 131 Stack<ITaskInstance List> toBeAppliedOn = new Stack<ITaskInstanceList>();130 ITaskInstance inputList = (ITaskInstance) decoder.decode(inputSpec); 131 132 Stack<ITaskInstance> toBeAppliedOn = new Stack<ITaskInstance>(); 132 133 toBeAppliedOn.push(inputList); 133 134 … … 156 157 while ((!toBeAppliedOn.isEmpty()) || (status == RuleApplicationStatus.FINISHED)); 157 158 158 ITaskInstance List expectedList =decoder.decode(expectedOutputSpec);159 160 new TaskTreeChecker().assertTaskInstance ListsEqual(expectedList, inputList);159 ITaskInstance expectedList = (ITaskInstance) decoder.decode(expectedOutputSpec); 160 161 new TaskTreeChecker().assertTaskInstancesEqual(expectedList, inputList); 161 162 } 162 163 -
trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TaskInstanceTrieTest.java
r1285 r1294 1510 1510 int order = 3; 1511 1511 1512 TaskInstanceTrieTester tester = new TaskInstanceTrieTester(1000, 100000 0, order);1513 1514 long start = System.currentTimeMillis(); 1515 fixture.trainSessions(Arrays.asList(tester.userSession), order); 1516 System.out.println("testing session with 100000 0task instances and 1000 symbols took " +1512 TaskInstanceTrieTester tester = new TaskInstanceTrieTester(1000, 100000, order); 1513 1514 long start = System.currentTimeMillis(); 1515 fixture.trainSessions(Arrays.asList(tester.userSession), order); 1516 System.out.println("testing session with 100000 task instances and 1000 symbols took " + 1517 1517 (System.currentTimeMillis() - start) + "ms"); 1518 1518 -
trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TaskSymbolBucketedMapTest.java
r1285 r1294 28 28 import org.junit.Test; 29 29 30 import de.ugoe.cs.autoquest.eventcore.Event; 30 31 import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality; 32 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 33 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTaskInstance; 31 34 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 32 35 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory; … … 60 63 @Test 61 64 public void testSymbolMap_1() { 62 SymbolMap<ITaskInstance, String> symbolMap = 63 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));65 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 66 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 64 67 65 68 assertNotNull(symbolMap); … … 69 72 @Test 70 73 public void testSymbolMap_2() { 71 TaskSymbolBucketedMap<String> symbolMap1 = 72 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));74 TaskSymbolBucketedMap<String> symbolMap1 = new TaskSymbolBucketedMap<String> 75 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 73 76 74 77 ITaskInstance taskInstance = createTaskInstance("symbol"); … … 89 92 @Test 90 93 public void testAddSymbol_1() { 91 SymbolMap<ITaskInstance, String> symbolMap = 92 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));94 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 95 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 93 96 94 97 ITaskInstance taskInstance = createTaskInstance("symbol"); … … 102 105 @Test 103 106 public void testAddSymbol_2() { 104 SymbolMap<ITaskInstance, String> symbolMap = 105 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));107 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 108 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 106 109 107 110 int entryCount = 2000; … … 122 125 @Test 123 126 public void testAddSymbol_3() { 124 SymbolMap<ITaskInstance, String> symbolMap = 125 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));127 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 128 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 126 129 127 130 int entryCount = 2000; … … 148 151 @Test(expected = java.lang.IllegalArgumentException.class) 149 152 public void testAddSymbol_4() { 150 SymbolMap<ITaskInstance, String> symbolMap = 151 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));153 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 154 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 152 155 153 156 symbolMap.addSymbol(null, null); … … 156 159 @Test 157 160 public void testSize_1() { 158 SymbolMap<ITaskInstance, String> symbolMap = 159 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));161 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 162 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 160 163 161 164 assertEquals(0, symbolMap.size()); … … 164 167 @Test 165 168 public void testSize_2() { 166 SymbolMap<ITaskInstance, String> symbolMap = 167 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));169 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 170 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 168 171 169 172 symbolMap.addSymbol(createTaskInstance("symbol1"), "value1"); … … 174 177 @Test 175 178 public void testSize_3() { 176 SymbolMap<ITaskInstance, String> symbolMap = 177 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));179 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 180 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 178 181 179 182 int entryCount = 2000; … … 188 191 @Test 189 192 public void testSize_4() { 190 SymbolMap<ITaskInstance, String> symbolMap = 191 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));193 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 194 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 192 195 193 196 int entryCount = 2000; … … 207 210 @Test 208 211 public void testSize_5() { 209 SymbolMap<ITaskInstance, String> symbolMap = 210 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));212 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 213 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 211 214 212 215 int entryCount = 2000; … … 225 228 @Test 226 229 public void testIsEmpty_1() { 227 SymbolMap<ITaskInstance, String> symbolMap = 228 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));230 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 231 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 229 232 230 233 assertTrue(symbolMap.isEmpty()); … … 233 236 @Test 234 237 public void testIsEmpty_2() { 235 SymbolMap<ITaskInstance, String> symbolMap = 236 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));238 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 239 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 237 240 238 241 symbolMap.addSymbol(createTaskInstance("symbol1"), "value1"); … … 243 246 @Test 244 247 public void testIsEmpty_3() { 245 SymbolMap<ITaskInstance, String> symbolMap = 246 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));248 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 249 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 247 250 248 251 int entryCount = 2000; … … 257 260 @Test 258 261 public void testIsEmpty_4() { 259 SymbolMap<ITaskInstance, String> symbolMap = 260 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));262 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 263 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 261 264 262 265 int entryCount = 2000; … … 276 279 @Test 277 280 public void testIsEmpty_5() { 278 SymbolMap<ITaskInstance, String> symbolMap = 279 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));281 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 282 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 280 283 281 284 int entryCount = 2000; … … 294 297 @Test 295 298 public void testContainsSymbol_1() { 296 SymbolMap<ITaskInstance, String> symbolMap = 297 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));299 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 300 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 298 301 299 302 assertFalse(symbolMap.containsSymbol(createTaskInstance("symbol"))); … … 302 305 @Test 303 306 public void testContainsSymbol_2() { 304 SymbolMap<ITaskInstance, String> symbolMap = 305 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));307 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 308 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 306 309 307 310 symbolMap.addSymbol(createTaskInstance("symbol1"), "value1"); … … 312 315 @Test 313 316 public void testContainsSymbol_3() { 314 SymbolMap<ITaskInstance, String> symbolMap = 315 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));317 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 318 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 316 319 317 320 int entryCount = 2000; … … 328 331 @Test 329 332 public void testContainsSymbol_4() { 330 SymbolMap<ITaskInstance, String> symbolMap = 331 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));333 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 334 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 332 335 333 336 int entryCount = 2000; … … 349 352 @Test 350 353 public void testContainsSymbol_5() { 351 SymbolMap<ITaskInstance, String> symbolMap = 352 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));354 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 355 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 353 356 354 357 int entryCount = 2000; … … 377 380 @Test(expected = java.lang.IllegalArgumentException.class) 378 381 public void testContainsSymbol_6() { 379 SymbolMap<ITaskInstance, String> symbolMap = 380 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));382 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 383 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 381 384 382 385 symbolMap.containsSymbol(null); … … 385 388 @Test 386 389 public void testGetValue_1() { 387 SymbolMap<ITaskInstance, String> symbolMap = 388 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));390 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 391 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 389 392 390 393 assertNull(symbolMap.getValue(createTaskInstance("symbol"))); … … 393 396 @Test 394 397 public void testGetValue_2() { 395 SymbolMap<ITaskInstance, String> symbolMap = 396 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));398 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 399 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 397 400 398 401 symbolMap.addSymbol(createTaskInstance("symbol1"), "value1"); … … 403 406 @Test 404 407 public void testGetValue_3() { 405 SymbolMap<ITaskInstance, String> symbolMap = 406 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));408 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 409 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 407 410 408 411 symbolMap.addSymbol(createTaskInstance("symbol1"), null); … … 413 416 @Test 414 417 public void testGetValue_4() { 415 SymbolMap<ITaskInstance, String> symbolMap = 416 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));418 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 419 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 417 420 418 421 int entryCount = 2000; … … 429 432 @Test 430 433 public void testGetValue_5() { 431 SymbolMap<ITaskInstance, String> symbolMap = 432 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));434 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 435 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 433 436 434 437 int entryCount = 2000; … … 455 458 @Test 456 459 public void testGetValue_6() { 457 SymbolMap<ITaskInstance, String> symbolMap = 458 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));460 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 461 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 459 462 460 463 int entryCount = 2000; … … 483 486 @Test(expected = java.lang.IllegalArgumentException.class) 484 487 public void testGetValue_7() { 485 SymbolMap<ITaskInstance, String> symbolMap = 486 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));488 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 489 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 487 490 488 491 symbolMap.getValue(null); … … 491 494 @Test 492 495 public void testRemoveSymbol_1() { 493 SymbolMap<ITaskInstance, String> symbolMap = 494 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));496 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 497 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 495 498 496 499 assertNull(symbolMap.removeSymbol(createTaskInstance("symbol"))); … … 499 502 @Test 500 503 public void testRemoveSymbol_2() { 501 SymbolMap<ITaskInstance, String> symbolMap = 502 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));504 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 505 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 503 506 504 507 symbolMap.addSymbol(createTaskInstance("symbol1"), "value1"); … … 510 513 @Test 511 514 public void testRemoveSymbol_3() { 512 SymbolMap<ITaskInstance, String> symbolMap = 513 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));515 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 516 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 514 517 515 518 symbolMap.addSymbol(createTaskInstance("symbol1"), null); … … 521 524 @Test 522 525 public void testRemoveSymbol_4() { 523 SymbolMap<ITaskInstance, String> symbolMap = 524 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));526 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 527 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 525 528 526 529 int entryCount = 2000; … … 539 542 @Test 540 543 public void testRemoveSymbol_5() { 541 SymbolMap<ITaskInstance, String> symbolMap = 542 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));544 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 545 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 543 546 544 547 int entryCount = 2000; … … 567 570 @Test 568 571 public void testRemoveSymbol_6() { 569 SymbolMap<ITaskInstance, String> symbolMap = 570 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));572 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 573 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 571 574 572 575 int entryCount = 2000; … … 597 600 @Test(expected = java.lang.IllegalArgumentException.class) 598 601 public void testRemoveSymbol_7() { 599 SymbolMap<ITaskInstance, String> symbolMap = 600 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));602 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 603 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 601 604 602 605 symbolMap.removeSymbol(null); … … 605 608 @Test 606 609 public void testGetSymbols_1() { 607 SymbolMap<ITaskInstance, String> symbolMap = 608 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));610 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 611 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 609 612 610 613 assertNotNull(symbolMap.getSymbols()); … … 614 617 @Test 615 618 public void testGetSymbols_2() { 616 SymbolMap<ITaskInstance, String> symbolMap = 617 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));619 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 620 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 618 621 619 622 ITaskInstance task = createTaskInstance("symbol1"); … … 627 630 @Test 628 631 public void testGetSymbols_3() { 629 SymbolMap<ITaskInstance, String> symbolMap = 630 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));632 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 633 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 631 634 632 635 ITaskInstance task = createTaskInstance("symbol1"); … … 640 643 @Test 641 644 public void testGetSymbols_4() { 642 SymbolMap<ITaskInstance, String> symbolMap = 643 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));645 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 646 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 644 647 Set<ITaskInstance> expectedSymbols = new HashSet<ITaskInstance>(); 645 648 … … 667 670 @Test 668 671 public void testGetSymbols_5() { 669 SymbolMap<ITaskInstance, String> symbolMap = 670 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));672 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 673 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 671 674 Set<ITaskInstance> expectedSymbols = new HashSet<ITaskInstance>(); 672 675 … … 701 704 @Test 702 705 public void testGetSymbols_6() { 703 SymbolMap<ITaskInstance, String> symbolMap = 704 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));706 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 707 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 705 708 List<ITaskInstance> expectedSymbols = new ArrayList<ITaskInstance>(); 706 709 … … 732 735 @Test 733 736 public void testGetValues_1() { 734 SymbolMap<ITaskInstance, String> symbolMap = 735 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));737 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 738 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 736 739 737 740 assertNotNull(symbolMap.getValues()); … … 741 744 @Test 742 745 public void testGetValues_2() { 743 SymbolMap<ITaskInstance, String> symbolMap = 744 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));746 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 747 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 745 748 746 749 symbolMap.addSymbol(createTaskInstance("symbol1"), "value1"); … … 753 756 @Test 754 757 public void testGetValues_3() { 755 SymbolMap<ITaskInstance, String> symbolMap = 756 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));758 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 759 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 757 760 758 761 symbolMap.addSymbol(createTaskInstance("symbol1"), null); … … 765 768 @Test 766 769 public void testGetValues_4() { 767 SymbolMap<ITaskInstance, String> symbolMap = 768 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));770 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 771 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 769 772 Set<String> expectedValues = new HashSet<String>(); 770 773 … … 791 794 @Test 792 795 public void testGetValues_5() { 793 SymbolMap<ITaskInstance, String> symbolMap = 794 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));796 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 797 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 795 798 Set<String> expectedValues = new HashSet<String>(); 796 799 … … 823 826 @Test 824 827 public void testGetValues_6() { 825 SymbolMap<ITaskInstance, String> symbolMap = 826 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));828 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 829 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 827 830 Set<String> expectedValues = new HashSet<String>(); 828 831 … … 854 857 @Test 855 858 public void testClear_1() { 856 SymbolMap<ITaskInstance, String> symbolMap = 857 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));859 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 860 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 858 861 859 862 symbolMap.clear(); … … 863 866 @Test 864 867 public void testClear_2() { 865 SymbolMap<ITaskInstance, String> symbolMap = 866 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));868 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 869 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 867 870 868 871 symbolMap.addSymbol(createTaskInstance("symbol1"), "value1"); … … 874 877 @Test 875 878 public void testClear_3() { 876 SymbolMap<ITaskInstance, String> symbolMap = 877 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));879 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 880 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 878 881 879 882 symbolMap.addSymbol(createTaskInstance("symbol1"), null); … … 885 888 @Test 886 889 public void testClear_4() { 887 SymbolMap<ITaskInstance, String> symbolMap = 888 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));890 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 891 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 889 892 890 893 int entryCount = 2000; … … 900 903 @Test 901 904 public void testClear_5() { 902 SymbolMap<ITaskInstance, String> symbolMap = 903 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));905 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 906 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 904 907 905 908 int entryCount = 2000; … … 920 923 @Test 921 924 public void testClear_6() { 922 SymbolMap<ITaskInstance, String> symbolMap = 923 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));925 SymbolMap<ITaskInstance, String> symbolMap = new TaskSymbolBucketedMap<String> 926 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 924 927 925 928 int entryCount = 2000; … … 939 942 @Test 940 943 public void testEquals_1() { 941 SymbolMap<ITaskInstance, String> symbolMap1 = 942 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));943 944 SymbolMap<ITaskInstance, String> symbolMap2 = 945 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));944 SymbolMap<ITaskInstance, String> symbolMap1 = new TaskSymbolBucketedMap<String> 945 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 946 947 SymbolMap<ITaskInstance, String> symbolMap2 = new TaskSymbolBucketedMap<String> 948 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 946 949 947 950 assertTrue(symbolMap1.equals(symbolMap2)); … … 950 953 @Test 951 954 public void testEquals_2() { 952 SymbolMap<ITaskInstance, String> symbolMap1 = 953 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));954 955 SymbolMap<ITaskInstance, String> symbolMap2 = 956 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));955 SymbolMap<ITaskInstance, String> symbolMap1 = new TaskSymbolBucketedMap<String> 956 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 957 958 SymbolMap<ITaskInstance, String> symbolMap2 = new TaskSymbolBucketedMap<String> 959 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 957 960 958 961 symbolMap1.addSymbol(createTaskInstance("symbol1"), "value1"); … … 963 966 @Test 964 967 public void testEquals_3() { 965 SymbolMap<ITaskInstance, String> symbolMap1 = 966 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));967 968 SymbolMap<ITaskInstance, String> symbolMap2 = 969 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));968 SymbolMap<ITaskInstance, String> symbolMap1 = new TaskSymbolBucketedMap<String> 969 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 970 971 SymbolMap<ITaskInstance, String> symbolMap2 = new TaskSymbolBucketedMap<String> 972 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 970 973 971 974 ITaskInstance task = createTaskInstance("symbol1"); … … 978 981 @Test 979 982 public void testEquals_4() { 980 SymbolMap<ITaskInstance, String> symbolMap1 = 981 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));983 SymbolMap<ITaskInstance, String> symbolMap1 = new TaskSymbolBucketedMap<String> 984 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 982 985 983 SymbolMap<ITaskInstance, String> symbolMap2 = 984 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));986 SymbolMap<ITaskInstance, String> symbolMap2 = new TaskSymbolBucketedMap<String> 987 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 985 988 986 989 int entryCount = 1000; … … 997 1000 @Test 998 1001 public void testEquals_5() { 999 SymbolMap<ITaskInstance, String> symbolMap1 = 1000 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));1002 SymbolMap<ITaskInstance, String> symbolMap1 = new TaskSymbolBucketedMap<String> 1003 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 1001 1004 1002 SymbolMap<ITaskInstance, String> symbolMap2 = 1003 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));1005 SymbolMap<ITaskInstance, String> symbolMap2 = new TaskSymbolBucketedMap<String> 1006 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 1004 1007 1005 1008 int entryCount = 1000; … … 1024 1027 @Test 1025 1028 public void testEquals_6() { 1026 SymbolMap<ITaskInstance, String> symbolMap1 = 1027 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));1029 SymbolMap<ITaskInstance, String> symbolMap1 = new TaskSymbolBucketedMap<String> 1030 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 1028 1031 1029 SymbolMap<ITaskInstance, String> symbolMap2 = 1030 new TaskSymbolBucketedMap<String>(new TaskComparator(TaskEquality.SEMANTICALLY_EQUAL));1032 SymbolMap<ITaskInstance, String> symbolMap2 = new TaskSymbolBucketedMap<String> 1033 (new TaskInstanceComparator(TaskEquality.SEMANTICALLY_EQUAL)); 1031 1034 1032 1035 int entryCount = 1000; … … 1052 1055 1053 1056 /** 1054 * <p>1055 * TODO: comment1056 * </p>1057 1057 * 1058 * @param string1059 * @return1060 1058 */ 1061 1059 private ITaskInstance createTaskInstance(String id) { 1062 1060 ITask task = tasks.get(id); 1063 1061 Event event = null; 1062 1064 1063 if (task == null) { 1065 task = taskFactory.createNewEventTask1066 (new DummyInteraction(id, 0), new DummyGUIElement("default"));1067 1064 event = new Event(new DummyInteraction(id, 0), new DummyGUIElement("default")); 1065 task = taskFactory.createNewEventTask(event.toString()); 1066 1068 1067 tasks.put(id, task); 1069 1068 } 1070 1071 return taskFactory.createNewTaskInstance(task); 1069 else { 1070 event = ((IEventTaskInstance) task.getInstances().iterator().next()).getEvent(); 1071 } 1072 1073 return taskFactory.createNewTaskInstance((IEventTask) task, event); 1072 1074 } 1073 1075 -
trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TaskSymbolIdentityMapTest.java
r1285 r1294 28 28 import org.junit.Test; 29 29 30 import de.ugoe.cs.autoquest.eventcore.Event; 31 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 32 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTaskInstance; 30 33 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 31 34 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory; … … 1054 1057 " took " + (System.currentTimeMillis() - start)); 1055 1058 } 1059 1056 1060 /** 1057 * <p>1058 * TODO: comment1059 * </p>1060 1061 * 1061 * @param string1062 * @return1063 1062 */ 1064 1063 private ITaskInstance createTaskInstance(String id) { 1065 1064 ITask task = tasks.get(id); 1065 Event event = null; 1066 1066 1067 1067 if (task == null) { 1068 task = taskFactory.createNewEventTask1069 (new DummyInteraction(id, 0), new DummyGUIElement("default"));1068 event = new Event(new DummyInteraction(id, 0), new DummyGUIElement("default")); 1069 task = taskFactory.createNewEventTask(event.toString()); 1070 1070 1071 1071 tasks.put(id, task); 1072 1072 } 1073 1074 return taskFactory.createNewTaskInstance(task); 1073 else { 1074 event = ((IEventTaskInstance) task.getInstances().iterator().next()).getEvent(); 1075 } 1076 1077 return taskFactory.createNewTaskInstance((IEventTask) task, event); 1075 1078 } 1076 1079 -
trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskModelTest.java
r1146 r1294 24 24 import org.junit.Test; 25 25 26 import de.ugoe.cs.autoquest.eventcore.Event; 26 27 import de.ugoe.cs.autoquest.eventcore.IEventTarget; 27 28 import de.ugoe.cs.autoquest.eventcore.IEventType; 28 29 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 30 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTaskInstance; 29 31 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 32 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIterationInstance; 30 33 import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptional; 34 import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptionalInstance; 31 35 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 36 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelectionInstance; 32 37 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 38 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequenceInstance; 33 39 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 34 40 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; … … 45 51 46 52 /** 47 * TODO comment 48 * 49 * @version $Revision: $ $Date: 02.04.2012$ 50 * @author 2012, last modified by $Author: patrick$ 53 * 51 54 */ 52 55 public class TaskModelTest { … … 69 72 IEventTarget eventTarget = new DummyGUIElement("elem"); 70 73 71 IEventTask task = taskFactory.createNewEventTask(eventType, eventTarget);74 IEventTask task = createNewEventTask(eventType, eventTarget); 72 75 73 76 assertNotNull(task); … … 76 79 assertTrue(task.equals(task)); 77 80 78 assertEquals(eventType, task.getEventType()); 79 assertEquals(eventTarget, task.getEventTarget()); 81 IEventTaskInstance instance = (IEventTaskInstance) task.getInstances().iterator().next(); 82 assertEquals(eventType, instance.getEvent().getType()); 83 assertEquals(eventTarget, instance.getEvent().getTarget()); 80 84 } 81 85 … … 88 92 IEventTarget eventTarget = new DummyGUIElement("elem"); 89 93 90 IEventTask task1 = taskFactory.createNewEventTask(eventType, eventTarget);91 IEventTask task2 = taskFactory.createNewEventTask(eventType, eventTarget);94 IEventTask task1 = createNewEventTask(eventType, eventTarget); 95 IEventTask task2 = createNewEventTask(eventType, eventTarget); 92 96 93 97 // the tasks will not be equal as they should have a different id … … 103 107 IEventTarget eventTarget = new DummyGUIElement("elem"); 104 108 105 IEventTask task = taskFactory.createNewEventTask(eventType, eventTarget);106 ITaskInstance taskInstance1 = taskFactory.createNewTaskInstance(task);107 ITaskInstance taskInstance2 = taskFactory.createNewTaskInstance(task);109 IEventTask task = createNewEventTask(eventType, eventTarget); 110 ITaskInstance taskInstance1 = createNewTaskInstance(task); 111 ITaskInstance taskInstance2 = createNewTaskInstance(task); 108 112 109 113 assertFalse(taskInstance1.equals(taskInstance2)); … … 133 137 IEventTarget eventTarget = new DummyGUIElement("elem"); 134 138 135 IEventTask child = taskFactory.createNewEventTask(eventType, eventTarget);139 IEventTask child = createNewEventTask(eventType, eventTarget); 136 140 137 141 ISequence task = taskFactory.createNewSequence(); … … 152 156 IEventTarget eventTarget = new DummyGUIElement("elem"); 153 157 154 IEventTask child1 = taskFactory.createNewEventTask(eventType, eventTarget);155 IEventTask child2 = taskFactory.createNewEventTask(eventType, eventTarget);156 IEventTask child3 = taskFactory.createNewEventTask(eventType, eventTarget);157 IEventTask child4 = taskFactory.createNewEventTask(eventType, eventTarget);158 IEventTask child5 = taskFactory.createNewEventTask(eventType, eventTarget);158 IEventTask child1 = createNewEventTask(eventType, eventTarget); 159 IEventTask child2 = createNewEventTask(eventType, eventTarget); 160 IEventTask child3 = createNewEventTask(eventType, eventTarget); 161 IEventTask child4 = createNewEventTask(eventType, eventTarget); 162 IEventTask child5 = createNewEventTask(eventType, eventTarget); 159 163 160 164 ISequence task = taskFactory.createNewSequence(); … … 198 202 IEventTarget eventTarget = new DummyGUIElement("elem"); 199 203 200 IEventTask child = taskFactory.createNewEventTask(eventType, eventTarget);204 IEventTask child = createNewEventTask(eventType, eventTarget); 201 205 202 206 ISelection task = taskFactory.createNewSelection(); … … 217 221 IEventTarget eventTarget = new DummyGUIElement("elem"); 218 222 219 IEventTask child1 = taskFactory.createNewEventTask(eventType, eventTarget);220 IEventTask child2 = taskFactory.createNewEventTask(eventType, eventTarget);221 IEventTask child3 = taskFactory.createNewEventTask(eventType, eventTarget);222 IEventTask child4 = taskFactory.createNewEventTask(eventType, eventTarget);223 IEventTask child5 = taskFactory.createNewEventTask(eventType, eventTarget);223 IEventTask child1 = createNewEventTask(eventType, eventTarget); 224 IEventTask child2 = createNewEventTask(eventType, eventTarget); 225 IEventTask child3 = createNewEventTask(eventType, eventTarget); 226 IEventTask child4 = createNewEventTask(eventType, eventTarget); 227 IEventTask child5 = createNewEventTask(eventType, eventTarget); 224 228 225 229 ISelection task = taskFactory.createNewSelection(); … … 262 266 IEventTarget eventTarget = new DummyGUIElement("elem"); 263 267 264 IEventTask child = taskFactory.createNewEventTask(eventType, eventTarget);268 IEventTask child = createNewEventTask(eventType, eventTarget); 265 269 266 270 IIteration task = taskFactory.createNewIteration(); … … 279 283 IEventTarget eventTarget = new DummyGUIElement("elem"); 280 284 281 IEventTask child1 = taskFactory.createNewEventTask(eventType, eventTarget);282 IEventTask child2 = taskFactory.createNewEventTask(eventType, eventTarget);285 IEventTask child1 = createNewEventTask(eventType, eventTarget); 286 IEventTask child2 = createNewEventTask(eventType, eventTarget); 283 287 284 288 IIteration task = taskFactory.createNewIteration(); … … 312 316 IEventTarget eventTarget = new DummyGUIElement("elem"); 313 317 314 IEventTask child = taskFactory.createNewEventTask(eventType, eventTarget);318 IEventTask child = createNewEventTask(eventType, eventTarget); 315 319 316 320 IOptional task = taskFactory.createNewOptional(); … … 329 333 IEventTarget eventTarget = new DummyGUIElement("elem"); 330 334 331 IEventTask child1 = taskFactory.createNewEventTask(eventType, eventTarget);332 IEventTask child2 = taskFactory.createNewEventTask(eventType, eventTarget);335 IEventTask child1 = createNewEventTask(eventType, eventTarget); 336 IEventTask child2 = createNewEventTask(eventType, eventTarget); 333 337 334 338 IOptional task = taskFactory.createNewOptional(); … … 348 352 IEventTarget eventTarget = new DummyGUIElement("elem"); 349 353 350 IEventTask task = taskFactory.createNewEventTask(eventType, eventTarget);351 352 I TaskInstance taskInstance = taskFactory.createNewTaskInstance(task);354 IEventTask task = createNewEventTask(eventType, eventTarget); 355 356 IEventTaskInstance taskInstance = createNewTaskInstance(task); 353 357 354 358 assertNotNull(taskInstance); … … 356 360 assertTrue(taskInstance.equals(taskInstance)); 357 361 assertFalse(taskInstance.equals(task)); 358 assertNotNull(taskInstance.getChildren());359 assertEquals(0, taskInstance.getChildren().size());360 362 } 361 363 … … 368 370 IEventTarget eventTarget = new DummyGUIElement("elem"); 369 371 370 IEventTask task = taskFactory.createNewEventTask(eventType, eventTarget);371 372 ITaskInstance taskInstance1 = taskFactory.createNewTaskInstance(task);373 ITaskInstance taskInstance2 = taskFactory.createNewTaskInstance(task);372 IEventTask task = createNewEventTask(eventType, eventTarget); 373 374 ITaskInstance taskInstance1 = createNewTaskInstance(task); 375 ITaskInstance taskInstance2 = createNewTaskInstance(task); 374 376 375 377 assertFalse(taskInstance1.equals(taskInstance2)); 376 }377 378 /**379 *380 */381 @Test(expected=IllegalArgumentException.class)382 public void test_EventTaskInstance_03() throws Exception {383 IEventType eventType = new DummyInteraction("interaction", 1);384 IEventTarget eventTarget = new DummyGUIElement("elem");385 386 IEventTask task = taskFactory.createNewEventTask(eventType, eventTarget);387 388 ITaskInstance taskInstance1 = taskFactory.createNewTaskInstance(task);389 ITaskInstance taskInstance2 = taskFactory.createNewTaskInstance(task);390 391 taskBuilder.addChild(taskInstance1, taskInstance2);392 378 } 393 379 … … 400 386 IEventTarget eventTarget = new DummyGUIElement("elem"); 401 387 402 IEventTask task = taskFactory.createNewEventTask(eventType, eventTarget);388 IEventTask task = createNewEventTask(eventType, eventTarget); 403 389 404 390 ISequence sequence = taskFactory.createNewSequence(); 405 391 406 ITaskInstance taskInstance = taskFactory.createNewTaskInstance(task);407 I TaskInstance sequenceInstance = taskFactory.createNewTaskInstance(sequence);392 ITaskInstance taskInstance = createNewTaskInstance(task); 393 ISequenceInstance sequenceInstance = createNewTaskInstance(sequence); 408 394 409 395 taskBuilder.addChild(sequenceInstance, taskInstance); … … 418 404 IEventTarget eventTarget = new DummyGUIElement("elem"); 419 405 420 IEventTask task = taskFactory.createNewEventTask(eventType, eventTarget);406 IEventTask task = createNewEventTask(eventType, eventTarget); 421 407 422 408 ISequence sequence = taskFactory.createNewSequence(); 423 409 taskBuilder.addChild(sequence, task); 424 410 425 ITaskInstance taskInstance = taskFactory.createNewTaskInstance(task);426 I TaskInstance sequenceInstance = taskFactory.createNewTaskInstance(sequence);411 ITaskInstance taskInstance = createNewTaskInstance(task); 412 ISequenceInstance sequenceInstance = createNewTaskInstance(sequence); 427 413 428 414 taskBuilder.addChild(sequenceInstance, taskInstance); 429 415 430 assertNotNull(sequenceInstance.getChildren()); 431 assertEquals(1, sequenceInstance.getChildren().size()); 432 assertEquals(taskInstance, sequenceInstance.getChildren().get(0)); 416 assertEquals(1, sequenceInstance.size()); 417 assertEquals(taskInstance, sequenceInstance.get(0)); 433 418 } 434 419 … … 441 426 IEventTarget eventTarget = new DummyGUIElement("elem"); 442 427 443 IEventTask task1 = taskFactory.createNewEventTask(eventType, eventTarget);444 IEventTask task2 = taskFactory.createNewEventTask(eventType, eventTarget);445 IEventTask task3 = taskFactory.createNewEventTask(eventType, eventTarget);446 IEventTask task4 = taskFactory.createNewEventTask(eventType, eventTarget);447 IEventTask task5 = taskFactory.createNewEventTask(eventType, eventTarget);428 IEventTask task1 = createNewEventTask(eventType, eventTarget); 429 IEventTask task2 = createNewEventTask(eventType, eventTarget); 430 IEventTask task3 = createNewEventTask(eventType, eventTarget); 431 IEventTask task4 = createNewEventTask(eventType, eventTarget); 432 IEventTask task5 = createNewEventTask(eventType, eventTarget); 448 433 449 434 ISequence sequence = taskFactory.createNewSequence(); … … 454 439 taskBuilder.addChild(sequence, task5); 455 440 456 ITaskInstance taskInstance1 = taskFactory.createNewTaskInstance(task1);457 ITaskInstance taskInstance2 = taskFactory.createNewTaskInstance(task2);458 ITaskInstance taskInstance3 = taskFactory.createNewTaskInstance(task3);459 ITaskInstance taskInstance4 = taskFactory.createNewTaskInstance(task4);460 ITaskInstance taskInstance5 = taskFactory.createNewTaskInstance(task5);461 I TaskInstance sequenceInstance = taskFactory.createNewTaskInstance(sequence);441 ITaskInstance taskInstance1 = createNewTaskInstance(task1); 442 ITaskInstance taskInstance2 = createNewTaskInstance(task2); 443 ITaskInstance taskInstance3 = createNewTaskInstance(task3); 444 ITaskInstance taskInstance4 = createNewTaskInstance(task4); 445 ITaskInstance taskInstance5 = createNewTaskInstance(task5); 446 ISequenceInstance sequenceInstance = createNewTaskInstance(sequence); 462 447 463 448 taskBuilder.addChild(sequenceInstance, taskInstance1); … … 467 452 taskBuilder.addChild(sequenceInstance, taskInstance5); 468 453 469 assertNotNull(sequenceInstance.getChildren()); 470 assertEquals(5, sequenceInstance.getChildren().size()); 471 assertEquals(taskInstance1, sequenceInstance.getChildren().get(0)); 472 assertEquals(taskInstance2, sequenceInstance.getChildren().get(1)); 473 assertEquals(taskInstance3, sequenceInstance.getChildren().get(2)); 474 assertEquals(taskInstance4, sequenceInstance.getChildren().get(3)); 475 assertEquals(taskInstance5, sequenceInstance.getChildren().get(4)); 454 assertEquals(5, sequenceInstance.size()); 455 assertEquals(taskInstance1, sequenceInstance.get(0)); 456 assertEquals(taskInstance2, sequenceInstance.get(1)); 457 assertEquals(taskInstance3, sequenceInstance.get(2)); 458 assertEquals(taskInstance4, sequenceInstance.get(3)); 459 assertEquals(taskInstance5, sequenceInstance.get(4)); 476 460 } 477 461 … … 484 468 IEventTarget eventTarget = new DummyGUIElement("elem"); 485 469 486 IEventTask task = taskFactory.createNewEventTask(eventType, eventTarget);470 IEventTask task = createNewEventTask(eventType, eventTarget); 487 471 488 472 ISelection selection = taskFactory.createNewSelection(); 489 473 490 ITaskInstance taskInstance = taskFactory.createNewTaskInstance(task);491 I TaskInstance selectionInstance = taskFactory.createNewTaskInstance(selection);492 493 taskBuilder. addChild(selectionInstance, taskInstance);474 ITaskInstance taskInstance = createNewTaskInstance(task); 475 ISelectionInstance selectionInstance = createNewTaskInstance(selection); 476 477 taskBuilder.setChild(selectionInstance, taskInstance); 494 478 } 495 479 … … 502 486 IEventTarget eventTarget = new DummyGUIElement("elem"); 503 487 504 IEventTask task = taskFactory.createNewEventTask(eventType, eventTarget);488 IEventTask task = createNewEventTask(eventType, eventTarget); 505 489 506 490 ISelection selection = taskFactory.createNewSelection(); 507 491 taskBuilder.addChild(selection, task); 508 492 509 ITaskInstance taskInstance = taskFactory.createNewTaskInstance(task); 510 ITaskInstance selectionInstance = taskFactory.createNewTaskInstance(selection); 511 512 taskBuilder.addChild(selectionInstance, taskInstance); 513 514 assertNotNull(selectionInstance.getChildren()); 515 assertEquals(1, selectionInstance.getChildren().size()); 516 assertEquals(taskInstance, selectionInstance.getChildren().get(0)); 517 } 518 519 /** 520 * 521 */ 522 @Test(expected=IllegalArgumentException.class) 493 ITaskInstance taskInstance = createNewTaskInstance(task); 494 ISelectionInstance selectionInstance = createNewTaskInstance(selection); 495 496 taskBuilder.setChild(selectionInstance, taskInstance); 497 498 assertNotNull(selectionInstance.getChild()); 499 assertEquals(taskInstance, selectionInstance.getChild()); 500 } 501 502 /** 503 * 504 */ 505 @Test 523 506 public void test_SelectionInstance_03() throws Exception { 524 507 IEventType eventType = new DummyInteraction("interaction", 1); 525 508 IEventTarget eventTarget = new DummyGUIElement("elem"); 526 509 527 IEventTask task1 = taskFactory.createNewEventTask(eventType, eventTarget);528 IEventTask task2 = taskFactory.createNewEventTask(eventType, eventTarget);529 IEventTask task3 = taskFactory.createNewEventTask(eventType, eventTarget);530 IEventTask task4 = taskFactory.createNewEventTask(eventType, eventTarget);531 IEventTask task5 = taskFactory.createNewEventTask(eventType, eventTarget);510 IEventTask task1 = createNewEventTask(eventType, eventTarget); 511 IEventTask task2 = createNewEventTask(eventType, eventTarget); 512 IEventTask task3 = createNewEventTask(eventType, eventTarget); 513 IEventTask task4 = createNewEventTask(eventType, eventTarget); 514 IEventTask task5 = createNewEventTask(eventType, eventTarget); 532 515 533 516 ISelection selection = taskFactory.createNewSelection(); … … 538 521 taskBuilder.addChild(selection, task5); 539 522 540 ITaskInstance taskInstance1 = taskFactory.createNewTaskInstance(task1); 541 ITaskInstance taskInstance2 = taskFactory.createNewTaskInstance(task2); 542 ITaskInstance selectionInstance = taskFactory.createNewTaskInstance(selection); 543 544 taskBuilder.addChild(selectionInstance, taskInstance1); 545 taskBuilder.addChild(selectionInstance, taskInstance2); 523 ITaskInstance taskInstance1 = createNewTaskInstance(task1); 524 ITaskInstance taskInstance2 = createNewTaskInstance(task2); 525 ISelectionInstance selectionInstance = createNewTaskInstance(selection); 526 527 taskBuilder.setChild(selectionInstance, taskInstance1); 528 taskBuilder.setChild(selectionInstance, taskInstance2); 529 530 assertEquals(taskInstance2, selectionInstance.getChild()); 546 531 } 547 532 … … 554 539 IEventTarget eventTarget = new DummyGUIElement("elem"); 555 540 556 IEventTask task = taskFactory.createNewEventTask(eventType, eventTarget);541 IEventTask task = createNewEventTask(eventType, eventTarget); 557 542 558 543 IIteration iteration = taskFactory.createNewIteration(); 559 544 560 ITaskInstance taskInstance = taskFactory.createNewTaskInstance(task);561 I TaskInstance iterationInstance = taskFactory.createNewTaskInstance(iteration);545 ITaskInstance taskInstance = createNewTaskInstance(task); 546 IIterationInstance iterationInstance = createNewTaskInstance(iteration); 562 547 563 548 taskBuilder.addChild(iterationInstance, taskInstance); … … 572 557 IEventTarget eventTarget = new DummyGUIElement("elem"); 573 558 574 IEventTask task = taskFactory.createNewEventTask(eventType, eventTarget);559 IEventTask task = createNewEventTask(eventType, eventTarget); 575 560 576 561 IIteration iteration = taskFactory.createNewIteration(); 577 562 taskBuilder.setMarkedTask(iteration, task); 578 563 579 ITaskInstance taskInstance = taskFactory.createNewTaskInstance(task);580 I TaskInstance iterationInstance = taskFactory.createNewTaskInstance(iteration);564 ITaskInstance taskInstance = createNewTaskInstance(task); 565 IIterationInstance iterationInstance = createNewTaskInstance(iteration); 581 566 582 567 taskBuilder.addChild(iterationInstance, taskInstance); 583 568 584 assertNotNull(iterationInstance.getChildren()); 585 assertEquals(1, iterationInstance.getChildren().size()); 586 assertEquals(taskInstance, iterationInstance.getChildren().get(0)); 569 assertEquals(1, iterationInstance.size()); 570 assertEquals(taskInstance, iterationInstance.get(0)); 587 571 } 588 572 … … 595 579 IEventTarget eventTarget = new DummyGUIElement("elem"); 596 580 597 IEventTask task1 = taskFactory.createNewEventTask(eventType, eventTarget);598 IEventTask task2 = taskFactory.createNewEventTask(eventType, eventTarget);581 IEventTask task1 = createNewEventTask(eventType, eventTarget); 582 IEventTask task2 = createNewEventTask(eventType, eventTarget); 599 583 600 584 IIteration iteration = taskFactory.createNewIteration(); … … 602 586 taskBuilder.setMarkedTask(iteration, task2); 603 587 604 ITaskInstance taskInstance1 = taskFactory.createNewTaskInstance(task1);605 I TaskInstance iterationInstance = taskFactory.createNewTaskInstance(iteration);588 ITaskInstance taskInstance1 = createNewTaskInstance(task1); 589 IIterationInstance iterationInstance = createNewTaskInstance(iteration); 606 590 607 591 taskBuilder.addChild(iterationInstance, taskInstance1); … … 616 600 IEventTarget eventTarget = new DummyGUIElement("elem"); 617 601 618 IEventTask task1 = taskFactory.createNewEventTask(eventType, eventTarget);619 IEventTask task2 = taskFactory.createNewEventTask(eventType, eventTarget);602 IEventTask task1 = createNewEventTask(eventType, eventTarget); 603 IEventTask task2 = createNewEventTask(eventType, eventTarget); 620 604 621 605 IIteration iteration = taskFactory.createNewIteration(); … … 623 607 taskBuilder.setMarkedTask(iteration, task2); 624 608 625 ITaskInstance taskInstance2 = taskFactory.createNewTaskInstance(task2);626 I TaskInstance iterationInstance = taskFactory.createNewTaskInstance(iteration);609 ITaskInstance taskInstance2 = createNewTaskInstance(task2); 610 IIterationInstance iterationInstance = createNewTaskInstance(iteration); 627 611 628 612 taskBuilder.addChild(iterationInstance, taskInstance2); 629 613 630 assertNotNull(iterationInstance.getChildren()); 631 assertEquals(1, iterationInstance.getChildren().size()); 632 assertEquals(taskInstance2, iterationInstance.getChildren().get(0)); 614 assertEquals(1, iterationInstance.size()); 615 assertEquals(taskInstance2, iterationInstance.get(0)); 633 616 } 634 617 … … 641 624 IEventTarget eventTarget = new DummyGUIElement("elem"); 642 625 643 IEventTask task = taskFactory.createNewEventTask(eventType, eventTarget);626 IEventTask task = createNewEventTask(eventType, eventTarget); 644 627 645 628 IOptional optional = taskFactory.createNewOptional(); 646 629 647 ITaskInstance taskInstance = taskFactory.createNewTaskInstance(task);648 I TaskInstance optionalInstance = taskFactory.createNewTaskInstance(optional);649 650 taskBuilder. addChild(optionalInstance, taskInstance);630 ITaskInstance taskInstance = createNewTaskInstance(task); 631 IOptionalInstance optionalInstance = createNewTaskInstance(optional); 632 633 taskBuilder.setChild(optionalInstance, taskInstance); 651 634 } 652 635 … … 659 642 IEventTarget eventTarget = new DummyGUIElement("elem"); 660 643 661 IEventTask task = taskFactory.createNewEventTask(eventType, eventTarget);644 IEventTask task = createNewEventTask(eventType, eventTarget); 662 645 663 646 IOptional optional = taskFactory.createNewOptional(); 664 647 taskBuilder.setMarkedTask(optional, task); 665 648 666 ITaskInstance taskInstance = taskFactory.createNewTaskInstance(task); 667 ITaskInstance optionalInstance = taskFactory.createNewTaskInstance(optional); 668 669 taskBuilder.addChild(optionalInstance, taskInstance); 670 671 assertNotNull(optionalInstance.getChildren()); 672 assertEquals(1, optionalInstance.getChildren().size()); 673 assertEquals(taskInstance, optionalInstance.getChildren().get(0)); 649 ITaskInstance taskInstance = createNewTaskInstance(task); 650 IOptionalInstance optionalInstance = createNewTaskInstance(optional); 651 652 taskBuilder.setChild(optionalInstance, taskInstance); 653 654 assertNotNull(optionalInstance.getChild()); 655 assertEquals(taskInstance, optionalInstance.getChild()); 674 656 } 675 657 … … 682 664 IEventTarget eventTarget = new DummyGUIElement("elem"); 683 665 684 IEventTask task1 = taskFactory.createNewEventTask(eventType, eventTarget);685 IEventTask task2 = taskFactory.createNewEventTask(eventType, eventTarget);666 IEventTask task1 = createNewEventTask(eventType, eventTarget); 667 IEventTask task2 = createNewEventTask(eventType, eventTarget); 686 668 687 669 IOptional optional = taskFactory.createNewOptional(); … … 689 671 taskBuilder.setMarkedTask(optional, task2); 690 672 691 ITaskInstance taskInstance1 = taskFactory.createNewTaskInstance(task1);692 I TaskInstance optionalInstance = taskFactory.createNewTaskInstance(optional);693 694 taskBuilder. addChild(optionalInstance, taskInstance1);673 ITaskInstance taskInstance1 = createNewTaskInstance(task1); 674 IOptionalInstance optionalInstance = createNewTaskInstance(optional); 675 676 taskBuilder.setChild(optionalInstance, taskInstance1); 695 677 } 696 678 … … 703 685 IEventTarget eventTarget = new DummyGUIElement("elem"); 704 686 705 IEventTask task1 = taskFactory.createNewEventTask(eventType, eventTarget);706 IEventTask task2 = taskFactory.createNewEventTask(eventType, eventTarget);687 IEventTask task1 = createNewEventTask(eventType, eventTarget); 688 IEventTask task2 = createNewEventTask(eventType, eventTarget); 707 689 708 690 IOptional optional = taskFactory.createNewOptional(); … … 710 692 taskBuilder.setMarkedTask(optional, task2); 711 693 712 ITaskInstance taskInstance2 = taskFactory.createNewTaskInstance(task2); 713 ITaskInstance optionalInstance = taskFactory.createNewTaskInstance(optional); 714 715 taskBuilder.addChild(optionalInstance, taskInstance2); 716 717 assertNotNull(optionalInstance.getChildren()); 718 assertEquals(1, optionalInstance.getChildren().size()); 719 assertEquals(taskInstance2, optionalInstance.getChildren().get(0)); 694 ITaskInstance taskInstance2 = createNewTaskInstance(task2); 695 IOptionalInstance optionalInstance = createNewTaskInstance(optional); 696 697 taskBuilder.setChild(optionalInstance, taskInstance2); 698 699 assertNotNull(optionalInstance.getChild()); 700 assertEquals(taskInstance2, optionalInstance.getChild()); 720 701 } 721 702 … … 740 721 IEventTarget eventTarget = new DummyGUIElement("elem"); 741 722 742 IEventTask task = taskFactory.createNewEventTask(eventType, eventTarget);723 IEventTask task = createNewEventTask(eventType, eventTarget); 743 724 744 725 IUserSession userSession = taskFactory.createUserSession(); 745 726 746 ITaskInstance taskInstance = taskFactory.createNewTaskInstance(task);727 ITaskInstance taskInstance = createNewTaskInstance(task); 747 728 748 729 taskBuilder.addExecutedTask(userSession, taskInstance); … … 761 742 IEventTarget eventTarget = new DummyGUIElement("elem"); 762 743 763 IEventTask task = taskFactory.createNewEventTask(eventType, eventTarget);744 IEventTask task = createNewEventTask(eventType, eventTarget); 764 745 ISequence sequence = taskFactory.createNewSequence(); 765 746 ISelection selection = taskFactory.createNewSelection(); … … 772 753 taskBuilder.setMarkedTask(optional, task); 773 754 774 ITaskInstance taskInstance = taskFactory.createNewTaskInstance(task);775 I TaskInstance sequenceInstance = taskFactory.createNewTaskInstance(sequence);776 I TaskInstance selectionInstance = taskFactory.createNewTaskInstance(selection);777 I TaskInstance iterationInstance = taskFactory.createNewTaskInstance(iteration);778 I TaskInstance optionalInstance = taskFactory.createNewTaskInstance(optional);779 780 taskBuilder.addChild(sequenceInstance, taskFactory.createNewTaskInstance(task));781 taskBuilder. addChild(selectionInstance, taskFactory.createNewTaskInstance(task));782 taskBuilder.addChild(iterationInstance, taskFactory.createNewTaskInstance(task));783 taskBuilder. addChild(optionalInstance, taskFactory.createNewTaskInstance(task));755 ITaskInstance taskInstance = createNewTaskInstance(task); 756 ISequenceInstance sequenceInstance = createNewTaskInstance(sequence); 757 ISelectionInstance selectionInstance = createNewTaskInstance(selection); 758 IIterationInstance iterationInstance = createNewTaskInstance(iteration); 759 IOptionalInstance optionalInstance = createNewTaskInstance(optional); 760 761 taskBuilder.addChild(sequenceInstance, createNewTaskInstance(task)); 762 taskBuilder.setChild(selectionInstance, createNewTaskInstance(task)); 763 taskBuilder.addChild(iterationInstance, createNewTaskInstance(task)); 764 taskBuilder.setChild(optionalInstance, createNewTaskInstance(task)); 784 765 785 766 IUserSession userSession = taskFactory.createUserSession(); … … 823 804 } 824 805 825 ITaskInstance taskInstance = instantiateTask(task, noOfMaxChildren); 806 ISequenceInstance sequenceInstance = 807 (ISequenceInstance) instantiateTask(task, noOfMaxChildren); 826 808 827 809 System.err.println(" creating user session"); … … 829 811 IUserSession session = taskFactory.createUserSession(); 830 812 831 for (ITaskInstance child : taskInstance.getChildren()) {813 for (ITaskInstance child : sequenceInstance) { 832 814 taskBuilder.addExecutedTask(session, child); 833 815 } … … 836 818 sessions.add(session); 837 819 838 ITaskModel task Tree= taskFactory.createTaskModel(sessions);820 ITaskModel taskModel = taskFactory.createTaskModel(sessions); 839 821 840 822 System.err.println(" validating task tree"); 841 823 Map<ITask, ITaskInfo> actualTaskInfos = new HashMap<ITask, ITaskInfo>(); 842 824 843 for (ITask currentTask : task Tree.getTasks()) {844 actualTaskInfos.put(currentTask, task Tree.getTaskInfo(currentTask));825 for (ITask currentTask : taskModel.getTasks()) { 826 actualTaskInfos.put(currentTask, taskModel.getTaskInfo(currentTask)); 845 827 } 846 828 … … 988 970 Thread.sleep(2); 989 971 long id = System.currentTimeMillis(); 990 IEventTask task = taskFactory.createNewEventTask972 IEventTask task = createNewEventTask 991 973 (new DummyInteraction("interaction" + id, 1), new DummyGUIElement("elem" + id)); 992 974 … … 1064 1046 1065 1047 for (int i = 0; i < noOfChildren; i++) { 1066 ITask child = createTaskTree(maxNoOfChildren, maxDepth - 1, taskInfos); 1048 ITask child; 1049 do { 1050 child = createTaskTree(maxNoOfChildren, maxDepth - 1, taskInfos); 1051 } 1052 while (child instanceof ISelection); 1053 1067 1054 taskBuilder.addChild(selection, child); 1068 1055 } … … 1099 1086 IIteration iteration = taskFactory.createNewIteration(); 1100 1087 1101 ITask child = createTaskTree(maxNoOfChildren, maxDepth - 1, taskInfos); 1088 ITask child; 1089 do { 1090 child = createTaskTree(maxNoOfChildren, maxDepth - 1, taskInfos); 1091 } 1092 while ((child instanceof IOptional) || (child instanceof IIteration)); 1093 1102 1094 taskBuilder.setMarkedTask(iteration, child); 1103 1095 … … 1133 1125 IOptional optional = taskFactory.createNewOptional(); 1134 1126 1135 ITask child = createTaskTree(maxNoOfChildren, maxDepth - 1, taskInfos); 1127 ITask child; 1128 do { 1129 child = createTaskTree(maxNoOfChildren, maxDepth - 1, taskInfos); 1130 } 1131 while (child instanceof IOptional); 1132 1136 1133 taskBuilder.setMarkedTask(optional, child); 1137 1134 … … 1193 1190 */ 1194 1191 private ITaskInstance instantiateTask(ITask task, int maxIterationCount) throws Exception { 1195 ITaskInstance instance = taskFactory.createNewTaskInstance(task);1192 ITaskInstance instance = createNewTaskInstance(task); 1196 1193 1197 1194 if (task instanceof ISequence) { 1198 1195 for (ITask child : ((ISequence) task).getChildren()) { 1199 taskBuilder.addChild(instance, instantiateTask(child, maxIterationCount)); 1196 taskBuilder.addChild 1197 ((ISequenceInstance) instance, instantiateTask(child, maxIterationCount)); 1200 1198 } 1201 1199 } … … 1203 1201 List<ITask> children = ((ISelection) task).getChildren(); 1204 1202 int index = randomize(children.size()); 1205 taskBuilder.addChild(instance, instantiateTask(children.get(index), maxIterationCount)); 1203 taskBuilder.setChild((ISelectionInstance) instance, 1204 instantiateTask(children.get(index),maxIterationCount)); 1206 1205 } 1207 1206 else if (task instanceof IIteration) { … … 1210 1209 1211 1210 for (int i = 0; i < count; i++) { 1212 taskBuilder.addChild(instance, instantiateTask(child, maxIterationCount)); 1211 taskBuilder.addChild 1212 ((IIterationInstance) instance, instantiateTask(child, maxIterationCount)); 1213 1213 } 1214 1214 } … … 1217 1217 1218 1218 if (randomize(1) == 0) { 1219 taskBuilder.addChild(instance, instantiateTask(child, maxIterationCount)); 1219 taskBuilder.setChild((IOptionalInstance) instance, 1220 instantiateTask(child, maxIterationCount)); 1220 1221 } 1221 1222 } … … 1244 1245 return value + min; 1245 1246 } 1247 1248 /** 1249 * 1250 */ 1251 protected IEventTask createNewEventTask(IEventType eventType, IEventTarget eventTarget) { 1252 IEventTask eventTask = taskFactory.createNewEventTask(eventType + " --> " + eventTarget); 1253 taskFactory.createNewTaskInstance(eventTask, new Event(eventType, eventTarget)); 1254 return eventTask; 1255 } 1256 1257 /** 1258 * 1259 */ 1260 private ITaskInstance createNewTaskInstance(ITask task) { 1261 if (task instanceof IEventTask) { 1262 return createNewTaskInstance((IEventTask) task); 1263 } 1264 else if (task instanceof ISequence) { 1265 return createNewTaskInstance((ISequence) task); 1266 } 1267 else if (task instanceof ISelection) { 1268 return createNewTaskInstance((ISelection) task); 1269 } 1270 else if (task instanceof IIteration) { 1271 return createNewTaskInstance((IIteration) task); 1272 } 1273 else if (task instanceof IOptional) { 1274 return createNewTaskInstance((IOptional) task); 1275 } 1276 1277 throw new IllegalArgumentException("unknown type of task"); 1278 } 1279 1280 /** 1281 * 1282 */ 1283 private IEventTaskInstance createNewTaskInstance(IEventTask task) { 1284 IEventTaskInstance existingInstance = 1285 (IEventTaskInstance) task.getInstances().iterator().next(); 1286 return taskFactory.createNewTaskInstance(task, existingInstance.getEvent()); 1287 } 1288 1289 /** 1290 * 1291 */ 1292 private ISequenceInstance createNewTaskInstance(ISequence task) { 1293 return taskFactory.createNewTaskInstance(task); 1294 } 1295 1296 /** 1297 * 1298 */ 1299 private ISelectionInstance createNewTaskInstance(ISelection task) { 1300 return taskFactory.createNewTaskInstance(task); 1301 } 1302 1303 /** 1304 * 1305 */ 1306 private IIterationInstance createNewTaskInstance(IIteration task) { 1307 return taskFactory.createNewTaskInstance(task); 1308 } 1309 1310 /** 1311 * 1312 */ 1313 private IOptionalInstance createNewTaskInstance(IOptional task) { 1314 return taskFactory.createNewTaskInstance(task); 1315 } 1316 1246 1317 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/manager/TaskTreeManager.java
r1154 r1294 21 21 22 22 import de.ugoe.cs.autoquest.eventcore.Event; 23 import de.ugoe.cs.autoquest.tasktrees.treeifc.I Task;23 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 24 24 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; 25 25 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; … … 124 124 public void handleNewEvent(Event event) { 125 125 assertSessionSequence(); 126 ITask eventTask = taskFactory.createNewEventTask(event.getType(), event.getTarget()); 127 taskBuilder.addExecutedTask(currentSession, taskFactory.createNewTaskInstance(eventTask)); 126 String description = event.getType().getName() + " \u21D2 " + event.getTarget(); 127 IEventTask eventTask = taskFactory.createNewEventTask(description); 128 taskBuilder.addExecutedTask 129 (currentSession, taskFactory.createNewTaskInstance(eventTask, event)); 128 130 } 129 131 -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/EventTaskComparisonRule.java
r1146 r1294 15 15 package de.ugoe.cs.autoquest.tasktrees.taskequality; 16 16 17 import java.util.Collection; 18 17 19 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 20 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTaskInstance; 18 21 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 22 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 19 23 20 24 /** … … 29 33 30 34 /* (non-Javadoc) 31 * @see NodeComparisonRule#isApplicable(ITask, ITask)35 * @see TaskComparisonRule#isApplicable(ITask, ITask) 32 36 */ 33 37 @Override … … 37 41 38 42 /* (non-Javadoc) 39 * @see NodeComparisonRule#areLexicallyEqual(ITask, ITask)43 * @see TaskComparisonRule#areLexicallyEqual(ITask, ITask) 40 44 */ 41 45 @Override 42 46 public boolean areLexicallyEqual(ITask task1, ITask task2) { 43 IEventTask eventTask1 = (IEventTask) task1;44 IEventTask eventTask2 = (IEventTask) task2;47 Collection<ITaskInstance> taskInstances1 = task1.getInstances(); 48 Collection<ITaskInstance> taskInstances2 = task2.getInstances(); 45 49 46 return (eventTask1.getEventType().equals(eventTask2.getEventType()) && 47 eventTask1.getEventTarget().equals(eventTask2.getEventTarget())); 50 for (ITaskInstance instance1 : taskInstances1) { 51 boolean found = false; 52 53 for (ITaskInstance instance2 : taskInstances2) { 54 if (areLexicallyEqual(instance1, instance2)) { 55 found = true; 56 break; 57 } 58 } 59 60 if (!found) { 61 return false; 62 } 63 } 64 65 return true; 48 66 } 49 67 50 68 /* (non-Javadoc) 51 * @see NodeComparisonRule#areSyntacticallyEqual(ITask, ITask)69 * @see TaskComparisonRule#areSyntacticallyEqual(ITask, ITask) 52 70 */ 53 71 @Override … … 57 75 58 76 /* (non-Javadoc) 59 * @see NodeComparisonRule#areSemanticallyEqual(ITask, ITask)77 * @see TaskComparisonRule#areSemanticallyEqual(ITask, ITask) 60 78 */ 61 79 @Override … … 64 82 } 65 83 84 /* (non-Javadoc) 85 * @see TaskComparisonRule#compare(ITask, ITask) 86 */ 66 87 @Override 67 88 public TaskEquality compare(ITask task1, ITask task2) { … … 74 95 } 75 96 97 98 /* (non-Javadoc) 99 * @see TaskComparisonRule#isApplicable(ITaskInstance, ITaskInstance) 100 */ 101 @Override 102 public boolean isApplicable(ITaskInstance instance1, ITaskInstance instance2) { 103 return 104 (instance1 instanceof IEventTaskInstance) && (instance2 instanceof IEventTaskInstance); 105 } 106 107 /* (non-Javadoc) 108 * @see TaskComparisonRule#areLexicallyEqual(ITaskInstance, ITaskInstance) 109 */ 110 @Override 111 public boolean areLexicallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 112 IEventTaskInstance eventTask1 = (IEventTaskInstance) instance1; 113 IEventTaskInstance eventTask2 = (IEventTaskInstance) instance2; 114 115 return (eventTask1.getEvent().getType().equals(eventTask2.getEvent().getType()) && 116 eventTask1.getEvent().getTarget().equals(eventTask2.getEvent().getTarget())); 117 } 118 119 /* (non-Javadoc) 120 * @see TaskComparisonRule#areSyntacticallyEqual(ITaskInstance, ITaskInstance) 121 */ 122 @Override 123 public boolean areSyntacticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 124 return areLexicallyEqual(instance1, instance2); 125 } 126 127 /* (non-Javadoc) 128 * @see TaskComparisonRule#areSemanticallyEqual(ITaskInstance, ITaskInstance) 129 */ 130 @Override 131 public boolean areSemanticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 132 return areLexicallyEqual(instance1, instance2); 133 } 134 135 /* (non-Javadoc) 136 * @see TaskComparisonRule#compare(ITaskInstance, ITaskInstance) 137 */ 138 @Override 139 public TaskEquality compare(ITaskInstance instance1, ITaskInstance instance2) { 140 if (areLexicallyEqual(instance1, instance2)) { 141 return TaskEquality.LEXICALLY_EQUAL; 142 } 143 else { 144 return TaskEquality.UNEQUAL; 145 } 146 } 147 76 148 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/GUIEventTaskComparisonRule.java
r1154 r1294 14 14 15 15 package de.ugoe.cs.autoquest.tasktrees.taskequality; 16 17 import java.util.Collection; 16 18 17 19 import de.ugoe.cs.autoquest.eventcore.IEventTarget; … … 41 43 import de.ugoe.cs.autoquest.eventcore.guimodel.IText; 42 44 import de.ugoe.cs.autoquest.eventcore.guimodel.IToolTip; 43 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask ;45 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTaskInstance; 44 46 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 47 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 45 48 46 49 /** … … 61 64 62 65 /* (non-Javadoc) 63 * @see NodeComparisonRule#isApplicable(ITask, ITask)66 * @see TaskComparisonRule#isApplicable(ITask, ITask) 64 67 */ 65 68 @Override 66 69 public boolean isApplicable(ITask task1, ITask task2) { 67 return 68 ((task1 instanceof IEventTask) && (task2 instanceof IEventTask) && 69 (((IEventTask) task1).getEventType() instanceof IInteraction) && 70 (((IEventTask) task2).getEventType() instanceof IInteraction)); 71 } 72 73 /* (non-Javadoc) 74 * @see NodeComparisonRule#areLexicallyEqual(ITask, ITask) 70 for (ITaskInstance instance : task1.getInstances()) { 71 if ((!(instance instanceof IEventTaskInstance)) || 72 (!(((IEventTaskInstance) instance).getEvent().getType() instanceof IInteraction))) 73 { 74 return false; 75 } 76 } 77 78 for (ITaskInstance instance : task2.getInstances()) { 79 if ((!(instance instanceof IEventTaskInstance)) || 80 (!(((IEventTaskInstance) instance).getEvent().getType() instanceof IInteraction))) 81 { 82 return false; 83 } 84 } 85 86 return true; 87 } 88 89 /* (non-Javadoc) 90 * @see TaskComparisonRule#areLexicallyEqual(ITask, ITask) 75 91 */ 76 92 @Override … … 81 97 82 98 /* (non-Javadoc) 83 * @see NodeComparisonRule#areSyntacticallyEqual(ITask, ITask)99 * @see TaskComparisonRule#areSyntacticallyEqual(ITask, ITask) 84 100 */ 85 101 @Override … … 90 106 91 107 /* (non-Javadoc) 92 * @see NodeComparisonRule#areSemanticallyEqual(ITask, ITask)108 * @see TaskComparisonRule#areSemanticallyEqual(ITask, ITask) 93 109 */ 94 110 @Override … … 99 115 100 116 /* (non-Javadoc) 101 * @see NodeComparisonRule#compare(ITask, ITask)117 * @see TaskComparisonRule#compare(ITask, ITask) 102 118 */ 103 119 @Override … … 106 122 } 107 123 108 /** 109 * 110 */ 111 private TaskEquality getEquality(ITask task1, ITask task2, TaskEquality requiredEqualityLevel) { 112 IEventTask eventTask1 = (IEventTask) task1; 113 IEventTask eventTask2 = (IEventTask) task2; 114 115 if (!eventTask1.getEventTarget().equals(eventTask2.getEventTarget())) { 124 /* (non-Javadoc) 125 * @see de.ugoe.cs.autoquest.tasktrees.taskequality.TaskComparisonRule#isApplicable(de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance, de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance) 126 */ 127 @Override 128 public boolean isApplicable(ITaskInstance instance1, ITaskInstance instance2) { 129 return 130 (instance1 instanceof IEventTaskInstance) && 131 (instance2 instanceof IEventTaskInstance) && 132 (((IEventTaskInstance) instance1).getEvent().getType() instanceof IInteraction) && 133 (((IEventTaskInstance) instance1).getEvent().getType() instanceof IInteraction); 134 } 135 136 /* (non-Javadoc) 137 * @see de.ugoe.cs.autoquest.tasktrees.taskequality.TaskComparisonRule#areLexicallyEqual(de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance, de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance) 138 */ 139 @Override 140 public boolean areLexicallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 141 TaskEquality equality = getEquality(instance1, instance2, TaskEquality.LEXICALLY_EQUAL); 142 return (equality != null) && (equality.isAtLeast(TaskEquality.LEXICALLY_EQUAL)); 143 } 144 145 /* (non-Javadoc) 146 * @see de.ugoe.cs.autoquest.tasktrees.taskequality.TaskComparisonRule#areSyntacticallyEqual(de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance, de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance) 147 */ 148 @Override 149 public boolean areSyntacticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 150 TaskEquality equality = getEquality(instance1, instance2, TaskEquality.SYNTACTICALLY_EQUAL); 151 return (equality != null) && (equality.isAtLeast(TaskEquality.SYNTACTICALLY_EQUAL)); 152 } 153 154 /* (non-Javadoc) 155 * @see de.ugoe.cs.autoquest.tasktrees.taskequality.TaskComparisonRule#areSemanticallyEqual(de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance, de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance) 156 */ 157 @Override 158 public boolean areSemanticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 159 TaskEquality equality = getEquality(instance1, instance2, TaskEquality.SEMANTICALLY_EQUAL); 160 return (equality != null) && (equality.isAtLeast(TaskEquality.SEMANTICALLY_EQUAL)); 161 } 162 163 /* (non-Javadoc) 164 * @see de.ugoe.cs.autoquest.tasktrees.taskequality.TaskComparisonRule#compare(de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance, de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance) 165 */ 166 @Override 167 public TaskEquality compare(ITaskInstance instance1, ITaskInstance instance2) { 168 return getEquality(instance1, instance2, null); 169 } 170 171 /** 172 * 173 */ 174 private TaskEquality getEquality(ITask task1, 175 ITask task2, 176 TaskEquality requiredEqualityLevel) 177 { 178 Collection<ITaskInstance> taskInstances1 = task1.getInstances(); 179 Collection<ITaskInstance> taskInstances2 = task2.getInstances(); 180 181 TaskEquality checkedEquality = 182 requiredEqualityLevel != null ? requiredEqualityLevel : TaskEquality.SEMANTICALLY_EQUAL; 183 184 TaskEquality commonDenominator = TaskEquality.LEXICALLY_EQUAL; 185 186 for (ITaskInstance instance1 : taskInstances1) { 187 TaskEquality mostConcreteEquality = null; 188 189 for (ITaskInstance instance2 : taskInstances2) { 190 TaskEquality equality = getEquality(instance1, instance2, requiredEqualityLevel); 191 192 if ((equality != null) && ((mostConcreteEquality == null) || 193 (equality.isAtLeast(mostConcreteEquality)))) 194 { 195 mostConcreteEquality = equality; 196 197 if (((requiredEqualityLevel != null) && 198 (mostConcreteEquality.isAtLeast(requiredEqualityLevel))) || 199 (mostConcreteEquality.isAtLeast(TaskEquality.LEXICALLY_EQUAL))) 200 { 201 break; 202 } 203 } 204 } 205 206 commonDenominator = commonDenominator.getCommonDenominator(mostConcreteEquality); 207 208 if (!commonDenominator.isAtLeast(checkedEquality)) { 209 return TaskEquality.UNEQUAL; 210 } 211 } 212 213 return commonDenominator; 214 } 215 216 /** 217 * 218 */ 219 private TaskEquality getEquality(ITaskInstance instance1, 220 ITaskInstance instance2, 221 TaskEquality requiredEqualityLevel) 222 { 223 IEventTaskInstance eventTask1 = (IEventTaskInstance) instance1; 224 IEventTaskInstance eventTask2 = (IEventTaskInstance) instance2; 225 226 if (!eventTask1.getEvent().getTarget().equals(eventTask2.getEvent().getTarget())) { 116 227 return TaskEquality.UNEQUAL; 117 228 } 118 229 119 IInteraction interaction1 = (IInteraction) eventTask1.getEvent Type();120 IInteraction interaction2 = (IInteraction) eventTask2.getEvent Type();230 IInteraction interaction1 = (IInteraction) eventTask1.getEvent().getType(); 231 IInteraction interaction2 = (IInteraction) eventTask2.getEvent().getType(); 121 232 122 233 return compareInteractions 123 (interaction1, interaction2, eventTask1.getEvent Target(), requiredEqualityLevel);234 (interaction1, interaction2, eventTask1.getEvent().getTarget(), requiredEqualityLevel); 124 235 } 125 236 -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/IterationComparisonRule.java
r1190 r1294 15 15 package de.ugoe.cs.autoquest.tasktrees.taskequality; 16 16 17 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask;18 17 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 18 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIterationInstance; 19 19 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 20 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence;21 20 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 21 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 22 22 23 23 /** … … 82 82 83 83 /* (non-Javadoc) 84 * @see NodeComparisonRule#isApplicable(ITask, ITask)84 * @see TaskComparisonRule#isApplicable(ITask, ITask) 85 85 */ 86 86 @Override … … 90 90 91 91 /* (non-Javadoc) 92 * @see NodeComparisonRule#areLexicallyEqual(ITask, ITask)92 * @see TaskComparisonRule#areLexicallyEqual(ITask, ITask) 93 93 */ 94 94 @Override 95 95 public boolean areLexicallyEqual(ITask task1, ITask task2) { 96 ITask child1 = ((IIteration) task1).getMarkedTask();97 ITask child2 = ((IIteration) task2).getMarkedTask();98 99 if (child1 != null) {100 if (child2 == null) {101 return false;102 }103 else {104 // iterations may have 3 different structures.105 // 1. they have one child, which is the iterated one106 // 2. they have a sequence of children, which is iterated107 // 3. they have a selection of different iterated variants (usually the variants108 // are semantically equal)109 // check if the type of children match. If not, return false. If they match,110 // use the equality manager to perform further comparisons111 112 if (((child1 instanceof ISelection) && (child2 instanceof ISelection)) ||113 ((child1 instanceof ISequence) && (child2 instanceof ISequence)) ||114 ((child1 instanceof IEventTask) && (child2 instanceof IEventTask)))115 {116 return getNodeEquality117 (child1, child2).isAtLeast(TaskEquality.LEXICALLY_EQUAL);118 }119 }120 }121 else if (child2 == null) {122 return true;123 }124 125 return false;126 }127 128 /* (non-Javadoc)129 * @see NodeComparisonRule#areSyntacticallyEqual(ITask, ITask)130 */131 @Override132 public boolean areSyntacticallyEqual(ITask task1, ITask task2) {133 96 ITask child1 = ((IIteration) task1).getMarkedTask(); 134 97 ITask child2 = ((IIteration) task2).getMarkedTask(); … … 146 109 // ignore the type of the children but check them for equality. 147 110 148 return getNodeEquality(child1, child2).isAtLeast(TaskEquality. SYNTACTICALLY_EQUAL);111 return getNodeEquality(child1, child2).isAtLeast(TaskEquality.LEXICALLY_EQUAL); 149 112 } 150 113 } … … 157 120 158 121 /* (non-Javadoc) 159 * @see NodeComparisonRule#areSemanticallyEqual(ITask, ITask) 122 * @see TaskComparisonRule#areSyntacticallyEqual(ITask, ITask) 123 */ 124 @Override 125 public boolean areSyntacticallyEqual(ITask task1, ITask task2) { 126 return areLexicallyEqual(task1, task2); 127 } 128 129 /* (non-Javadoc) 130 * @see TaskComparisonRule#areSemanticallyEqual(ITask, ITask) 160 131 */ 161 132 @Override … … 165 136 166 137 /* (non-Javadoc) 167 * @see NodeComparisonRule#compare(ITask, ITask)138 * @see TaskComparisonRule#compare(ITask, ITask) 168 139 */ 169 140 @Override … … 203 174 // all other combinations (i.e. sequence with single child and sequence with selection) 204 175 // can not match 176 } 177 178 /* (non-Javadoc) 179 * @see TaskComparisonRule#isApplicable(ITaskInstance, ITaskInstance) 180 */ 181 @Override 182 public boolean isApplicable(ITaskInstance instance1, ITaskInstance instance2) { 183 return isApplicable(instance1.getTask(), instance2.getTask()); 184 } 185 186 /* (non-Javadoc) 187 * @see TaskComparisonRule#areLexicallyEqual(ITaskInstance, ITaskInstance) 188 */ 189 @Override 190 public boolean areLexicallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 191 IIterationInstance iteration1 = (IIterationInstance) instance1; 192 IIterationInstance iteration2 = (IIterationInstance) instance2; 193 194 // if both sequences do not have children, they are equal although this doesn't make sense 195 if ((iteration1.size() == 0) && (iteration2.size() == 0)) { 196 return true; 197 } 198 199 if (iteration1.size() != iteration2.size()) { 200 return false; 201 } 202 203 for (int i = 0; i < iteration1.size(); i++) { 204 ITaskInstance child1 = iteration1.get(i); 205 ITaskInstance child2 = iteration2.get(i); 206 207 TaskEquality taskEquality = 208 callRuleManager(child1, child2, TaskEquality.LEXICALLY_EQUAL); 209 210 if ((taskEquality == null) || (taskEquality == TaskEquality.UNEQUAL)) { 211 return false; 212 } 213 } 214 215 return true; 216 } 217 218 /* (non-Javadoc) 219 * @see TaskComparisonRule#areSyntacticallyEqual(ITaskInstance, ITaskInstance) 220 */ 221 @Override 222 public boolean areSyntacticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 223 return areLexicallyEqual(instance1, instance2); 224 } 225 226 /* (non-Javadoc) 227 * @see TaskComparisonRule#areSemanticallyEqual(ITaskInstance, ITaskInstance) 228 */ 229 @Override 230 public boolean areSemanticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 231 return areLexicallyEqual(instance1, instance2); 232 } 233 234 /* (non-Javadoc) 235 * @see TaskComparisonRule#compare(ITaskInstance, ITaskInstance) 236 */ 237 @Override 238 public TaskEquality compare(ITaskInstance instance1, ITaskInstance instance2) { 239 if (areLexicallyEqual(instance1, instance2)) { 240 return TaskEquality.LEXICALLY_EQUAL; 241 } 242 else { 243 return TaskEquality.UNEQUAL; 244 } 205 245 } 206 246 … … 272 312 callRuleManager(task, child, commonDenominatorForAllComparisons); 273 313 274 if ((taskEquality == null) || (taskEquality == TaskEquality.UNEQUAL)) 275 { 314 if ((taskEquality == null) || (taskEquality == TaskEquality.UNEQUAL)) { 276 315 return TaskEquality.UNEQUAL; 277 316 } … … 314 353 } 315 354 } 355 356 /** 357 * <p> 358 * used to to call the task equality rule manager for the comparison of the two provided 359 * children. If no required equality level is provided, than the most concrete equality is 360 * returned. Otherwise, the required equality is returned as long as the children are equal 361 * on that level. 362 * </p> 363 * 364 * @param taskInstance1 the first task instance to be compared 365 * @param taskInstance2 the second task instance to be compared 366 * @param requiredEqualityLevel the equality level to be checked for 367 * 368 * @return the determined equality 369 */ 370 private TaskEquality callRuleManager(ITaskInstance taskInstance1, 371 ITaskInstance taskInstance2, 372 TaskEquality requiredEqualityLevel) 373 { 374 if (requiredEqualityLevel == null) { 375 return TaskEqualityRuleManager.getInstance().compare(taskInstance1, taskInstance2); 376 } 377 else if (TaskEqualityRuleManager.getInstance().areAtLeastEqual 378 (taskInstance1, taskInstance2, requiredEqualityLevel)) 379 { 380 return requiredEqualityLevel; 381 } 382 else { 383 return TaskEquality.UNEQUAL; 384 } 385 } 316 386 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/SelectionComparisonRule.java
r1190 r1294 18 18 19 19 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 20 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelectionInstance; 20 21 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 22 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 21 23 22 24 /** … … 39 41 40 42 /* (non-Javadoc) 41 * @see NodeComparisonRule#isApplicable(ITask, ITask)43 * @see TaskComparisonRule#isApplicable(ITask, ITask) 42 44 */ 43 45 @Override … … 47 49 48 50 /* (non-Javadoc) 49 * @see NodeComparisonRule#areLexicallyEqual(ITask, ITask)51 * @see TaskComparisonRule#areLexicallyEqual(ITask, ITask) 50 52 */ 51 53 @Override … … 56 58 57 59 /* (non-Javadoc) 58 * @see NodeComparisonRule#areSyntacticallyEqual(ITask, ITask)60 * @see TaskComparisonRule#areSyntacticallyEqual(ITask, ITask) 59 61 */ 60 62 @Override … … 65 67 66 68 /* (non-Javadoc) 67 * @see NodeComparisonRule#areSemanticallyEqual(ITask, ITask)69 * @see TaskComparisonRule#areSemanticallyEqual(ITask, ITask) 68 70 */ 69 71 @Override … … 74 76 75 77 /* (non-Javadoc) 76 * @see NodeComparisonRule#compare(ITask, ITask)78 * @see TaskComparisonRule#compare(ITask, ITask) 77 79 */ 78 80 @Override 79 81 public TaskEquality compare(ITask task1, ITask task2) { 80 82 return getEquality(task1, task2, null); 83 } 84 85 /* (non-Javadoc) 86 * @see TaskComparisonRule#isApplicable(ITaskInstance, ITaskInstance) 87 */ 88 @Override 89 public boolean isApplicable(ITaskInstance instance1, ITaskInstance instance2) { 90 return isApplicable(instance1.getTask(), instance2.getTask()); 91 } 92 93 /* (non-Javadoc) 94 * @see TaskComparisonRule#areLexicallyEqual(ITaskInstance, ITaskInstance) 95 */ 96 @Override 97 public boolean areLexicallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 98 TaskEquality equality = getEquality(instance1, instance2, TaskEquality.LEXICALLY_EQUAL); 99 return (equality != null) && (equality.isAtLeast(TaskEquality.LEXICALLY_EQUAL)); 100 } 101 102 /* (non-Javadoc) 103 * @see TaskComparisonRule#areSyntacticallyEqual(ITaskInstance, ITaskInstance) 104 */ 105 @Override 106 public boolean areSyntacticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 107 TaskEquality equality = getEquality(instance1, instance2, TaskEquality.SYNTACTICALLY_EQUAL); 108 return (equality != null) && (equality.isAtLeast(TaskEquality.SYNTACTICALLY_EQUAL)); 109 } 110 111 /* (non-Javadoc) 112 * @see TaskComparisonRule#areSemanticallyEqual(ITaskInstance, ITaskInstance) 113 */ 114 @Override 115 public boolean areSemanticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 116 TaskEquality equality = getEquality(instance1, instance2, TaskEquality.SEMANTICALLY_EQUAL); 117 return (equality != null) && (equality.isAtLeast(TaskEquality.SEMANTICALLY_EQUAL)); 118 } 119 120 /* (non-Javadoc) 121 * @see TaskComparisonRule#compare(ITaskInstance, ITaskInstance) 122 */ 123 @Override 124 public TaskEquality compare(ITaskInstance instance1, ITaskInstance instance2) { 125 return getEquality(instance1, instance2, null); 81 126 } 82 127 … … 107 152 } 108 153 109 TaskEquality selectionEquality;110 111 154 if (requiredEqualityLevel == null) { 112 155 // calculate the common equality level for all children of both selections. 113 156 // do it in both directions to ensure commutative comparison 114 selectionEquality = getCommonEqualityLevel(children1, children2); 115 if (selectionEquality != TaskEquality.UNEQUAL) { 116 return selectionEquality.getCommonDenominator 117 (getCommonEqualityLevel(children2, children1)); 118 } 119 else { 120 return TaskEquality.UNEQUAL; 121 } 157 return getMostConcreteEqualityLevel(children1, children2); 122 158 } 123 159 else { 124 160 // we are searching for a specific equality 125 if (checkEqualityLevel(children1, children2, requiredEqualityLevel) && 126 checkEqualityLevel(children2, children1, requiredEqualityLevel)) 127 { 161 if (checkEqualityLevel(children1, children2, requiredEqualityLevel)) { 128 162 return requiredEqualityLevel; 129 163 } … … 136 170 /** 137 171 * <p> 138 * determines the commonequality level for all tasks in the first list compared to all139 * tasks in the second list. I f for one task in the first list, there is no equal task in the140 * second list, the method return unequality.172 * determines the most concrete equality level for all tasks in the first list compared to all 173 * tasks in the second list. It is sufficient, if there is one task in one list for which there 174 * exist an equal task in the other list. 141 175 * </p> 142 176 * … … 144 178 * @param children2 the second list to be compared 145 179 * 146 * @return the common task equality identified for all tasks in the first list with respect to 147 * the second list 148 */ 149 private TaskEquality getCommonEqualityLevel(List<ITask> children1, List<ITask> children2) { 150 TaskEquality listEquality = TaskEquality.LEXICALLY_EQUAL; 151 180 * @return the most concrete task equality identified for all tasks in the first list with 181 * respect to the second list 182 */ 183 private TaskEquality getMostConcreteEqualityLevel(List<ITask> children1, List<ITask> children2) 184 { 152 185 TaskEquality childEquality; 153 186 TaskEquality currentEquality; … … 164 197 } 165 198 166 if (childEquality == TaskEquality.SEMANTICALLY_EQUAL) { 167 // as we calculate only the common denominator, we can break up here for 168 // the current child. We will not improve the denominator anymore 169 break; 199 if (childEquality.isAtLeast(TaskEquality.LEXICALLY_EQUAL)) { 200 // as we calculate the most concrete equality, we can break up here 201 return TaskEquality.LEXICALLY_EQUAL; 170 202 } 171 203 } 172 204 } 173 174 if (childEquality == null) { 175 // we did not find any child in the second list, that is equal to the searched 176 // child 177 return TaskEquality.UNEQUAL; 178 } 179 else { 180 listEquality = listEquality.getCommonDenominator(childEquality); 181 } 182 } 183 184 return listEquality; 185 } 186 187 /** 188 * <p> 189 * ensures for the two given lists, that for each task in the first list there is a task 205 } 206 207 // as the comparison should be commutative, we do not need to check, if in list 2 there is 208 // a child equal to one in list 1 209 return TaskEquality.UNEQUAL; 210 } 211 212 /** 213 * <p> 214 * ensures for the two given lists, that for at least one task in the first list there is a task 190 215 * in the second list being on the given level equal to the task in the first list. 191 216 * </p> … … 195 220 * @param requiredEqualityLevel the equality level to be checked for 196 221 * 197 * @return true if each task in the first list has an equal task in the second list when198 * considering the given equality level, false else.222 * @return true if there is a task in the first list that has an equal task in the second list 223 * when considering the given equality level, false else. 199 224 */ 200 225 private boolean checkEqualityLevel(List<ITask> children1, … … 202 227 TaskEquality requiredEqualityLevel) 203 228 { 204 TaskEquality childEquality;205 229 TaskEquality currentEquality; 206 230 for (ITask child1 : children1) { 207 childEquality = null;208 231 for (ITask child2 : children2) { 209 232 currentEquality = callRuleManager(child1, child2, requiredEqualityLevel); … … 212 235 // we found at least one equal child with sufficient equality in the 213 236 // second list. So be can break up for this child. 214 childEquality = currentEquality; 215 break; 237 return true; 216 238 } 217 239 } 218 219 if (childEquality == null) { 220 // we did not find any child in the second list, that is equal to the searched 221 // child 222 return false; 223 } 224 } 225 226 // for all children, we found an equality 227 return true; 240 } 241 242 return false; 228 243 } 229 244 … … 259 274 } 260 275 276 /** 277 * <p> 278 * compares two selection instances with each other checking for the provided required level of 279 * equality. If this level is ensured, the method immediately returns. The more concrete 280 * the required equality level, the more checks this method performs. 281 * </p> 282 * 283 * @param taskInstance1 the first task instance to be compared 284 * @param taskInstance2 the second task instance to be compared 285 * @param requiredEqualityLevel the equality level to be checked for 286 * 287 * @return the determined equality. 288 */ 289 private TaskEquality getEquality(ITaskInstance taskInstance1, 290 ITaskInstance taskInstance2, 291 TaskEquality requiredEqualityLevel) 292 { 293 ITaskInstance child1 = ((ISelectionInstance) taskInstance1).getChild(); 294 ITaskInstance child2 = ((ISelectionInstance) taskInstance2).getChild(); 295 296 // if both selections do not have children, they are lexically equal. If only one of them 297 // has children, they are unequal. 298 if ((child1 == null) && (child2 == null)) { 299 return TaskEquality.LEXICALLY_EQUAL; 300 } 301 else if ((child1 == null) || (child2 == null)) { 302 return TaskEquality.UNEQUAL; 303 } 304 305 TaskEquality equality = callRuleManager(child1, child2, requiredEqualityLevel); 306 307 if (equality == TaskEquality.IDENTICAL) { 308 // two different selection instances can be at most lexically equal even if their 309 // children are identical 310 return TaskEquality.LEXICALLY_EQUAL; 311 } 312 else { 313 return equality; 314 } 315 } 316 317 /** 318 * <p> 319 * used to to call the task equality rule manager for the comparison of the two provided 320 * children. If no required equality level is provided, than the most concrete equality is 321 * returned. Otherwise, the required equality is returned as long as the children are equal 322 * on that level. 323 * </p> 324 * 325 * @param taskInstance1 the first task instance to be compared 326 * @param taskInstance2 the second task instance to be compared 327 * @param requiredEqualityLevel the equality level to be checked for 328 * 329 * @return the determined equality 330 */ 331 private TaskEquality callRuleManager(ITaskInstance taskInstance1, 332 ITaskInstance taskInstance2, 333 TaskEquality requiredEqualityLevel) 334 { 335 if (requiredEqualityLevel == null) { 336 return TaskEqualityRuleManager.getInstance().compare(taskInstance1, taskInstance2); 337 } 338 else if (TaskEqualityRuleManager.getInstance().areAtLeastEqual 339 (taskInstance1, taskInstance2, requiredEqualityLevel)) 340 { 341 return requiredEqualityLevel; 342 } 343 else { 344 return TaskEquality.UNEQUAL; 345 } 346 } 261 347 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/SequenceComparisonRule.java
r1190 r1294 18 18 19 19 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 20 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequenceInstance; 20 21 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 22 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 21 23 22 24 /** … … 34 36 35 37 /* (non-Javadoc) 36 * @see NodeComparisonRule#isApplicable(ITask, ITask)38 * @see TaskComparisonRule#isApplicable(ITask, ITask) 37 39 */ 38 40 @Override … … 42 44 43 45 /* (non-Javadoc) 44 * @see NodeComparisonRule#areLexicallyEqual(ITask, ITask)46 * @see TaskComparisonRule#areLexicallyEqual(ITask, ITask) 45 47 */ 46 48 @Override … … 51 53 52 54 /* (non-Javadoc) 53 * @see NodeComparisonRule#areSyntacticallyEqual(ITask, ITask)55 * @see TaskComparisonRule#areSyntacticallyEqual(ITask, ITask) 54 56 */ 55 57 @Override … … 60 62 61 63 /* (non-Javadoc) 62 * @see NodeComparisonRule#areSemanticallyEqual(ITask, ITask)64 * @see TaskComparisonRule#areSemanticallyEqual(ITask, ITask) 63 65 */ 64 66 @Override … … 69 71 70 72 /* (non-Javadoc) 71 * @see NodeComparisonRule#compare(ITask, ITask)73 * @see TaskComparisonRule#compare(ITask, ITask) 72 74 */ 73 75 @Override 74 76 public TaskEquality compare(ITask task1, ITask task2) { 75 77 return getEquality(task1, task2, null); 78 } 79 80 /* (non-Javadoc) 81 * @see TaskComparisonRule#isApplicable(ITaskInstance, ITaskInstance) 82 */ 83 @Override 84 public boolean isApplicable(ITaskInstance instance1, ITaskInstance instance2) { 85 return isApplicable(instance1.getTask(), instance2.getTask()); 86 } 87 88 /* (non-Javadoc) 89 * @see TaskComparisonRule#areLexicallyEqual(ITaskInstance, ITaskInstance) 90 */ 91 @Override 92 public boolean areLexicallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 93 TaskEquality equality = getEquality(instance1, instance2, TaskEquality.LEXICALLY_EQUAL); 94 return (equality != null) && (equality.isAtLeast(TaskEquality.LEXICALLY_EQUAL)); 95 } 96 97 /* (non-Javadoc) 98 * @see TaskComparisonRule#areSyntacticallyEqual(ITaskInstance, ITaskInstance) 99 */ 100 @Override 101 public boolean areSyntacticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 102 TaskEquality equality = getEquality(instance1, instance2, TaskEquality.SYNTACTICALLY_EQUAL); 103 return (equality != null) && (equality.isAtLeast(TaskEquality.SYNTACTICALLY_EQUAL)); 104 } 105 106 /* (non-Javadoc) 107 * @see TaskComparisonRule#areSemanticallyEqual(ITaskInstance, ITaskInstance) 108 */ 109 @Override 110 public boolean areSemanticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 111 TaskEquality equality = getEquality(instance1, instance2, TaskEquality.SEMANTICALLY_EQUAL); 112 return (equality != null) && (equality.isAtLeast(TaskEquality.SEMANTICALLY_EQUAL)); 113 } 114 115 /* (non-Javadoc) 116 * @see TaskComparisonRule#compare(ITaskInstance, ITaskInstance) 117 */ 118 @Override 119 public TaskEquality compare(ITaskInstance instance1, ITaskInstance instance2) { 120 return getEquality(instance1, instance2, null); 76 121 } 77 122 … … 149 194 } 150 195 } 196 197 /** 198 * <p> 199 * compares two sequence instances with each other checking for the provided required level of 200 * equality. If this level is ensured, the method immediately returns. The more concrete 201 * the required equality level, the more checks this method performs. 202 * </p> 203 * 204 * @param taskInstance1 the first task instance to be compared 205 * @param taskInstance2 the second task instance to be compared 206 * @param requiredEqualityLevel the equality level to be checked for 207 * 208 * @return the determined equality. 209 */ 210 private TaskEquality getEquality(ITaskInstance taskInstance1, 211 ITaskInstance taskInstance2, 212 TaskEquality requiredEqualityLevel) 213 { 214 ISequenceInstance sequence1 = (ISequenceInstance) taskInstance1; 215 ISequenceInstance sequence2 = (ISequenceInstance) taskInstance2; 216 217 // if both sequences do not have children, they are equal although this doesn't make sense 218 if ((sequence1.size() == 0) && (sequence2.size() == 0)) { 219 return TaskEquality.LEXICALLY_EQUAL; 220 } 221 222 if (sequence1.size() != sequence2.size()) { 223 return TaskEquality.UNEQUAL; 224 } 225 226 TaskEquality resultingEquality = TaskEquality.LEXICALLY_EQUAL; 227 for (int i = 0; i < sequence1.size(); i++) { 228 ITaskInstance child1 = sequence1.get(i); 229 ITaskInstance child2 = sequence2.get(i); 230 231 TaskEquality taskEquality = callRuleManager(child1, child2, requiredEqualityLevel); 232 233 if ((taskEquality == null) || (taskEquality == TaskEquality.UNEQUAL)) { 234 return TaskEquality.UNEQUAL; 235 } 236 237 resultingEquality = resultingEquality.getCommonDenominator(taskEquality); 238 } 239 240 return resultingEquality; 241 } 242 243 /** 244 * <p> 245 * used to to call the task equality rule manager for the comparison of the two provided 246 * children. If no required equality level is provided, than the most concrete equality is 247 * returned. Otherwise, the required equality is returned as long as the children are equal 248 * on that level. 249 * </p> 250 * 251 * @param taskInstance1 the first task instance to be compared 252 * @param taskInstance2 the second task instance to be compared 253 * @param requiredEqualityLevel the equality level to be checked for 254 * 255 * @return the determined equality 256 */ 257 private TaskEquality callRuleManager(ITaskInstance taskInstance1, 258 ITaskInstance taskInstance2, 259 TaskEquality requiredEqualityLevel) 260 { 261 if (requiredEqualityLevel == null) { 262 return TaskEqualityRuleManager.getInstance().compare(taskInstance1, taskInstance2); 263 } 264 else if (TaskEqualityRuleManager.getInstance().areAtLeastEqual 265 (taskInstance1, taskInstance2, requiredEqualityLevel)) 266 { 267 return requiredEqualityLevel; 268 } 269 else { 270 return TaskEquality.UNEQUAL; 271 } 272 } 151 273 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/TaskAndIterationComparisonRule.java
r1190 r1294 16 16 17 17 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 18 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIterationInstance; 18 19 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 20 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 19 21 20 22 /** … … 33 35 34 36 /* (non-Javadoc) 35 * @see NodeComparisonRule#isApplicable(ITask, ITask)37 * @see TaskComparisonRule#isApplicable(ITask, ITask) 36 38 */ 37 39 @Override … … 42 44 43 45 /* (non-Javadoc) 44 * @see NodeComparisonRule#areLexicallyEqual(ITask, ITask)46 * @see TaskComparisonRule#areLexicallyEqual(ITask, ITask) 45 47 */ 46 48 @Override … … 51 53 52 54 /* (non-Javadoc) 53 * @see NodeComparisonRule#areSyntacticallyEqual(ITask, ITask)55 * @see TaskComparisonRule#areSyntacticallyEqual(ITask, ITask) 54 56 */ 55 57 @Override … … 60 62 61 63 /* (non-Javadoc) 62 * @see NodeComparisonRule#areSemanticallyEqual(ITask, ITask)64 * @see TaskComparisonRule#areSemanticallyEqual(ITask, ITask) 63 65 */ 64 66 @Override … … 69 71 70 72 /* (non-Javadoc) 71 * @see NodeComparisonRule#compare(ITask, ITask)73 * @see TaskComparisonRule#compare(ITask, ITask) 72 74 */ 73 75 @Override 74 76 public TaskEquality compare(ITask task1, ITask task2) { 75 77 return getEquality(task1, task2, null); 78 } 79 80 /* (non-Javadoc) 81 * @see TaskComparisonRule#isApplicable(ITaskInstance, ITaskInstance) 82 */ 83 @Override 84 public boolean isApplicable(ITaskInstance instance1, ITaskInstance instance2) { 85 return isApplicable(instance1.getTask(), instance2.getTask()); 86 } 87 88 /* (non-Javadoc) 89 * @see TaskComparisonRule#areLexicallyEqual(ITaskInstance, ITaskInstance) 90 */ 91 @Override 92 public boolean areLexicallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 93 TaskEquality equality = getEquality(instance1, instance2, TaskEquality.LEXICALLY_EQUAL); 94 return (equality != null) && (equality.isAtLeast(TaskEquality.LEXICALLY_EQUAL)); 95 } 96 97 /* (non-Javadoc) 98 * @see TaskComparisonRule#areSyntacticallyEqual(ITaskInstance, ITaskInstance) 99 */ 100 @Override 101 public boolean areSyntacticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 102 TaskEquality equality = getEquality(instance1, instance2, TaskEquality.SYNTACTICALLY_EQUAL); 103 return (equality != null) && (equality.isAtLeast(TaskEquality.SYNTACTICALLY_EQUAL)); 104 } 105 106 /* (non-Javadoc) 107 * @see TaskComparisonRule#areSemanticallyEqual(ITaskInstance, ITaskInstance) 108 */ 109 @Override 110 public boolean areSemanticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 111 TaskEquality equality = getEquality(instance1, instance2, TaskEquality.SEMANTICALLY_EQUAL); 112 return (equality != null) && (equality.isAtLeast(TaskEquality.SEMANTICALLY_EQUAL)); 113 } 114 115 /* (non-Javadoc) 116 * @see TaskComparisonRule#compare(ITaskInstance, ITaskInstance) 117 */ 118 @Override 119 public TaskEquality compare(ITaskInstance instance1, ITaskInstance instance2) { 120 return getEquality(instance1, instance2, null); 76 121 } 77 122 … … 167 212 } 168 213 } 214 215 /** 216 * <p> 217 * compares two task instances with each other checking for the provided required level of 218 * equality. One of the task instances must be a iteration, the other one not. If this is not 219 * the case, the method returns null. The returned equality level is at most lexical equality 220 * as the iteration can not be identical to something not being a iteration. 221 * </p> 222 * 223 * @param taskInstance1 the first task instance to be compared 224 * @param taskInstance2 the second task instance to be compared 225 * @param requiredEqualityLevel the equality level to be checked for 226 * 227 * @return the determined equality. 228 */ 229 private TaskEquality getEquality(ITaskInstance taskInstance1, 230 ITaskInstance taskInstance2, 231 TaskEquality requiredEqualityLevel) 232 { 233 IIterationInstance iteration = null; 234 ITaskInstance task = null; 235 236 if (taskInstance1 instanceof IIterationInstance) { 237 if (taskInstance2 instanceof IIterationInstance) { 238 // the rule is not responsible for two iterations 239 return null; 240 } 241 242 iteration = (IIterationInstance) taskInstance1; 243 task = taskInstance2; 244 } 245 else if (taskInstance2 instanceof IIterationInstance) { 246 if (taskInstance1 instanceof IIterationInstance) { 247 // the rule is not responsible for two iterations 248 return null; 249 } 250 251 iteration = (IIterationInstance) taskInstance2; 252 task = taskInstance1; 253 } 254 else { 255 return null; 256 } 257 258 // now, that we found the iteration and the task, lets compare the children of the iteration 259 // with the task. 260 261 if (iteration.size() < 1) { 262 return null; 263 } 264 265 TaskEquality mostConcreteNodeEquality = null; 266 267 for (ITaskInstance child : iteration) { 268 TaskEquality taskEquality = callRuleManager(child, task, requiredEqualityLevel); 269 270 if (taskEquality != TaskEquality.UNEQUAL) { 271 if (mostConcreteNodeEquality == null) { 272 mostConcreteNodeEquality = taskEquality; 273 } 274 else if (mostConcreteNodeEquality.isAtLeast(taskEquality)) { 275 mostConcreteNodeEquality = taskEquality; 276 277 } 278 279 if ((requiredEqualityLevel != null) && 280 (mostConcreteNodeEquality.isAtLeast(requiredEqualityLevel))) 281 { 282 // if we found one child of the selection that is as equal as required, then 283 // we can consider the selection to be sufficiently equal to the other task. 284 // So we break up checking further children. 285 break; 286 } 287 } 288 } 289 290 // although the subtask may be identical to the task, we can not return identical, as 291 // the selection is not identical to the task, but at most lexically equal 292 if (mostConcreteNodeEquality == TaskEquality.IDENTICAL) { 293 return TaskEquality.LEXICALLY_EQUAL; 294 } 295 else { 296 return mostConcreteNodeEquality; 297 } 298 299 } 300 301 /** 302 * <p> 303 * used to to call the task equality rule manager for the comparison of the two provided 304 * children. If no required equality level is provided, than the most concrete equality is 305 * returned. Otherwise, the required equality is returned as long as the children are equal 306 * on that level. 307 * </p> 308 * 309 * @param taskInstance1 the first task instance to be compared 310 * @param taskInstance2 the second task instance to be compared 311 * @param requiredEqualityLevel the equality level to be checked for 312 * 313 * @return the determined equality 314 */ 315 private TaskEquality callRuleManager(ITaskInstance taskInstance1, 316 ITaskInstance taskInstance2, 317 TaskEquality requiredEqualityLevel) 318 { 319 if (requiredEqualityLevel == null) { 320 return TaskEqualityRuleManager.getInstance().compare(taskInstance1, taskInstance2); 321 } 322 else if (TaskEqualityRuleManager.getInstance().areAtLeastEqual 323 (taskInstance1, taskInstance2, requiredEqualityLevel)) 324 { 325 return requiredEqualityLevel; 326 } 327 else { 328 return TaskEquality.UNEQUAL; 329 } 330 } 169 331 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/TaskAndSelectionComparisonRule.java
r1190 r1294 18 18 19 19 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 20 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelectionInstance; 20 21 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 22 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 21 23 22 24 /** … … 34 36 35 37 /* (non-Javadoc) 36 * @see NodeComparisonRule#isApplicable(ITask, ITask)38 * @see TaskComparisonRule#isApplicable(ITask, ITask) 37 39 */ 38 40 @Override … … 43 45 44 46 /* (non-Javadoc) 45 * @see NodeComparisonRule#areLexicallyEqual(ITask, ITask)47 * @see TaskComparisonRule#areLexicallyEqual(ITask, ITask) 46 48 */ 47 49 @Override … … 52 54 53 55 /* (non-Javadoc) 54 * @see NodeComparisonRule#areSyntacticallyEqual(ITask, ITask)56 * @see TaskComparisonRule#areSyntacticallyEqual(ITask, ITask) 55 57 */ 56 58 @Override … … 61 63 62 64 /* (non-Javadoc) 63 * @see NodeComparisonRule#areSemanticallyEqual(ITask, ITask)65 * @see TaskComparisonRule#areSemanticallyEqual(ITask, ITask) 64 66 */ 65 67 @Override … … 70 72 71 73 /* (non-Javadoc) 72 * @see NodeComparisonRule#compare(ITask, ITask)74 * @see TaskComparisonRule#compare(ITask, ITask) 73 75 */ 74 76 @Override … … 77 79 } 78 80 81 /* (non-Javadoc) 82 * @see TaskComparisonRule#isApplicable(ITaskInstance, ITaskInstance) 83 */ 84 @Override 85 public boolean isApplicable(ITaskInstance instance1, ITaskInstance instance2) { 86 return isApplicable(instance1.getTask(), instance2.getTask()); 87 } 88 89 /* (non-Javadoc) 90 * @see TaskComparisonRule#areLexicallyEqual(ITaskInstance, ITaskInstance) 91 */ 92 @Override 93 public boolean areLexicallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 94 TaskEquality equality = getEquality(instance1, instance2, TaskEquality.LEXICALLY_EQUAL); 95 return (equality != null) && (equality.isAtLeast(TaskEquality.LEXICALLY_EQUAL)); 96 } 97 98 /* (non-Javadoc) 99 * @see TaskComparisonRule#areSyntacticallyEqual(ITaskInstance, ITaskInstance) 100 */ 101 @Override 102 public boolean areSyntacticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 103 TaskEquality equality = getEquality(instance1, instance2, TaskEquality.SYNTACTICALLY_EQUAL); 104 return (equality != null) && (equality.isAtLeast(TaskEquality.SYNTACTICALLY_EQUAL)); 105 } 106 107 /* (non-Javadoc) 108 * @see TaskComparisonRule#areSemanticallyEqual(ITaskInstance, ITaskInstance) 109 */ 110 @Override 111 public boolean areSemanticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 112 TaskEquality equality = getEquality(instance1, instance2, TaskEquality.SEMANTICALLY_EQUAL); 113 return (equality != null) && (equality.isAtLeast(TaskEquality.SEMANTICALLY_EQUAL)); 114 } 115 116 /* (non-Javadoc) 117 * @see TaskComparisonRule#compare(ITaskInstance, ITaskInstance) 118 */ 119 @Override 120 public TaskEquality compare(ITaskInstance instance1, ITaskInstance instance2) { 121 return getEquality(instance1, instance2, null); 122 } 123 79 124 /** 80 125 * <p> … … 191 236 } 192 237 } 238 239 /** 240 * <p> 241 * compares two task instances with each other checking for the provided required level of 242 * equality. One of the task instances must be a selection, the other one not. If this is not 243 * the case, the method returns null. The returned equality level is at most lexical equality 244 * as the selection can not be identical to something not being a selection. 245 * </p> 246 * 247 * @param taskInstance1 the first task instance to be compared 248 * @param taskInstance2 the second task instance to be compared 249 * @param requiredEqualityLevel the equality level to be checked for 250 * 251 * @return the determined equality. 252 */ 253 private TaskEquality getEquality(ITaskInstance taskInstance1, 254 ITaskInstance taskInstance2, 255 TaskEquality requiredEqualityLevel) 256 { 257 ISelectionInstance selection = null; 258 ITaskInstance task = null; 259 260 if (taskInstance1 instanceof ISelectionInstance) { 261 if (taskInstance2 instanceof ISelectionInstance) { 262 // the rule is not responsible for two selections 263 return null; 264 } 265 266 selection = (ISelectionInstance) taskInstance1; 267 task = taskInstance2; 268 } 269 else if (taskInstance2 instanceof ISelectionInstance) { 270 if (taskInstance1 instanceof ISelectionInstance) { 271 // the rule is not responsible for two selections 272 return null; 273 } 274 275 selection = (ISelectionInstance) taskInstance2; 276 task = taskInstance1; 277 } 278 else { 279 return null; 280 } 281 282 // now, that we found the selection and the task, lets compare the child of the selection 283 // with the task. 284 ITaskInstance child = selection.getChild(); 285 286 if (child == null) { 287 return null; 288 } 289 290 TaskEquality taskEquality = callRuleManager(child, task, requiredEqualityLevel); 291 292 // although the subtask may be identical to the task, we can not return identical, as 293 // the selection is not identical to the task, but at most lexically equal 294 if (taskEquality == TaskEquality.IDENTICAL) { 295 return TaskEquality.LEXICALLY_EQUAL; 296 } 297 else { 298 return taskEquality; 299 } 300 301 } 302 303 /** 304 * <p> 305 * used to to call the task equality rule manager for the comparison of the two provided 306 * children. If no required equality level is provided, than the most concrete equality is 307 * returned. Otherwise, the required equality is returned as long as the children are equal 308 * on that level. 309 * </p> 310 * 311 * @param taskInstance1 the first task instance to be compared 312 * @param taskInstance2 the second task instance to be compared 313 * @param requiredEqualityLevel the equality level to be checked for 314 * 315 * @return the determined equality 316 */ 317 private TaskEquality callRuleManager(ITaskInstance taskInstance1, 318 ITaskInstance taskInstance2, 319 TaskEquality requiredEqualityLevel) 320 { 321 if (requiredEqualityLevel == null) { 322 return TaskEqualityRuleManager.getInstance().compare(taskInstance1, taskInstance2); 323 } 324 else if (TaskEqualityRuleManager.getInstance().areAtLeastEqual 325 (taskInstance1, taskInstance2, requiredEqualityLevel)) 326 { 327 return requiredEqualityLevel; 328 } 329 else { 330 return TaskEquality.UNEQUAL; 331 } 332 } 193 333 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/TaskComparisonRule.java
r1146 r1294 16 16 17 17 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 18 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 18 19 19 20 /** 20 21 * <p> 21 * A task comparison rule is used by the {@link TaskEqualityRuleManager} to compare tasks with22 * each other. It provides several methods to be called for a comparison.22 * A task comparison rule is used by the {@link TaskEqualityRuleManager} to compare tasks and 23 * task instances with each other. It provides several methods to be called for a comparison. 23 24 * </p> 24 25 * … … 90 91 public TaskEquality compare(ITask task1, ITask task2); 91 92 93 /** 94 * <p> 95 * checks if the rule is applicable for comparing the two provided task instances 96 * </p> 97 * 98 * @param instance1 the first task instance to compare 99 * @param instance2 the second task instance to compare 100 * 101 * @return true, if the rule is applicable, false else 102 */ 103 public boolean isApplicable(ITaskInstance instance1, ITaskInstance instance2); 104 105 /** 106 * <p> 107 * checks, if the provided task instances are lexically equal 108 * </p> 109 * 110 * @param instance1 the first task instance to compare 111 * @param instance2 the second task instance to compare 112 * 113 * @return true, if the tasks are equal, false else 114 */ 115 public boolean areLexicallyEqual(ITaskInstance instance1, ITaskInstance instance2); 116 117 /** 118 * <p> 119 * checks, if the provided task instances are syntactically equal 120 * </p> 121 * 122 * @param instance1 the first task instance to compare 123 * @param instance2 the second task instance to compare 124 * 125 * @return true, if the tasks are equal, false else 126 */ 127 public boolean areSyntacticallyEqual(ITaskInstance instance1, ITaskInstance instance2); 128 129 /** 130 * <p> 131 * checks, if the provided task instances are semantically equal 132 * </p> 133 * 134 * @param instance1 the first task instance to compare 135 * @param instance2 the second task instance to compare 136 * 137 * @return true, if the tasks are equal, false else 138 */ 139 public boolean areSemanticallyEqual(ITaskInstance instance1, ITaskInstance instance2); 140 141 /** 142 * <p> 143 * compares two task instances with each other. The result of the method is either a task 144 * instance equality or null. If it is null, it means, that the rule is not able to correctly 145 * compare the two given task instances 146 * </p> 147 * 148 * @param instance1 the first task instance to compare 149 * @param instance2 the second task instance to compare 150 * 151 * @return as described 152 */ 153 public TaskEquality compare(ITaskInstance instance1, ITaskInstance instance2); 154 92 155 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/TaskEqualityRuleManager.java
r1190 r1294 19 19 20 20 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 21 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 21 22 22 23 /** 23 24 * <p> 24 * The task equality rule manager is capable of comparing tasks based on its internal list25 * of comparison rules. These rules are asked for comparing the two provided tasks. If a rule26 * returns a task equality other than null, this equality is returned. Otherwise the next rule27 * is asked.25 * The task equality rule manager is capable of comparing tasks and task instances based on its 26 * internal list of comparison rules. These rules are asked for comparing the two provided tasks or 27 * task instance. If a rule returns a task equality other than null, this equality is returned. 28 * Otherwise the next rule is asked. 28 29 * </p> 29 30 * 30 * @version $Revision: $ $Date: 19.02.2012$ 31 * @author 2012, last modified by $Author: patrick$ 31 * @author Patrick Harms 32 32 */ 33 33 public class TaskEqualityRuleManager { … … 269 269 } 270 270 271 /** 272 * <p> 273 * this method performs a comparison of the two provided task instances. It iterates its 274 * internal comparison rules. If the first rule returns a task instance equality other than 275 * null, this equality is returned. Otherwise the next rule is tried. If no rule returns an 276 * equality <code>TaskEquality.UNEQUAL</code> is returned. 277 * </p> 278 * 279 * @param instance1 the first task instance to be compared 280 * @param instance2 the second task instance to be compared 281 * 282 * @return as described 283 * 284 * @throws IllegalStateException in the case, the {@link #init()} method was not called on the 285 * manager before a call to this method. 286 */ 287 public TaskEquality compare(ITaskInstance instance1, ITaskInstance instance2) 288 throws IllegalStateException 289 { 290 if (mRuleIndex == null) { 291 throw new IllegalStateException("not initialized"); 292 } 293 294 // LOG.info("checking for equality of " + instance1 + " and " + instance2); 295 TaskEquality instanceEquality = null; 296 297 for (TaskComparisonRule rule : mRuleIndex) { 298 if (rule.isApplicable(instance1, instance2)) { 299 instanceEquality = rule.compare(instance1, instance2); 300 if (instanceEquality != null) { 301 // LOG.warning("used rule " + rule + " for equality check"); 302 return instanceEquality; 303 } 304 } 305 } 306 307 // LOG.warning("no rule could be applied --> handling tasks as unequal"); 308 309 return TaskEquality.UNEQUAL; 310 } 311 312 /** 313 * <p> 314 * this method compares two task instances with respect to the given equality level and returns 315 * true, if this level is given. 316 * </p> 317 * 318 * @param instance1 the first task instance to be compared 319 * @param instance2 the second task instance to be compared 320 * @param equalityLevel the level of equality to be checked for 321 * 322 * @return as described 323 * 324 * @throws IllegalStateException in the case, the {@link #init()} method was not called on the 325 * manager before a call to this method. 326 */ 327 public boolean areAtLeastEqual(ITaskInstance instance1, 328 ITaskInstance instance2, 329 TaskEquality equalityLevel) 330 { 331 if (equalityLevel == null) { 332 throw new IllegalArgumentException("required equality level must not be null"); 333 } 334 335 switch (equalityLevel) { 336 case IDENTICAL: 337 return areIdentical(instance1, instance2); 338 case LEXICALLY_EQUAL: 339 return areLexicallyEqual(instance1, instance2); 340 case SYNTACTICALLY_EQUAL: 341 return areSyntacticallyEqual(instance1, instance2); 342 case SEMANTICALLY_EQUAL: 343 return areSemanticallyEqual(instance1, instance2); 344 case UNEQUAL: 345 return !areSemanticallyEqual(instance1, instance2); 346 default: 347 throw new IllegalArgumentException("unknown required equality: " + equalityLevel); 348 } 349 } 350 351 /** 352 * <p> 353 * this method checks if the two given task instances are identical. For this, it iterates its 354 * internal comparison rules. If the first rule returns true, than this method returns true 355 * as well. If no rule returns true, this method returns false. 356 * </p> 357 * 358 * @param instance1 the first task instance to be compared 359 * @param instance2 the second task instance to be compared 360 * 361 * @return as described 362 * 363 * @throws IllegalStateException in the case, the {@link #init()} method was not called on the 364 * manager before a call to this method. 365 */ 366 public boolean areIdentical(ITaskInstance instance1, ITaskInstance instance2) { 367 if (mRuleIndex == null) { 368 throw new IllegalStateException("not initialized"); 369 } 370 371 for (TaskComparisonRule rule : mRuleIndex) { 372 if (rule.isApplicable(instance1, instance2) && 373 rule.areLexicallyEqual(instance1, instance2)) 374 { 375 return true; 376 } 377 } 378 379 return false; 380 } 381 382 /** 383 * <p> 384 * this method checks if the two given task instances are lexically equal. For this, it 385 * iterates its internal comparison rules. If the first rule returns true, than this method 386 * returns true, as well. If no rule returns true, this method returns false. 387 * </p> 388 * 389 * @param instance1 the first task instance to be compared 390 * @param instance2 the second task instance to be compared 391 * 392 * @return as described 393 * 394 * @throws IllegalStateException in the case, the {@link #init()} method was not called on the 395 * manager before a call to this method. 396 */ 397 public boolean areLexicallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 398 if (mRuleIndex == null) { 399 throw new IllegalStateException("not initialized"); 400 } 401 402 for (TaskComparisonRule rule : mRuleIndex) { 403 if (rule.isApplicable(instance1, instance2) && 404 rule.areLexicallyEqual(instance1, instance2)) 405 { 406 return true; 407 } 408 } 409 410 return false; 411 } 412 413 /** 414 * <p> 415 * this method checks if the two given task instances are syntactically equal. For this, it 416 * iterates its internal comparison rules. If the first rule returns true, than this method 417 * returns true, as well. If no rule returns true, this method returns false. 418 * </p> 419 * 420 * @param instance1 the first task instance to be compared 421 * @param instance2 the second task instance to be compared 422 * 423 * @return as described 424 * 425 * @throws IllegalStateException in the case, the {@link #init()} method was not called on the 426 * manager before a call to this method. 427 */ 428 public boolean areSyntacticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 429 if (mRuleIndex == null) { 430 throw new IllegalStateException("not initialized"); 431 } 432 433 for (TaskComparisonRule rule : mRuleIndex) { 434 if (rule.isApplicable(instance1, instance2) && 435 rule.areSyntacticallyEqual(instance1, instance2)) 436 { 437 return true; 438 } 439 } 440 441 return false; 442 } 443 444 /** 445 * <p> 446 * this method checks if the two given task instances are semantically equal. For this, it 447 * iterates its internal comparison rules. If the first rule returns true, than this method 448 * returns true, as well. If no rule returns true, this method returns false. 449 * </p> 450 * 451 * @param instance1 the first task instance to be compared 452 * @param instance2 the second task instance to be compared 453 * 454 * @return as described 455 * 456 * @throws IllegalStateException in the case, the {@link #init()} method was not called on the 457 * manager before a call to this method. 458 */ 459 public boolean areSemanticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 460 if (mRuleIndex == null) { 461 throw new IllegalStateException("not initialized"); 462 } 463 464 for (TaskComparisonRule rule : mRuleIndex) { 465 if (rule.isApplicable(instance1, instance2) && 466 rule.areSemanticallyEqual(instance1, instance2)) 467 { 468 return true; 469 } 470 } 471 472 return false; 473 } 474 271 475 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/TaskIdentityRule.java
r1146 r1294 16 16 17 17 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 18 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 18 19 19 20 /** 20 21 * <p> 21 22 * This comparison rule returns <code>TaskEquality.IDENTICAL</code> if the comparison of the two 22 * tasks using the <code>==</code> operator or the <code>equals</code> method return true.23 * Else it returns null to denote, thatit can not compare the tasks.23 * tasks using the <code>==</code> operator returns true. Else it returns null to denote, that 24 * it can not compare the tasks. 24 25 * </p> 25 26 * … … 30 31 31 32 /* (non-Javadoc) 32 * @see NodeComparisonRule#isApplicable(ITask, ITask)33 * @see TaskComparisonRule#isApplicable(ITask, ITask) 33 34 */ 34 35 @Override … … 38 39 39 40 /* (non-Javadoc) 40 * @see NodeComparisonRule#areLexicallyEqual(ITask, ITask)41 * @see TaskComparisonRule#areLexicallyEqual(ITask, ITask) 41 42 */ 42 43 @Override … … 46 47 47 48 /* (non-Javadoc) 48 * @see NodeComparisonRule#areSyntacticallyEqual(ITask, ITask)49 * @see TaskComparisonRule#areSyntacticallyEqual(ITask, ITask) 49 50 */ 50 51 @Override … … 54 55 55 56 /* (non-Javadoc) 56 * @see NodeComparisonRule#areSemanticallyEqual(ITask, ITask)57 * @see TaskComparisonRule#areSemanticallyEqual(ITask, ITask) 57 58 */ 58 59 @Override … … 62 63 63 64 /* (non-Javadoc) 64 * @see NodeComparisonRule#compare(ITask, ITask)65 * @see TaskComparisonRule#compare(ITask, ITask) 65 66 */ 66 67 @Override … … 74 75 } 75 76 77 /* (non-Javadoc) 78 * @see TaskComparisonRule#isApplicable(ITaskInstance, ITaskInstance) 79 */ 80 @Override 81 public boolean isApplicable(ITaskInstance instance1, ITaskInstance instance2) { 82 return (instance1.getTask() == instance2.getTask()); 83 } 84 85 /* (non-Javadoc) 86 * @see TaskComparisonRule#areLexicallyEqual(ITaskInstance, ITaskInstance) 87 */ 88 @Override 89 public boolean areLexicallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 90 return (instance1.getTask() == instance2.getTask()); 91 } 92 93 /* (non-Javadoc) 94 * @see TaskComparisonRule#areSyntacticallyEqual(ITaskInstance, ITaskInstance) 95 */ 96 @Override 97 public boolean areSyntacticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 98 return (instance1.getTask() == instance2.getTask()); 99 } 100 101 /* (non-Javadoc) 102 * @see TaskComparisonRule#areSemanticallyEqual(ITaskInstance, ITaskInstance) 103 */ 104 @Override 105 public boolean areSemanticallyEqual(ITaskInstance instance1, ITaskInstance instance2) { 106 return (instance1.getTask() == instance2.getTask()); 107 } 108 109 /* (non-Javadoc) 110 * @see TaskComparisonRule#compare(ITaskInstance, ITaskInstance) 111 */ 112 @Override 113 public TaskEquality compare(ITaskInstance instance1, ITaskInstance instance2) { 114 if (isApplicable(instance1, instance2)) { 115 return TaskEquality.IDENTICAL; 116 } 117 else { 118 return null; 119 } 120 } 121 76 122 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/ITaskInstanceScopeRule.java
r1219 r1294 15 15 package de.ugoe.cs.autoquest.tasktrees.temporalrelation; 16 16 17 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance List;17 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 18 18 19 19 /** 20 20 * <p> 21 * a task instance list scope rule is able to detected temporal relationships between a list of task22 * instances provided to the {@link #apply(ITaskInstanceList)} method. A rule creates temporal21 * a task instance scope rule is able to detected temporal relationships between the children of 22 * a task instance provided to the {@link #apply(ITaskInstance)} method. A rule creates temporal 23 23 * relationships between the task instances, i.e. substructures in the task tree, if 24 24 * it detects a temporal relationship and instantiates the temporal relationships accordingly. … … 27 27 * @author Patrick Harms 28 28 */ 29 interface ITaskInstance ListScopeRule extends ITemporalRelationshipRule {29 interface ITaskInstanceScopeRule extends ITemporalRelationshipRule { 30 30 31 31 /** 32 32 * <p> 33 * applies the rule to the given task instance list. The returned rule application result is null,33 * applies the rule to the given task instance. The returned rule application result is null, 34 34 * if the rule can not be applied, i.e. it does not detect a temporal relationship. It returns a 35 35 * rule application result with a status {@link RuleApplicationStatus#RULE_APPLICATION_FINISHED} … … 37 37 * </p> 38 38 * 39 * @param taskInstance s the list oftask instances to apply the rule on39 * @param taskInstance the task instances to apply the rule on 40 40 * 41 41 * @return the rule application result as described. 42 42 */ 43 RuleApplicationResult apply(ITaskInstance List taskInstances);43 RuleApplicationResult apply(ITaskInstance taskInstance); 44 44 45 45 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/ITemporalRelationshipRule.java
r1284 r1294 19 19 * a temporal relationship rule is the main interface for all rules applied for generating 20 20 * temporal relationships in a task tree. It is just a marker interface. More important are the 21 * sub interfaces {@link ISessionScopeRule} and {@link ITaskInstance ListScopeRule}.21 * sub interfaces {@link ISessionScopeRule} and {@link ITaskInstanceScopeRule}. 22 22 * </p> 23 23 * -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/RuleUtils.java
r1281 r1294 15 15 package de.ugoe.cs.autoquest.tasktrees.temporalrelation; 16 16 17 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 17 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 18 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequenceInstance; 18 19 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; 19 20 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; … … 55 56 int startIndex, 56 57 int endIndex, 57 I Taskmodel,58 ISequence model, 58 59 ITaskFactory taskFactory, 59 60 ITaskBuilder taskBuilder) 60 61 { 61 I TaskInstance subsequence = taskFactory.createNewTaskInstance(model);62 ISequenceInstance subsequence = taskFactory.createNewTaskInstance(model); 62 63 63 64 for (int i = startIndex; i <= endIndex; i++) { … … 83 84 * @return the replacement for the range 84 85 */ 85 static I TaskInstance createNewSubSequenceInRange(ITaskInstanceList parent,86 int startIndex,87 int endIndex,88 ITaskmodel,89 ITaskFactory taskFactory,90 ITaskBuilder taskBuilder)86 static ISequenceInstance createNewSubSequenceInRange(ITaskInstanceList parent, 87 int startIndex, 88 int endIndex, 89 ISequence model, 90 ITaskFactory taskFactory, 91 ITaskBuilder taskBuilder) 91 92 { 92 I TaskInstance subsequence = taskFactory.createNewTaskInstance(model);93 ISequenceInstance subsequence = taskFactory.createNewTaskInstance(model); 93 94 94 95 for (int i = startIndex; i <= endIndex; i++) { -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/SequenceForTaskDetectionRule.java
r1287 r1294 26 26 import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality; 27 27 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 28 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIterationInstance; 28 29 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 30 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelectionInstance; 29 31 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 32 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequenceInstance; 30 33 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 31 34 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; … … 159 162 SymbolMap<ITaskInstance, ITask> uniqueTasks = 160 163 preparationTaskHandlingStrategy.createSymbolMap(); 161 Task Comparator comparator = preparationTaskHandlingStrategy.getTaskComparator();164 TaskInstanceComparator comparator = preparationTaskHandlingStrategy.getTaskComparator(); 162 165 163 166 int unifiedTasks = 0; … … 235 238 { 236 239 Map<ITask, IIteration> iterations = new HashMap<ITask, IIteration>(); 237 Map<IIteration, List<I TaskInstance>> iterationInstances =238 new HashMap<IIteration, List<I TaskInstance>>();240 Map<IIteration, List<IIterationInstance>> iterationInstances = 241 new HashMap<IIteration, List<IIterationInstance>>(); 239 242 240 243 for (ITask iteratedTask : iteratedTasks) { 241 244 IIteration iteration = taskFactory.createNewIteration(); 242 245 iterations.put(iteratedTask, iteration); 243 iterationInstances.put(iteration, new LinkedList<I TaskInstance>());244 } 245 246 I TaskInstance iterationInstance = null;246 iterationInstances.put(iteration, new LinkedList<IIterationInstance>()); 247 } 248 249 IIterationInstance iterationInstance = null; 247 250 248 251 for (IUserSession session : sessions) { … … 275 278 } 276 279 277 for (Map.Entry<IIteration, List<ITaskInstance>> entry : iterationInstances.entrySet()) { 280 for (Map.Entry<IIteration, List<IIterationInstance>> entry : iterationInstances.entrySet()) 281 { 278 282 harmonizeIterationInstancesModel(entry.getKey(), entry.getValue()); 279 283 } … … 283 287 * 284 288 */ 285 private void harmonizeIterationInstancesModel(IIteration iteration,286 List<I TaskInstance> iterationInstances)289 private void harmonizeIterationInstancesModel(IIteration iteration, 290 List<IIterationInstance> iterationInstances) 287 291 { 288 292 List<ITask> iteratedTaskVariants = new LinkedList<ITask>(); 289 Task Comparator comparator = preparationTaskHandlingStrategy.getTaskComparator();293 TaskInstanceComparator comparator = preparationTaskHandlingStrategy.getTaskComparator(); 290 294 291 295 // merge the lexically different variants of iterated task to a unique list 292 for (I TaskInstance iterationInstance : iterationInstances) {296 for (IIterationInstance iterationInstance : iterationInstances) { 293 297 for (ITaskInstance executionVariant : iterationInstance) { 294 298 ITask candidate = executionVariant.getTask(); … … 323 327 taskBuilder.setMarkedTask(iteration, selection); 324 328 325 for (I TaskInstance instance : iterationInstances) {329 for (IIterationInstance instance : iterationInstances) { 326 330 for (int i = 0; i < instance.size(); i++) { 327 ITaskInstance selectionInstance = taskFactory.createNewTaskInstance(selection); 328 taskBuilder.addChild(selectionInstance, instance.get(i)); 331 ISelectionInstance selectionInstance = 332 taskFactory.createNewTaskInstance(selection); 333 taskBuilder.setChild(selectionInstance, instance.get(i)); 329 334 taskBuilder.setTaskInstance(instance, i, selectionInstance); 330 335 } … … 490 495 Console.traceln(Level.FINEST, "replacing " + sequence.getId() + ": " + task); 491 496 492 List<I TaskInstance> sequenceInstances =497 List<ISequenceInstance> sequenceInstances = 493 498 replaceTaskOccurrences(task, appData.getSessions(), sequence); 494 499 … … 510 515 * 511 516 */ 512 private void harmonizeSequenceInstancesModel(ISequence sequence,513 List<I TaskInstance> sequenceInstances,514 int sequenceLength)517 private void harmonizeSequenceInstancesModel(ISequence sequence, 518 List<ISequenceInstance> sequenceInstances, 519 int sequenceLength) 515 520 { 516 Task Comparator comparator = preparationTaskHandlingStrategy.getTaskComparator();521 TaskInstanceComparator comparator = preparationTaskHandlingStrategy.getTaskComparator(); 517 522 518 523 // ensure for each subtask that lexically different variants are preserved … … 520 525 List<ITask> subTaskVariants = new LinkedList<ITask>(); 521 526 522 for (I TaskInstance sequenceInstance : sequenceInstances) {527 for (ISequenceInstance sequenceInstance : sequenceInstances) { 523 528 ITask candidate = sequenceInstance.get(subTaskIndex).getTask(); 524 529 … … 556 561 taskBuilder.addChild(sequence, selection); 557 562 558 for (I TaskInstance instance : sequenceInstances) {559 I TaskInstance selectionInstance =563 for (ISequenceInstance instance : sequenceInstances) { 564 ISelectionInstance selectionInstance = 560 565 taskFactory.createNewTaskInstance(selection); 561 taskBuilder. addChild(selectionInstance, instance.get(subTaskIndex));566 taskBuilder.setChild(selectionInstance, instance.get(subTaskIndex)); 562 567 taskBuilder.setTaskInstance(instance, subTaskIndex, selectionInstance); 563 568 } … … 572 577 * @param tree 573 578 */ 574 private List<I TaskInstance> replaceTaskOccurrences(List<ITaskInstance> task,575 List<IUserSession> sessions,576 ISequence temporalTaskModel)579 private List<ISequenceInstance> replaceTaskOccurrences(List<ITaskInstance> task, 580 List<IUserSession> sessions, 581 ISequence temporalTaskModel) 577 582 { 578 List<I TaskInstance> sequenceInstances = new LinkedList<ITaskInstance>();583 List<ISequenceInstance> sequenceInstances = new LinkedList<ISequenceInstance>(); 579 584 580 585 for (IUserSession session : sessions) { -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TaskHandlingStrategy.java
r1285 r1294 42 42 * 43 43 */ 44 private Task Comparator comparator;44 private TaskInstanceComparator comparator; 45 45 46 46 /** … … 58 58 } 59 59 else { 60 comparator = new Task Comparator(this.consideredEquality);60 comparator = new TaskInstanceComparator(this.consideredEquality); 61 61 } 62 62 } … … 77 77 * @return 78 78 */ 79 public Task Comparator getTaskComparator() {79 public TaskInstanceComparator getTaskComparator() { 80 80 return comparator; 81 81 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TaskIdentityComparator.java
r1285 r1294 21 21 * TODO comment 22 22 */ 23 class TaskIdentityComparator extends Task Comparator {23 class TaskIdentityComparator extends TaskInstanceComparator { 24 24 25 25 /** */ -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TaskInstanceComparator.java
r1285 r1294 28 28 * TODO comment 29 29 */ 30 class Task Comparator implements SymbolComparator<ITaskInstance> {30 class TaskInstanceComparator implements SymbolComparator<ITaskInstance> { 31 31 32 32 /** */ … … 54 54 * 55 55 */ 56 public Task Comparator(TaskEquality minimalNodeEquality) {56 public TaskInstanceComparator(TaskEquality minimalNodeEquality) { 57 57 this.minimalNodeEquality = minimalNodeEquality; 58 58 init(); -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TaskSymbolBucketedMap.java
r1285 r1294 27 27 28 28 import de.ugoe.cs.autoquest.eventcore.IEventType; 29 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 30 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 31 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 32 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 33 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 29 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTaskInstance; 30 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIterationInstance; 31 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelectionInstance; 32 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequenceInstance; 34 33 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 35 34 import de.ugoe.cs.autoquest.usageprofiles.SymbolMap; … … 81 80 * </p> 82 81 */ 83 private Task Comparator comparator;82 private TaskInstanceComparator comparator; 84 83 85 84 /** … … 117 116 * @throws IllegalArgumentException if the provided comparator is null 118 117 */ 119 public TaskSymbolBucketedMap(Task Comparator comparator) {118 public TaskSymbolBucketedMap(TaskInstanceComparator comparator) { 120 119 if (comparator == null) { 121 120 throw new IllegalArgumentException("comparator must not be null"); … … 400 399 // other = hashCode of name of event type 401 400 402 ITask task = taskInstance.getTask(); 403 404 if (task instanceof IEventTask) { 401 if (taskInstance instanceof IEventTaskInstance) { 405 402 // event tasks are most likely equal to those of the event type with the same name, 406 403 // Afterwards, they may be equal to iterations, optionals, other event tasks, 407 404 // selections, and finally the rest. 408 IEventType eventType = ((IEventTask ) task).getEventType();405 IEventType eventType = ((IEventTaskInstance) taskInstance).getEvent().getType(); 409 406 return new int[] { eventType.getName().hashCode(), 2, 3, 4, 1 }; 410 407 } 411 else if (task instanceof ISequence) {408 else if (taskInstance instanceof ISequenceInstance) { 412 409 return new int[] { 0, 2, 3, 1 }; 413 410 } 414 else if (task instanceof ISelection) {411 else if (taskInstance instanceof ISelectionInstance) { 415 412 return new int[] { 1, 4, 2, 3 }; 416 413 } 417 else if (task instanceof IIteration) {414 else if (taskInstance instanceof IIterationInstance) { 418 415 return new int[] { 2, 1, 4 }; 419 416 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TemporalRelationshipRuleManager.java
r1189 r1294 26 26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory; 27 27 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 28 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList;29 28 import de.ugoe.cs.autoquest.tasktrees.treeifc.IUserSession; 30 29 import de.ugoe.cs.util.console.Console; … … 38 37 * between tasks which are not only a major sequence. I.e. through the application of the 39 38 * rules iterations and selections of tasks are detected. Which kind of temporal relations 40 * between tasks are detected depends on the {@link ITaskInstance ListScopeRule}s known to39 * between tasks are detected depends on the {@link ITaskInstanceScopeRule}s known to 41 40 * this class. 42 41 * </p> 43 * <p>The class holds references to the appropriate {@link ITaskInstance ListScopeRule}s and calls44 * their {@link ITaskInstance ListScopeRule#apply(ITask, ITaskBuilder, ITaskFactory, boolean)}42 * <p>The class holds references to the appropriate {@link ITaskInstanceScopeRule}s and calls 43 * their {@link ITaskInstanceScopeRule#apply(ITask, ITaskBuilder, ITaskFactory, boolean)} 45 44 * method for each task in the task tree it is needed for. The general behavior of this class is 46 45 * the following: … … 56 55 * <li> 57 56 * the class iterates its internal list of rules and calls their 58 * {@link ITaskInstance ListScopeRule#apply(ITask, ITaskBuilder, ITaskFactory, boolean)}57 * {@link ITaskInstanceScopeRule#apply(ITask, ITaskBuilder, ITaskFactory, boolean)} 59 58 * method. 60 59 * </li> … … 115 114 * </p> 116 115 */ 117 private ITaskInstance ListScopeRule[] taskScopeRules;116 private ITaskInstanceScopeRule[] taskScopeRules; 118 117 119 118 /** … … 166 165 //treeScopeRules.add(new DefaultGuiElementSequenceDetectionRule(frameFilter)); 167 166 168 taskScopeRules = new ITaskInstance ListScopeRule[] {167 taskScopeRules = new ITaskInstanceScopeRule[] { 169 168 //new SequenceOnGuiElementDetectionRule(taskFactory, taskTreeBuilder), 170 169 //new EventSequenceOnSameTargetDetectionRule(taskFactory, taskTreeBuilder), … … 262 261 * on the recursion depth of calling this method. 263 262 */ 264 private int applyRules(ITaskInstance ListScopeRule[] rules,265 ITaskInstance List taskInstances,263 private int applyRules(ITaskInstanceScopeRule[] rules, 264 ITaskInstance taskInstance, 266 265 String logIndent) 267 266 { 268 Console.traceln(Level.FINER, logIndent + "applying rules for " + taskInstances.size() + 269 " task instances"); 267 Console.traceln(Level.FINER, logIndent + "applying rules on " + taskInstance); 270 268 271 269 int noOfRuleApplications = 0; 272 270 273 for (ITaskInstance ListScopeRule rule : rules) {271 for (ITaskInstanceScopeRule rule : rules) { 274 272 RuleApplicationResult result; 275 273 do { 276 274 Console.traceln 277 (Level.FINER, logIndent + "trying rule " + rule + " on " + taskInstance s);278 result = rule.apply(taskInstance s);275 (Level.FINER, logIndent + "trying rule " + rule + " on " + taskInstance); 276 result = rule.apply(taskInstance); 279 277 280 278 if ((result != null) && … … 282 280 { 283 281 Console.traceln 284 (Level.FINE, logIndent + "applied rule " + rule + " on " + taskInstance s);282 (Level.FINE, logIndent + "applied rule " + rule + " on " + taskInstance); 285 283 noOfRuleApplications++; 286 284 -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/IEventTask.java
r1180 r1294 15 15 package de.ugoe.cs.autoquest.tasktrees.treeifc; 16 16 17 import de.ugoe.cs.autoquest.eventcore.IEventTarget;18 import de.ugoe.cs.autoquest.eventcore.IEventType;19 20 17 /** 21 18 * <p> 22 19 * Event tasks represent single events. They have no children and are therefore the leaf nodes of 23 * a task model. They provide information about the event they represent. This includes the event 24 * type and the target. 20 * a task model. They provide information about the event they represent as a String description. 21 * They do not refer to events, as they may represented several semantically equal but lexically 22 * different events. Their description carries as much information as required to show the 23 * level of distinction. 25 24 * </p> 26 25 * … … 29 28 public interface IEventTask extends ITask { 30 29 31 /**32 * <p>33 * return the type of the event represented by this task34 * </p>35 *36 * @return as described37 */38 public IEventType getEventType();39 40 /**41 * <p>42 * return the target of the event represented by this task43 * </p>44 *45 * @return as described46 */47 public IEventTarget getEventTarget();48 49 30 /** 50 31 * <p> -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/ITask.java
r1180 r1294 16 16 17 17 import java.io.Serializable; 18 import java.util.Collection; 18 19 19 20 /** … … 49 50 */ 50 51 public String getDescription(); 52 53 /** 54 * <p> 55 * returns a collection of all observed instances of this task 56 * </p> 57 * 58 * @return as described 59 */ 60 public Collection<ITaskInstance> getInstances(); 51 61 52 62 /** -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/ITaskBuilder.java
r1197 r1294 26 26 /** 27 27 * <p> 28 * adds a child to a taskinstance. May ensure, that the child is a valid child considering28 * adds a child to a sequence instance. May ensure, that the child is a valid child considering 29 29 * the task model of the parent. In that case, an IllegalArgumentException is thrown. 30 30 * </p> 31 31 * 32 * @param taskInstance the instance of add the child to 33 * @param child the child to be added 34 * 35 * @throws IllegalArgumentException as described 36 */ 37 void addChild(ITaskInstance taskInstance, ITaskInstance child) throws IllegalArgumentException; 32 * @param instance the instance of add the child to 33 * @param child the child to be added 34 * 35 * @throws IllegalArgumentException as described 36 */ 37 void addChild(ISequenceInstance instance, ITaskInstance child) throws IllegalArgumentException; 38 39 /** 40 * <p> 41 * adds a child to an iteration instance. May ensure, that the child is a valid child 42 * considering the task model of the parent. In that case, an IllegalArgumentException is 43 * thrown. 44 * </p> 45 * 46 * @param instance the instance of add the child to 47 * @param child the child to be added 48 * 49 * @throws IllegalArgumentException as described 50 */ 51 void addChild(IIterationInstance instance, ITaskInstance child) throws IllegalArgumentException; 52 53 /** 54 * <p> 55 * sets the child of a selection instance. May ensure, that the child is a valid child 56 * considering the task model of the parent. In that case, an IllegalArgumentException is 57 * thrown. 58 * </p> 59 * 60 * @param instance the instance of add the child to 61 * @param child the child to be added 62 * 63 * @throws IllegalArgumentException as described 64 */ 65 void setChild(ISelectionInstance instance, ITaskInstance child) throws IllegalArgumentException; 66 67 /** 68 * <p> 69 * sets the child of an optional instance. May ensure, that the child is a valid child 70 * considering the task model of the parent. In that case, an IllegalArgumentException is 71 * thrown. 72 * </p> 73 * 74 * @param instance the instance of add the child to 75 * @param child the child to be added 76 * 77 * @throws IllegalArgumentException as described 78 */ 79 void setChild(IOptionalInstance instance, ITaskInstance child) throws IllegalArgumentException; 38 80 39 81 /** … … 215 257 void replaceChild(ISelection parent, ITask oldChild, ITask newChild); 216 258 217 /**218 * <p>219 * sets the description of a task220 * </p>221 *222 * @param task the task to set the description of223 * @param description the new description of the task224 */225 void setDescription(ITask task, String description);226 227 259 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/ITaskFactory.java
r1191 r1294 17 17 import java.util.List; 18 18 19 import de.ugoe.cs.autoquest.eventcore.IEventTarget; 20 import de.ugoe.cs.autoquest.eventcore.IEventType; 19 import de.ugoe.cs.autoquest.eventcore.Event; 21 20 22 21 /** … … 31 30 /** 32 31 * <p> 33 * creates a new event task with the given type and target32 * creates a new event task with the given description 34 33 * </p> 35 34 * 36 * @param eventType the type of the event represented by the task 37 * @param eventTarget the target of the event represented by the task 35 * @param description the description for the represented events 38 36 * 39 37 * @return the event task 40 38 */ 41 IEventTask createNewEventTask( IEventType eventType, IEventTarget eventTarget);39 IEventTask createNewEventTask(String description); 42 40 43 41 /** … … 79 77 /** 80 78 * <p> 81 * creates a new task instance with the given task as its model 79 * creates a new task instance with the given task as its model representing the provided event 82 80 * </p> 83 81 * 84 * @param task the model of the task instance to be created 82 * @param task the model of the task instance to be created 83 * @param event the event represented by the task instance 85 84 * 86 85 * @return the task instance 87 86 */ 88 I TaskInstance createNewTaskInstance(ITask task);87 IEventTaskInstance createNewTaskInstance(IEventTask task, Event event); 89 88 90 89 /** 91 90 * <p> 92 * creates a new empty task instance list91 * creates a new task instance with the given sequence as its model 93 92 * </p> 94 93 * 95 * @return the task instance list 94 * @param sequence the model of the task instance to be created 95 * 96 * @return the task instance 96 97 */ 97 ITaskInstanceList createNewTaskInstanceList(); 98 ISequenceInstance createNewTaskInstance(ISequence sequence); 99 100 /** 101 * <p> 102 * creates a new task instance with the given iteration as its model 103 * </p> 104 * 105 * @param iteration the model of the task instance to be created 106 * 107 * @return the task instance 108 */ 109 IIterationInstance createNewTaskInstance(IIteration iteration); 110 111 /** 112 * <p> 113 * creates a new task instance with the given optional as its model 114 * </p> 115 * 116 * @param optional the model of the task instance to be created 117 * 118 * @return the task instance 119 */ 120 IOptionalInstance createNewTaskInstance(IOptional optional); 121 122 /** 123 * <p> 124 * creates a new task instance with the given selection as its model 125 * </p> 126 * 127 * @param selection the model of the task instance to be created 128 * 129 * @return the task instance 130 */ 131 ISelectionInstance createNewTaskInstance(ISelection selection); 98 132 99 133 /** -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/ITaskInstance.java
r1177 r1294 15 15 package de.ugoe.cs.autoquest.tasktrees.treeifc; 16 16 17 import java. util.List;17 import java.io.Serializable; 18 18 19 19 /** 20 20 * <p> 21 21 * a task instance represents the execution of a specific task within a user session. A task 22 * instance is always related to the task that was executed. A task instance may have children 23 * but only if its related task allows to have children. For example, if the represented task is 24 * a sequence then task instance has children and these are instances of the tasks being the 25 * children of the related sequence. 26 * </p> 27 * <p> 28 * An instance of a sequence has the same number of children as the related sequence. An instance 29 * of a selection has only one child which is an instance of exactly one variant contained in the 30 * related selection. An instance of an iteration has zero or more instances of the same task 31 * as children where the task is the child of the related iteration. An instance of an optional 32 * has zero or one child where the task related to child is the child of the optional. A task 33 * instance related to an event task does not have children. 22 * instance is always related to the task that was executed. 34 23 * </p> 35 24 * 36 25 * @author Patrick Harms 37 26 */ 38 public interface ITaskInstance extends ITaskInstanceList { 39 40 /** 41 * <p> 42 * returns the children of the task instance if any. See class description for how many 43 * children can be expected. May return null. 44 * </p> 45 * 46 * @return as described 47 */ 48 public List<ITaskInstance> getChildren(); 27 public interface ITaskInstance extends Serializable, Cloneable { 49 28 50 29 /** -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/ITaskInstanceList.java
r1177 r1294 19 19 /** 20 20 * <p> 21 * represents a serializable , clonable,iterable representation of a read only list of task21 * represents a serializable and iterable representation of a read only list of task 22 22 * instances. The list is ordered. It does not provide methods for changing it. 23 23 * </p> … … 25 25 * @author Patrick Harms 26 26 */ 27 public interface ITaskInstanceList extends Serializable, Cloneable,Iterable<ITaskInstance> {27 public interface ITaskInstanceList extends Serializable, Iterable<ITaskInstance> { 28 28 29 29 /** … … 48 48 public int size(); 49 49 50 /**51 * <p>52 * clones a task instance list by creating exact clones of each contained instance in their53 * order54 * </p>55 *56 * @return a clone of the task instance list57 */58 public ITaskInstanceList clone();59 60 50 } -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/EventTask.java
r1255 r1294 15 15 package de.ugoe.cs.autoquest.tasktrees.treeimpl; 16 16 17 import de.ugoe.cs.autoquest.eventcore.IEventTarget;18 import de.ugoe.cs.autoquest.eventcore.IEventType;19 17 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 20 18 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskVisitor; … … 39 37 /** 40 38 * <p> 41 * the type of the represented event 42 * </p> 43 */ 44 private IEventType eventType; 45 46 /** 47 * <p> 48 * the target of the represented event 49 * </p> 50 */ 51 private IEventTarget eventTarget; 52 53 /** 54 * <p> 55 * simple constructor initializing this task with an event type and an event target 39 * simple constructor initializing this task with a description for the represented events 56 40 * </p> 57 41 * 58 * @param eventType the type of the represented event 59 * @param eventTarget the target of the represented event 42 * @param description a description for the represented events 60 43 */ 61 EventTask(IEventType eventType, IEventTarget eventTarget) { 62 super.setDescription(eventType.toString() + " \u21D2 " + eventTarget); 63 this.eventType = eventType; 64 this.eventTarget = eventTarget; 65 } 66 67 /* (non-Javadoc) 68 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask#getEventType() 69 */ 70 @Override 71 public IEventType getEventType() { 72 return eventType; 73 } 74 75 /* (non-Javadoc) 76 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask#getEventTarget() 77 */ 78 @Override 79 public IEventTarget getEventTarget() { 80 return eventTarget; 44 EventTask(String description) { 45 super.setDescription(description); 81 46 } 82 47 -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/Task.java
r1215 r1294 15 15 package de.ugoe.cs.autoquest.tasktrees.treeimpl; 16 16 17 import java.util.Collection; 18 import java.util.Collections; 19 import java.util.HashSet; 20 17 21 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 22 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 18 23 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskVisitor; 19 24 … … 56 61 */ 57 62 private String description; 63 64 /** 65 * <p> 66 * the instances of this task 67 * </p> 68 */ 69 private Collection<ITaskInstance> instances = new HashSet<ITaskInstance>(); 58 70 59 71 /** … … 97 109 public String getDescription() { 98 110 return description; 111 } 112 113 /* (non-Javadoc) 114 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITask#getInstances() 115 */ 116 @Override 117 public Collection<ITaskInstance> getInstances() { 118 return Collections.unmodifiableCollection(instances); 99 119 } 100 120 … … 163 183 } 164 184 185 /** 186 * <p> 187 * internally used to add an instance to this task 188 * </p> 189 * 190 * @param instance the instance belonging to this task 191 */ 192 void addInstance(ITaskInstance instance) { 193 this.instances.add(instance); 194 } 195 165 196 /* (non-Javadoc) 166 197 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITask#accept(ITaskVisitor) -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskBuilder.java
r1216 r1294 17 17 import java.util.List; 18 18 19 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask;20 19 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 20 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIterationInstance; 21 21 import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptional; 22 import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptionalInstance; 22 23 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 24 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelectionInstance; 23 25 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequenceInstance; 24 27 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 25 28 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; … … 41 44 42 45 /* (non-Javadoc) 43 * @see ITaskBuilder#addChild(ITaskInstance,ITaskInstance) 44 */ 45 @Override 46 public void addChild(ITaskInstance parent, ITaskInstance child) throws IllegalArgumentException 47 { 48 if (!(parent instanceof TaskInstance)) { 49 throw new IllegalArgumentException 50 ("illegal type of task instance provided: " + parent.getClass()); 46 * @see ITaskBuilder#addChild(ISequenceInstance, ITaskInstance) 47 */ 48 @Override 49 public void addChild(ISequenceInstance instance, ITaskInstance child) 50 throws IllegalArgumentException 51 { 52 if (!(instance instanceof SequenceInstance)) { 53 throw new IllegalArgumentException 54 ("illegal type of sequence instance provided: " + instance.getClass()); 51 55 } 52 56 53 57 if (!(child instanceof TaskInstance)) { 54 58 throw new IllegalArgumentException 55 ("illegal type of task instance provided: " + parent.getClass()); 56 } 57 58 // check, that the correct number of children for the distinct types are added 59 ITask task = parent.getTask(); 60 61 if (task instanceof IEventTask) { 62 throw new IllegalArgumentException 63 ("can not add children to a task instance of an event task"); 64 } 65 else if (task instanceof ISelection) { 66 if (parent.getChildren().size() > 0) { 67 throw new IllegalArgumentException 68 ("the instance of a selection must have at most one child"); 59 ("illegal type of task instance provided: " + child.getClass()); 60 } 61 62 /*IStructuringTemporalRelationship parentTask = 63 (IStructuringTemporalRelationship) parent.getTask(); 64 65 for (ITask parentTaskChild : parentTask.getChildren()) { 66 if (parentTaskChild.equals(child.getTask())) { 67 foundChildTask = true; 68 break; 69 69 } 70 70 } 71 else if (task instanceof IOptional) { 72 if (parent.getChildren().size() > 1) { 73 throw new IllegalArgumentException 74 ("the instance of an optional must have at most one child"); 75 } 76 } 77 /*else if (task instanceof IIteration) { 78 for (ITaskInstance childInstance : parent.getChildren()) { 79 if (!childInstance.getTask().equals(child.getTask())) { 80 throw new IllegalArgumentException 81 ("all children of an instance of an iteration must have exactly the " + 82 "same type"); 83 } 84 } 85 } 86 87 boolean foundChildTask = false; 88 if (parent.getTask() instanceof IStructuringTemporalRelationship) { 89 IStructuringTemporalRelationship parentTask = 90 (IStructuringTemporalRelationship) parent.getTask(); 91 92 for (ITask parentTaskChild : parentTask.getChildren()) { 93 if (parentTaskChild.equals(child.getTask())) { 94 foundChildTask = true; 95 break; 96 } 97 } 98 } 99 else if (parent.getTask() instanceof IMarkingTemporalRelationship) { 100 IMarkingTemporalRelationship parentTask = 101 (IMarkingTemporalRelationship) parent.getTask(); 102 103 foundChildTask = parentTask.getMarkedTask() != null ? 104 parentTask.getMarkedTask().equals(child.getTask()) : false; 105 } 106 71 107 72 if (!foundChildTask) { 108 73 throw new IllegalArgumentException … … 111 76 }*/ 112 77 113 // finally, after all checks are positive, add the child 114 ((TaskInstance) parent).addChild(child); 78 ((SequenceInstance) instance).addChild(child); 79 } 80 81 /* (non-Javadoc) 82 * @see ITaskBuilder#addChild(ISequenceInstance, int, ITaskInstance) 83 */ 84 public void addChild(ISequenceInstance instance, int index, ITaskInstance child) 85 throws IllegalArgumentException 86 { 87 if (!(instance instanceof SequenceInstance)) { 88 throw new IllegalArgumentException 89 ("illegal type of sequence instance provided: " + instance.getClass()); 90 } 91 92 if (!(child instanceof TaskInstance)) { 93 throw new IllegalArgumentException 94 ("illegal type of task instance provided: " + child.getClass()); 95 } 96 97 /*IStructuringTemporalRelationship parentTask = 98 (IStructuringTemporalRelationship) parent.getTask(); 99 100 for (ITask parentTaskChild : parentTask.getChildren()) { 101 if (parentTaskChild.equals(child.getTask())) { 102 foundChildTask = true; 103 break; 104 } 105 } 106 107 if (!foundChildTask) { 108 throw new IllegalArgumentException 109 ("the task of the child instance to be added does not belong to the children " + 110 "of the task of the parent instance"); 111 }*/ 112 113 ((SequenceInstance) instance).addChild(index, child); 114 } 115 116 /* (non-Javadoc) 117 * @see ITaskBuilder#addChild(IIterationInstance, ITaskInstance) 118 */ 119 @Override 120 public void addChild(IIterationInstance instance, ITaskInstance child) 121 throws IllegalArgumentException 122 { 123 if (!(instance instanceof IterationInstance)) { 124 throw new IllegalArgumentException 125 ("illegal type of iteration instance provided: " + instance.getClass()); 126 } 127 128 if (!(child instanceof TaskInstance)) { 129 throw new IllegalArgumentException 130 ("illegal type of task instance provided: " + child.getClass()); 131 } 132 133 /*IStructuringTemporalRelationship parentTask = 134 (IStructuringTemporalRelationship) parent.getTask(); 135 136 IMarkingTemporalRelationship parentTask = 137 (IMarkingTemporalRelationship) parent.getTask(); 138 139 foundChildTask = parentTask.getMarkedTask() != null ? 140 parentTask.getMarkedTask().equals(child.getTask()) : false; 141 142 if (!foundChildTask) { 143 throw new IllegalArgumentException 144 ("the task of the child instance to be added does not belong to the children " + 145 "of the task of the parent instance"); 146 }*/ 147 148 ((IterationInstance) instance).addChild(child); 149 } 150 151 /* (non-Javadoc) 152 * @see ITaskBuilder#addChild(IIterationInstance, int, ITaskInstance) 153 */ 154 public void addChild(IIterationInstance instance, int index, ITaskInstance child) 155 throws IllegalArgumentException 156 { 157 if (!(instance instanceof IterationInstance)) { 158 throw new IllegalArgumentException 159 ("illegal type of iteration instance provided: " + instance.getClass()); 160 } 161 162 if (!(child instanceof TaskInstance)) { 163 throw new IllegalArgumentException 164 ("illegal type of task instance provided: " + child.getClass()); 165 } 166 167 /*IStructuringTemporalRelationship parentTask = 168 (IStructuringTemporalRelationship) parent.getTask(); 169 170 IMarkingTemporalRelationship parentTask = 171 (IMarkingTemporalRelationship) parent.getTask(); 172 173 foundChildTask = parentTask.getMarkedTask() != null ? 174 parentTask.getMarkedTask().equals(child.getTask()) : false; 175 176 if (!foundChildTask) { 177 throw new IllegalArgumentException 178 ("the task of the child instance to be added does not belong to the children " + 179 "of the task of the parent instance"); 180 }*/ 181 182 ((IterationInstance) instance).addChild(index, child); 183 } 184 185 /* (non-Javadoc) 186 * @see ITaskBuilder#setChild(ISelectionInstance, ITaskInstance) 187 */ 188 @Override 189 public void setChild(ISelectionInstance instance, ITaskInstance child) 190 throws IllegalArgumentException 191 { 192 if (!(instance instanceof SelectionInstance)) { 193 throw new IllegalArgumentException 194 ("illegal type of sequence instance provided: " + instance.getClass()); 195 } 196 197 if (!(child instanceof TaskInstance)) { 198 throw new IllegalArgumentException 199 ("illegal type of task instance provided: " + child.getClass()); 200 } 201 202 /*IStructuringTemporalRelationship parentTask = 203 (IStructuringTemporalRelationship) parent.getTask(); 204 205 for (ITask parentTaskChild : parentTask.getChildren()) { 206 if (parentTaskChild.equals(child.getTask())) { 207 foundChildTask = true; 208 break; 209 } 210 } 211 212 if (!foundChildTask) { 213 throw new IllegalArgumentException 214 ("the task of the child instance to be added does not belong to the children " + 215 "of the task of the parent instance"); 216 }*/ 217 218 ((SelectionInstance) instance).setChild(child); 219 } 220 221 /* (non-Javadoc) 222 * @see ITaskBuilder#setChild(IOptionalInstance, ITaskInstance) 223 */ 224 @Override 225 public void setChild(IOptionalInstance instance, ITaskInstance child) 226 throws IllegalArgumentException 227 { 228 if (!(instance instanceof OptionalInstance)) { 229 throw new IllegalArgumentException 230 ("illegal type of optional instance provided: " + instance.getClass()); 231 } 232 233 if (!(child instanceof TaskInstance)) { 234 throw new IllegalArgumentException 235 ("illegal type of task instance provided: " + child.getClass()); 236 } 237 238 /*IStructuringTemporalRelationship parentTask = 239 (IStructuringTemporalRelationship) parent.getTask(); 240 241 IMarkingTemporalRelationship parentTask = 242 (IMarkingTemporalRelationship) parent.getTask(); 243 244 foundChildTask = parentTask.getMarkedTask() != null ? 245 parentTask.getMarkedTask().equals(child.getTask()) : false; 246 247 if (!foundChildTask) { 248 throw new IllegalArgumentException 249 ("the task of the child instance to be added does not belong to the children " + 250 "of the task of the parent instance"); 251 }*/ 252 253 ((OptionalInstance) instance).setChild(child); 115 254 } 116 255 … … 134 273 135 274 /* (non-Javadoc) 275 * @see ITaskBuilder#addExecutedTask(IUserSession, int, ITaskInstance) 276 */ 277 public void addExecutedTask(IUserSession session, int index, ITaskInstance taskInstance) { 278 if (!(session instanceof UserSession)) { 279 throw new IllegalArgumentException 280 ("illegal type of session provided: " + session.getClass()); 281 } 282 283 if (!(taskInstance instanceof TaskInstance)) { 284 throw new IllegalArgumentException 285 ("illegal type of task instance provided: " + taskInstance.getClass()); 286 } 287 288 ((UserSession) session).addExecutedTask(index, taskInstance); 289 } 290 291 /* (non-Javadoc) 136 292 * @see ITaskBuilder#addTaskInstance(ITaskInstanceList, ITaskInstance) 137 293 */ 138 294 @Override 139 295 public void addTaskInstance(ITaskInstanceList taskInstanceList, ITaskInstance taskInstance) { 140 if (taskInstanceList instanceof TaskInstance) { 141 ((TaskInstance) taskInstanceList).addChild(taskInstance); 296 if (taskInstanceList instanceof SequenceInstance) { 297 addChild((SequenceInstance) taskInstanceList, taskInstance); 298 } 299 else if (taskInstanceList instanceof IterationInstance) { 300 addChild((IterationInstance) taskInstanceList, taskInstance); 142 301 } 143 302 else if (taskInstanceList instanceof UserSession) { 144 ((UserSession) taskInstanceList).addExecutedTask(taskInstance);303 addExecutedTask((UserSession) taskInstanceList, taskInstance); 145 304 } 146 305 else { … … 158 317 ITaskInstance taskInstance) 159 318 { 160 if (taskInstanceList instanceof TaskInstance) { 161 ((TaskInstance) taskInstanceList).addChild(index, taskInstance); 319 if (taskInstanceList instanceof SequenceInstance) { 320 addChild((SequenceInstance) taskInstanceList, index, taskInstance); 321 } 322 else if (taskInstanceList instanceof IterationInstance) { 323 addChild((IterationInstance) taskInstanceList, index, taskInstance); 162 324 } 163 325 else if (taskInstanceList instanceof UserSession) { 164 ((UserSession) taskInstanceList).addExecutedTask(index, taskInstance);326 addExecutedTask((UserSession) taskInstanceList, index, taskInstance); 165 327 } 166 328 else { … … 178 340 ITaskInstance taskInstance) 179 341 { 180 if (taskInstanceList instanceof TaskInstance) { 181 ((TaskInstance) taskInstanceList).removeChild(index); 182 ((TaskInstance) taskInstanceList).addChild(index, taskInstance); 183 } 184 else if (taskInstanceList instanceof UserSession) { 185 ((UserSession) taskInstanceList).removeExecutedTask(index); 186 ((UserSession) taskInstanceList).addExecutedTask(index, taskInstance); 187 } 188 else { 189 throw new IllegalArgumentException 190 ("illegal type of task instance list provided: " + taskInstanceList.getClass()); 191 } 342 removeTaskInstance(taskInstanceList, index); 343 addTaskInstance(taskInstanceList, index, taskInstance); 192 344 } 193 345 … … 334 486 @Override 335 487 public void removeTaskInstance(ITaskInstanceList taskInstanceList, int index) { 336 if (taskInstanceList instanceof TaskInstance) { 337 ((TaskInstance) taskInstanceList).removeChild(index); 488 if (taskInstanceList instanceof SequenceInstance) { 489 ((SequenceInstance) taskInstanceList).removeChild(index); 490 } 491 else if (taskInstanceList instanceof IterationInstance) { 492 ((IterationInstance) taskInstanceList).removeChild(index); 338 493 } 339 494 else if (taskInstanceList instanceof UserSession) { … … 369 524 } 370 525 371 /* (non-Javadoc)372 * @see ITaskBuilder#setDescription(ITask, java.lang.String)373 */374 @Override375 public void setDescription(ITask parent, String description) {376 if (!(parent instanceof Task)) {377 throw new IllegalArgumentException378 ("illegal type of task provided: " + parent.getClass());379 }380 381 ((Task) parent).setDescription(description);382 }383 384 526 /** 385 527 * <p> -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskFactory.java
r1216 r1294 17 17 import java.util.List; 18 18 19 import de.ugoe.cs.autoquest.eventcore.IEventTarget; 20 import de.ugoe.cs.autoquest.eventcore.IEventType; 19 import de.ugoe.cs.autoquest.eventcore.Event; 21 20 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 21 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTaskInstance; 22 22 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 23 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIterationInstance; 23 24 import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptional; 25 import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptionalInstance; 24 26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 27 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelectionInstance; 25 28 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 27 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 28 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList; 29 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequenceInstance; 29 30 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; 30 31 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory; … … 43 44 44 45 /* (non-Javadoc) 45 * @see ITaskFactory#createNewEventTask( IEventType, IEventTarget)46 * @see ITaskFactory#createNewEventTask(String) 46 47 */ 47 48 @Override 48 public IEventTask createNewEventTask( IEventType eventType, IEventTarget eventTarget) {49 return new EventTask( eventType, eventTarget);49 public IEventTask createNewEventTask(String description) { 50 return new EventTask(description); 50 51 } 51 52 … … 83 84 84 85 /* (non-Javadoc) 85 * @see ITaskFactory#createNewTaskInstance(I Task)86 * @see ITaskFactory#createNewTaskInstance(IEventTask, Event) 86 87 */ 87 88 @Override 88 public ITaskInstance createNewTaskInstance(ITask task) { 89 return new TaskInstance(task); 89 public IEventTaskInstance createNewTaskInstance(IEventTask task, Event event) { 90 if (!(task instanceof EventTask)) { 91 throw new IllegalArgumentException 92 ("illegal type of event task provided: " + task.getClass()); 93 } 94 95 EventTaskInstance instance = new EventTaskInstance(task, event); 96 ((EventTask) task).addInstance(instance); 97 98 return instance; 90 99 } 91 100 92 101 /* (non-Javadoc) 93 * @see ITaskFactory#createNewTaskInstance List()102 * @see ITaskFactory#createNewTaskInstance(ISequence) 94 103 */ 95 104 @Override 96 public ITaskInstanceList createNewTaskInstanceList() { 97 return new TaskInstance(new Sequence()); 105 public ISequenceInstance createNewTaskInstance(ISequence sequence) { 106 if (!(sequence instanceof Sequence)) { 107 throw new IllegalArgumentException 108 ("illegal type of sequence provided: " + sequence.getClass()); 109 } 110 111 SequenceInstance instance = new SequenceInstance(sequence); 112 ((Sequence) sequence).addInstance(instance); 113 114 return instance; 115 } 116 117 /* (non-Javadoc) 118 * @see ITaskFactory#createNewTaskInstance(IIteration) 119 */ 120 @Override 121 public IIterationInstance createNewTaskInstance(IIteration iteration) { 122 if (!(iteration instanceof Iteration)) { 123 throw new IllegalArgumentException 124 ("illegal type of iteration provided: " + iteration.getClass()); 125 } 126 127 IterationInstance instance = new IterationInstance(iteration); 128 ((Iteration) iteration).addInstance(instance); 129 130 return instance; 131 } 132 133 /* (non-Javadoc) 134 * @see ITaskFactory#createNewTaskInstance(IOptional) 135 */ 136 @Override 137 public IOptionalInstance createNewTaskInstance(IOptional optional) { 138 if (!(optional instanceof Optional)) { 139 throw new IllegalArgumentException 140 ("illegal type of optional provided: " + optional.getClass()); 141 } 142 143 OptionalInstance instance = new OptionalInstance(optional); 144 ((Optional) optional).addInstance(instance); 145 146 return instance; 147 } 148 149 /* (non-Javadoc) 150 * @see ITaskFactory#createNewTaskInstance(ISelection) 151 */ 152 @Override 153 public ISelectionInstance createNewTaskInstance(ISelection selection) { 154 if (!(selection instanceof Selection)) { 155 throw new IllegalArgumentException 156 ("illegal type of optional provided: " + selection.getClass()); 157 } 158 159 SelectionInstance instance = new SelectionInstance(selection); 160 ((Selection) selection).addInstance(instance); 161 162 return instance; 98 163 } 99 164 -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskInstance.java
r1255 r1294 14 14 15 15 package de.ugoe.cs.autoquest.tasktrees.treeimpl; 16 17 import java.util.Collections;18 import java.util.Iterator;19 import java.util.LinkedList;20 import java.util.List;21 16 22 17 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; … … 64 59 /** 65 60 * <p> 66 * the children of this task instance which are task instances, as well67 * </p>68 */69 private List<ITaskInstance> children;70 71 /**72 * <p>73 61 * instantiated the task instance with the task that is instantiated by the instance. It also 74 62 * assigns a unique id to the instance using {@link #getNewId()}. … … 102 90 public ITask getTask() { 103 91 return task; 104 }105 106 /* (non-Javadoc)107 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance#getChildren()108 */109 public synchronized List<ITaskInstance> getChildren() {110 if (children == null) {111 children = new LinkedList<ITaskInstance>();112 }113 114 return Collections.unmodifiableList(children);115 }116 117 /* (non-Javadoc)118 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList#get(int)119 */120 @Override121 public ITaskInstance get(int index) {122 if (children == null) {123 throw new IndexOutOfBoundsException(Integer.toString(index));124 }125 else {126 return children.get(index);127 }128 }129 130 /* (non-Javadoc)131 * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList#size()132 */133 @Override134 public int size() {135 if (children == null) {136 return 0;137 }138 else {139 return children.size();140 }141 }142 143 /* (non-Javadoc)144 * @see java.lang.Iterable#iterator()145 */146 @Override147 public Iterator<ITaskInstance> iterator() {148 return getChildren().iterator();149 92 } 150 93 … … 203 146 try { 204 147 clone = (TaskInstance) super.clone(); 205 206 if (children != null) {207 clone.children = new LinkedList<ITaskInstance>();208 209 for (ITaskInstance child : children) {210 clone.children.add(child.clone());211 }212 }213 214 148 } 215 149 catch (CloneNotSupportedException e) { … … 219 153 220 154 return clone; 221 }222 223 /**224 * <p>225 * used to add a child to this task instance226 * </p>227 *228 * @param child the new child of this instance229 */230 synchronized void addChild(ITaskInstance child) {231 if (children == null) {232 children = new LinkedList<ITaskInstance>();233 }234 235 children.add(child);236 }237 238 /**239 * <p>240 * used to add a child to this task instance at a specific position241 * </p>242 *243 * @param index the position of the new child in the list of children244 * @param child the new child of this instance245 */246 synchronized void addChild(int index, ITaskInstance child) {247 if (children == null) {248 children = new LinkedList<ITaskInstance>();249 }250 251 children.add(index, child);252 }253 254 /**255 * <p>256 * removes a child from this task instance at a specific position257 * </p>258 *259 * @param index the position of the child to be removed260 *261 * @return the child remove from the children of this instance262 */263 synchronized ITaskInstance removeChild(int index) {264 if (children != null) {265 return children.remove(index);266 }267 else {268 throw new IllegalArgumentException269 ("this task instance does not have children that can be removed");270 }271 155 } 272 156 -
trunk/autoquest-test-utils/src/main/java/de/ugoe/cs/autoquest/tasktrees/TaskTreeChecker.java
r1146 r1294 20 20 import java.util.HashMap; 21 21 import java.util.Iterator; 22 import java.util.LinkedList; 22 23 import java.util.List; 23 24 import java.util.Map; … … 27 28 import de.ugoe.cs.autoquest.eventcore.gui.TextInput; 28 29 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 30 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTaskInstance; 29 31 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 32 import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptionalInstance; 30 33 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 34 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelectionInstance; 31 35 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 32 36 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; … … 70 74 * 71 75 */ 72 public void assert TaskInstanceList(String userSessionSpec, ITaskInstanceList taskInstances) {76 public void assertUserSession(String userSessionSpec, IUserSession session) { 73 77 if (doTrace) { 74 new TaskTreeEncoder().encode( taskInstances, System.err);78 new TaskTreeEncoder().encode(session, System.err); 75 79 } 76 80 … … 86 90 87 91 if (taskInstanceSpec != null) { 88 assertTaskInstanceList(taskInstanceSpec, taskInstances, tasks); 92 assertUserSession(taskInstanceSpec, session, tasks); 93 } 94 } 95 } 96 97 /** 98 * 99 */ 100 public void assertTaskInstance(String userSessionSpec, ITaskInstance taskInstance) { 101 if (doTrace) { 102 new TaskTreeEncoder().encode(taskInstance, System.err); 103 } 104 105 TaskSpec taskInstanceSpec = null; 106 107 Matcher taskMatcher = taskPattern.matcher(userSessionSpec); 108 109 Map<String, ITask> tasks = new HashMap<String, ITask>(); 110 111 while (taskMatcher.find()) { 112 113 taskInstanceSpec = parseTaskInstance(taskMatcher); 114 115 if (taskInstanceSpec != null) { 116 assertTaskInstance(taskInstanceSpec, taskInstance, tasks); 89 117 } 90 118 } … … 154 182 } 155 183 156 List<ITaskInstance> expectedChildren = expected.getChildren();157 List<ITaskInstance> checkedChildren = checked.getChildren();184 List<ITaskInstance> expectedChildren = getChildren(expected); 185 List<ITaskInstance> checkedChildren = getChildren(checked); 158 186 159 187 if ((expectedChildren != null) && (expectedChildren.size() > 0)) { … … 241 269 * @param taskMapCopy 242 270 */ 243 private void assert TaskInstanceList(TaskSpec taskSpec,244 ITaskInstanceList taskInstances,245 271 private void assertUserSession(TaskSpec taskSpec, 272 IUserSession session, 273 Map<String, ITask> tasks) 246 274 { 247 275 if (doTrace) { 248 System.err.println("\ncomparing " + taskSpec.type + " with " + taskInstances+ "\n");249 } 250 251 if ( (taskInstances instanceof IUserSession) && (!"UserSession".equals(taskSpec.type))) {276 System.err.println("\ncomparing " + taskSpec.type + " with " + session + "\n"); 277 } 278 279 if (!"UserSession".equals(taskSpec.type)) { 252 280 fail("can not compare a task instance with a user session"); 253 281 } 254 else if ((!(taskInstances instanceof IUserSession)) && 255 (!"TaskInstances".equals(taskSpec.type))) 256 { 282 283 List<ITaskInstance> children = session.getExecutedTasks(); 284 285 if (taskSpec.children.length != children.size()) { 286 fail("number of task instances in task instance list does not match"); 287 } 288 289 for (int i = 0; i < children.size(); i++) { 290 TaskSpec childSpec = taskSpec.children[i]; 291 assertTrue(taskSpecEqualsTaskInstance(childSpec, children.get(i), tasks)); 292 } 293 } 294 295 /** 296 * @param task 297 * @param taskMapCopy 298 */ 299 private void assertTaskInstance(TaskSpec taskSpec, 300 ITaskInstance taskInstance, 301 Map<String, ITask> tasks) 302 { 303 if (doTrace) { 304 System.err.println("\ncomparing " + taskSpec.type + " with " + taskInstance + "\n"); 305 } 306 307 if (!"TaskInstances".equals(taskSpec.type)) { 257 308 fail("can not compare a task instance with a task instance list"); 258 309 } 259 310 260 if (taskSpec.children.length != taskInstances.size()) { 311 List<ITaskInstance> children = getChildren(taskInstance); 312 313 if (taskSpec.children.length != children.size()) { 261 314 fail("number of task instances in task instance list does not match"); 262 315 } 263 316 264 for (int i = 0; i < taskInstances.size(); i++) {317 for (int i = 0; i < children.size(); i++) { 265 318 TaskSpec childSpec = taskSpec.children[i]; 266 assertTrue(taskSpecEqualsTaskInstance(childSpec, taskInstances.get(i), tasks));319 assertTrue(taskSpecEqualsTaskInstance(childSpec, children.get(i), tasks)); 267 320 } 268 321 } … … 284 337 if (("Event".equals(taskSpec.type) && (!(task instanceof IEventTask))) || 285 338 ("TextInputEvent".equals(taskSpec.type) && 286 ((!(task instanceof IEventTask)) ||287 (!(((IEventTask ) task).getEventType() instanceof TextInput)))) ||339 ((!(taskInstance instanceof IEventTaskInstance)) || 340 (!(((IEventTaskInstance) taskInstance).getEvent().getType() instanceof TextInput)))) || 288 341 ("Sequence".equals(taskSpec.type) && (!(task instanceof ISequence))) || 289 342 ("Selection".equals(taskSpec.type) && (!(task instanceof ISelection))) || … … 306 359 307 360 if ("TextInputEvent".equals(taskSpec.type)) { 308 TextInput eventType = (TextInput) ((IEventTask) task).getEventType(); 361 TextInput eventType = (TextInput) 362 ((IEventTaskInstance) taskInstance).getEvent().getType(); 363 309 364 if ((taskSpec.additionalInfo != null) && 310 365 !"".equals(taskSpec.additionalInfo) && … … 319 374 } 320 375 } 321 else if ((task instanceof IEventTask) && (((IEventTask) task).getEventType() != null) && 322 (!taskSpec.name.equals(((IEventTask) task).getEventType().getName()))) 376 else if ((task instanceof IEventTask) && 377 (((IEventTaskInstance) taskInstance).getEvent().getType() != null) && 378 (!taskSpec.name.equals(((IEventTaskInstance) taskInstance).getEvent().getType().getName()))) 323 379 { 324 380 // simple event names do not match. But what about the event name in … … 328 384 (!"".equals(taskSpec.additionalInfo) ? " " + taskSpec.additionalInfo : ""); 329 385 330 if (!complexName.equals(((IEventTask ) task).getEventType().getName())) {386 if (!complexName.equals(((IEventTaskInstance) taskInstance).getEvent().getType().getName())) { 331 387 if (doTrace) { 332 System.err.println("event names do not match: " + taskSpec.name + " != " + 333 ((IEventTask) task).getEventType().getName() + "\n"); 388 System.err.println 389 ("event names do not match: " + taskSpec.name + " != " + 390 ((IEventTaskInstance) taskInstance).getEvent().getType().getName() + "\n"); 334 391 } 335 392 return false; … … 358 415 } 359 416 360 if (((taskSpec.children == null) && (taskInstance.getChildren().size() > 0)) || 417 List<ITaskInstance> children = getChildren(taskInstance); 418 419 if (((taskSpec.children == null) && (children.size() > 0)) || 361 420 ((taskSpec.children != null) && 362 (taskSpec.children.length != taskInstance.getChildren().size())))421 (taskSpec.children.length != children.size()))) 363 422 { 364 423 if (doTrace) { … … 366 425 ("numbers of children do not match: " + 367 426 (taskSpec.children == null ? "0" : taskSpec.children.length) + " != " + 368 (taskInstance.getChildren() == null ? "0" : 369 taskInstance.getChildren().size()) + "\n"); 427 (children == null ? "0" : children.size()) + "\n"); 370 428 } 371 429 return false; 372 430 } 373 431 374 Iterator<ITaskInstance> children = taskInstance.getChildren().iterator();432 Iterator<ITaskInstance> childrenIterator = children.iterator(); 375 433 if (taskSpec.children != null) { 376 434 for (TaskSpec child : taskSpec.children) { 377 if (!taskSpecEqualsTaskInstance(child, children .next(), tasks)) {435 if (!taskSpecEqualsTaskInstance(child, childrenIterator.next(), tasks)) { 378 436 if (doTrace) { 379 437 System.err.println("one of the children does not match\n"); … … 384 442 } 385 443 386 if (!children .hasNext()) {444 if (!childrenIterator.hasNext()) { 387 445 if (doTrace) { 388 446 System.err.println("nodes match\n"); … … 398 456 } 399 457 458 /** 459 * <p> 460 * TODO: comment 461 * </p> 462 * 463 * @param taskInstance 464 * @return 465 */ 466 private List<ITaskInstance> getChildren(ITaskInstance taskInstance) { 467 List<ITaskInstance> result = new LinkedList<ITaskInstance>(); 468 469 if (taskInstance instanceof ITaskInstanceList) { 470 for (ITaskInstance child : (ITaskInstanceList) taskInstance) { 471 result.add(child); 472 } 473 } 474 else if (taskInstance instanceof ISelectionInstance) { 475 result.add(((ISelectionInstance) taskInstance).getChild()); 476 } 477 else if (taskInstance instanceof IOptionalInstance) { 478 result.add(((IOptionalInstance) taskInstance).getChild()); 479 } 480 481 return result; 482 } 483 400 484 /** 401 485 * -
trunk/autoquest-test-utils/src/main/java/de/ugoe/cs/autoquest/tasktrees/TaskTreeDecoder.java
r1212 r1294 26 26 import de.ugoe.cs.autoquest.eventcore.StringEventType; 27 27 import de.ugoe.cs.autoquest.eventcore.gui.TextInput; 28 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 29 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTaskInstance; 28 30 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 31 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIterationInstance; 29 32 import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptional; 33 import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptionalInstance; 30 34 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 35 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelectionInstance; 31 36 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 37 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequenceInstance; 32 38 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 33 39 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; … … 173 179 } 174 180 else { 175 task = createUserInteractionTask (matcher);181 task = createUserInteractionTaskInstance(matcher).getTask(); 176 182 } 177 183 tasks.put(id, task); 178 184 } 179 185 180 if ((matcher.group(5) != null) && (!"".equals(matcher.group(5).trim()))) { 181 taskBuilder.setDescription(task, matcher.group(5).trim()); 182 } 183 184 ITaskInstance instance = taskFactory.createNewTaskInstance(task); 186 ITaskInstance instance; 187 188 if (task instanceof ISequence) { 189 instance = taskFactory.createNewTaskInstance((ISequence) task); 190 } 191 else if (task instanceof ISelection) { 192 instance = taskFactory.createNewTaskInstance((ISelection) task); 193 } 194 else if (task instanceof IIteration) { 195 instance = taskFactory.createNewTaskInstance((IIteration) task); 196 } 197 else if (task instanceof IOptional) { 198 instance = taskFactory.createNewTaskInstance((IOptional) task); 199 } 200 else { 201 instance = taskFactory.createNewTaskInstance 202 ((IEventTask) task, 203 ((IEventTaskInstance) task.getInstances().iterator().next()).getEvent()); 204 } 185 205 186 206 while (taskMatcher.find() && !"}".equals(taskMatcher.group(0))) { … … 216 236 } 217 237 218 taskBuilder.addChild(instance, childInstance); 238 if (instance instanceof ISequenceInstance) { 239 taskBuilder.addChild((ISequenceInstance) instance, childInstance); 240 } 241 else if (instance instanceof ISelectionInstance) { 242 taskBuilder.setChild((ISelectionInstance) instance, childInstance); 243 } 244 else if (instance instanceof IIterationInstance) { 245 taskBuilder.addChild((IIterationInstance) instance, childInstance); 246 } 247 else if (instance instanceof IOptionalInstance) { 248 taskBuilder.setChild((IOptionalInstance) instance, childInstance); 249 } 219 250 } 220 251 … … 229 260 * @return 230 261 */ 231 private ITask createUserInteractionTask(Matcher matcher) {262 private ITaskInstance createUserInteractionTaskInstance(Matcher matcher) { 232 263 String evenType = matcher.group(1); 233 264 String id = matcher.group(2); 234 IEventTarget even Target = targets.get(id);235 if (even Target == null) {236 even Target = determineTarget(evenType, id, matcher.group(4));237 targets.put(id, even Target);265 IEventTarget eventTarget = targets.get(id); 266 if (eventTarget == null) { 267 eventTarget = determineTarget(evenType, id, matcher.group(4)); 268 targets.put(id, eventTarget); 238 269 } 239 270 IEventType eventType = determineType(evenType, matcher.group(4)); 240 return taskFactory.createNewEventTask(eventType, evenTarget); 271 IEventTask task = taskFactory.createNewEventTask(eventType + " --> " + eventTarget); 272 273 return taskFactory.createNewTaskInstance(task, new Event(eventType, eventTarget)); 241 274 } 242 275 -
trunk/autoquest-test-utils/src/main/java/de/ugoe/cs/autoquest/tasktrees/TaskTreeEncoder.java
r1146 r1294 24 24 import java.util.Map; 25 25 26 import de.ugoe.cs.autoquest.eventcore.Event; 26 27 import de.ugoe.cs.autoquest.eventcore.gui.TextInput; 27 28 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 29 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTaskInstance; 28 30 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 29 31 import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptional; 32 import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptionalInstance; 30 33 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 34 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelectionInstance; 31 35 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 32 36 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; … … 141 145 else if (task instanceof IEventTask) { 142 146 out.print(indent); 143 out.print(((IEventTask) task).getEventType()); 144 out.print(" "); 145 out.print(((IEventTask) task).getEventTarget().getStringIdentifier()); 146 // if (((IEventTask) node).getEventTarget() instanceof IGUIElement) { 147 // out.print(" "); 148 // out.print(((IGUIElement) ((IEventTask) node).getEventTarget()).getSpecification()); 149 // } 147 out.print(task); 150 148 } 151 149 else { … … 154 152 155 153 int i = 0; 156 for (ITaskInstance child : taskInstance.getChildren()) { 157 encode(child, out, indent + " ", i++); 154 155 if (taskInstance instanceof ITaskInstanceList) { 156 for (ITaskInstance child : (ITaskInstanceList) taskInstance) { 157 encode(child, out, indent + " ", i++); 158 } 159 } 160 else if (taskInstance instanceof ISelectionInstance) { 161 encode(((ISelectionInstance) taskInstance).getChild(), out, indent + " ", i++); 162 } 163 else if (taskInstance instanceof IOptionalInstance) { 164 encode(((IOptionalInstance) taskInstance).getChild(), out, indent + " ", i++); 158 165 } 159 166 … … 221 228 } 222 229 else if (task instanceof IEventTask) { 223 if (((IEventTask) task).getEventType() instanceof TextInput) { 230 Event event = ((IEventTaskInstance) taskInstance).getEvent(); 231 if (event.getType() instanceof TextInput) { 224 232 if (id == null) { 225 233 id = "textInput" + typeCounters[3]++; … … 229 237 System.out.print(id); 230 238 System.out.print(" \""); 231 System.out.print(((TextInput) ((IEventTask) task).getEventType()).getEnteredText());239 System.out.print(((TextInput) event.getType()).getEnteredText()); 232 240 System.out.print("\""); 233 241 } … … 240 248 System.out.print(id); 241 249 System.out.print(' '); 242 System.out.print( ((IEventTask) task).getEventType().getName());250 System.out.print(event.getType().getName()); 243 251 } 244 252 System.out.print(" {}\" +"); … … 250 258 taskIds.put(task, id); 251 259 252 for (ITaskInstance child : taskInstance.getChildren()) { 253 dumpTaskInstanceAsCheckString(child, typeCounters, taskIds, indent + " "); 260 if (taskInstance instanceof ITaskInstanceList) { 261 for (ITaskInstance child : (ITaskInstanceList) taskInstance) { 262 dumpTaskInstanceAsCheckString(child, typeCounters, taskIds, indent + " "); 263 } 264 } 265 else if (taskInstance instanceof ISelectionInstance) { 266 dumpTaskInstanceAsCheckString 267 (((ISelectionInstance) taskInstance).getChild(), typeCounters, taskIds, indent + " "); 268 } 269 else if (taskInstance instanceof IOptionalInstance) { 270 dumpTaskInstanceAsCheckString 271 (((IOptionalInstance) taskInstance).getChild(), typeCounters, taskIds, indent + " "); 254 272 } 255 273 -
trunk/autoquest-test-utils/src/main/java/de/ugoe/cs/autoquest/tasktrees/TaskTreeValidator.java
r1146 r1294 20 20 21 21 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 22 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTaskInstance; 22 23 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 24 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIterationInstance; 23 25 import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptional; 26 import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptionalInstance; 24 27 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 28 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelectionInstance; 25 29 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 30 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequenceInstance; 26 31 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 27 32 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; … … 66 71 67 72 assertEquals("number of children of sequence instance must match sequence model", 68 taskInstance.size(), task.getChildren().size());73 ((ISequenceInstance) taskInstance).size(), task.getChildren().size()); 69 74 70 for (int i = 0; i < taskInstance.size(); i++) { 71 assertNotNull("sequence instance child " + i + " was null", taskInstance.get(i)); 72 ITask childTask = taskInstance.get(i).getTask(); 75 for (int i = 0; i < ((ISequenceInstance) taskInstance).size(); i++) { 76 assertNotNull("sequence instance child " + i + " was null", 77 ((ISequenceInstance) taskInstance).get(i)); 78 ITask childTask = ((ISequenceInstance) taskInstance).get(i).getTask(); 73 79 assertSame("task of sequence child " + i + " does not match sequence model", 74 80 childTask, task.getChildren().get(i)); … … 78 84 ISelection task = (ISelection) taskInstance.getTask(); 79 85 80 assert Equals81 ("number of children of selection instance must be 1", 1, taskInstance.size());86 assertNotNull("number of children of selection instance must be 1", 87 ((ISelectionInstance) taskInstance).getChild()); 82 88 assertTrue 83 89 ("number of children of selection must be larger 0", task.getChildren().size() > 0); … … 90 96 assertFalse("child of selection model must not be an optional", 91 97 childTask instanceof IOptional); 92 if (childTask.equals( taskInstance.get(0).getTask())) {98 if (childTask.equals(((ISelectionInstance) taskInstance).getChild().getTask())) { 93 99 found = true; 94 100 break; … … 107 113 childTask instanceof IOptional); 108 114 109 for (int i = 0; i < taskInstance.size(); i++) { 110 assertNotNull("iteration instance child " + i + " was null", taskInstance.get(i)); 115 for (int i = 0; i < ((IIterationInstance) taskInstance).size(); i++) { 116 assertNotNull("iteration instance child " + i + " was null", 117 ((IIterationInstance) taskInstance).get(i)); 111 118 assertSame("task of iteration child " + i + " does not match iteration model", 112 childTask, taskInstance.get(i).getTask());119 childTask, ((IIterationInstance) taskInstance).get(i).getTask()); 113 120 } 114 121 } … … 119 126 childTask instanceof IOptional); 120 127 121 assert Equals122 ("number of children of optional instance must be 1", 1, taskInstance.size());128 assertNotNull("number of children of optional instance must be 1", 129 ((IOptionalInstance) taskInstance).getChild()); 123 130 124 131 assertEquals("task of optional child does not match optional model", 125 childTask, taskInstance.get(0).getTask());132 childTask, ((IOptionalInstance) taskInstance).getChild().getTask()); 126 133 } 127 134 else if (taskInstance.getTask() instanceof IEventTask) { 128 135 IEventTask task = (IEventTask) taskInstance.getTask(); 129 136 assertNotNull("event task model must not be null", task); 130 assertNotNull("event type of event task model must not be null", task.getEventType()); 131 assertNotNull 132 ("event target of event task model must not be null", task.getEventTarget()); 133 134 assertEquals("event task instance must not have children", 0, taskInstance.size()); 137 assertNotNull("event of event task instance must not be null", 138 ((IEventTaskInstance) taskInstance).getEvent()); 135 139 } 136 140 else { … … 138 142 } 139 143 140 for (ITaskInstance child : taskInstance) { 141 validate(child); 144 if (taskInstance instanceof ITaskInstanceList) { 145 for (ITaskInstance child : (ITaskInstanceList) taskInstance) { 146 validate(child); 147 } 148 } 149 else if (taskInstance instanceof ISelectionInstance) { 150 validate(((ISelectionInstance) taskInstance).getChild()); 151 } 152 else if (taskInstance instanceof IOptionalInstance) { 153 validate(((IOptionalInstance) taskInstance).getChild()); 142 154 } 143 155 } -
trunk/autoquest-ui-swt/src/main/java/de/ugoe/cs/autoquest/ui/swt/ShowTaskTreeDialog.java
r1275 r1294 18 18 import java.util.Collections; 19 19 import java.util.Comparator; 20 import java.util.HashSet;21 20 import java.util.LinkedList; 22 21 import java.util.List; 23 import java.util.Set;24 22 25 23 import org.eclipse.swt.SWT; … … 39 37 40 38 import de.ugoe.cs.autoquest.tasktrees.treeifc.IMarkingTemporalRelationship; 39 import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptionalInstance; 40 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelectionInstance; 41 41 import de.ugoe.cs.autoquest.tasktrees.treeifc.IStructuringTemporalRelationship; 42 42 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; … … 173 173 * convenience method for creating the display of the instances 174 174 */ 175 private void buildInstanceTree(TreeItem currentParent, I TaskInstanceList taskInstanceList) {175 private void buildInstanceTree(TreeItem currentParent, IUserSession session) { 176 176 TreeItem child = new TreeItem(currentParent, SWT.NULL); 177 child.setText(taskInstanceList.toString()); 178 child.setData(taskInstanceList); 179 180 for (ITaskInstanceList childTask : taskInstanceList) { 181 buildInstanceTree(child, childTask); 177 child.setText(session.toString()); 178 child.setData(session); 179 180 for (ITaskInstance childInstance : session) { 181 buildInstanceTree(child, childInstance); 182 } 183 } 184 185 /** 186 * convenience method for creating the display of the instances 187 */ 188 private void buildInstanceTree(TreeItem currentParent, ITaskInstance taskInstance) { 189 TreeItem child = new TreeItem(currentParent, SWT.NULL); 190 child.setText(taskInstance.toString()); 191 child.setData(taskInstance); 192 193 if (taskInstance instanceof ITaskInstanceList) { 194 for (ITaskInstance childInstance : (ITaskInstanceList) taskInstance) { 195 buildInstanceTree(child, childInstance); 196 } 197 } 198 else if (taskInstance instanceof ISelectionInstance) { 199 buildInstanceTree(child, ((ISelectionInstance) taskInstance).getChild()); 200 } 201 else if (taskInstance instanceof IOptionalInstance) { 202 buildInstanceTree(child, ((IOptionalInstance) taskInstance).getChild()); 182 203 } 183 204 } … … 229 250 230 251 /** 231 * reduces the list of tasks in a model so that it only contains root nodes and that it is 232 * sorted starting with the most complex task first 252 * sort the list of tasks so that it contain those occurring most often first 233 253 */ 234 254 private List<ITask> createSortedTaskList(Collection<ITask> tasks) { 235 Set<ITask> resultSet = new HashSet<ITask>(tasks);255 /*Set<ITask> resultSet = new HashSet<ITask>(tasks); 236 256 237 257 for (ITask task : tasks) { 238 258 removeChildren(task, resultSet); 239 } 240 241 List<ITask> result = new LinkedList<ITask>( resultSet);259 }*/ 260 261 List<ITask> result = new LinkedList<ITask>(tasks); 242 262 243 263 Collections.sort(result, new Comparator<ITask>() { 244 264 @Override 245 265 public int compare(ITask task1, ITask task2) { 246 return depth(task2) - depth(task1); 247 } 248 249 private int depth(ITask task) { 266 return taskModel.getTaskInfo(task2).getCount() - 267 taskModel.getTaskInfo(task1).getCount(); 268 } 269 270 /*private int depth(ITask task) { 250 271 int maxChildDepth = 0; 251 272 if (task instanceof IStructuringTemporalRelationship) { … … 259 280 } 260 281 return maxChildDepth + 1; 261 } 282 }*/ 262 283 }); 263 284 … … 268 289 * convenience method for removed all non root tasks of the provided list 269 290 */ 270 private void removeChildren(ITask task, Set<ITask> result) {291 /*private void removeChildren(ITask task, Set<ITask> result) { 271 292 if (task instanceof IStructuringTemporalRelationship) { 272 293 for (ITask child : ((IStructuringTemporalRelationship) task).getChildren()) { … … 277 298 result.remove(((IMarkingTemporalRelationship) task).getMarkedTask()); 278 299 } 279 } 300 }*/ 280 301 281 302 /** … … 338 359 private void createTreeItemFor(ITask task, TreeItem parent) { 339 360 TreeItem item = new TreeItem(parent, SWT.NULL); 340 item.setText(task.toString() );361 item.setText(task.toString() + " (" + taskModel.getTaskInfo(task).getCount() + ")"); 341 362 item.setData(task); 342 363
Note: See TracChangeset
for help on using the changeset viewer.