Changeset 1333 for trunk/autoquest-test-utils/src/main/java/de/ugoe/cs
- Timestamp:
- 01/24/14 13:48:25 (11 years ago)
- Location:
- trunk/autoquest-test-utils/src/main/java/de/ugoe/cs/autoquest/tasktrees
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-test-utils/src/main/java/de/ugoe/cs/autoquest/tasktrees/TaskTreeDecoder.java
r1327 r1333 29 29 import de.ugoe.cs.autoquest.eventcore.IEventType; 30 30 import de.ugoe.cs.autoquest.eventcore.StringEventType; 31 import de.ugoe.cs.autoquest.eventcore.gui.Scroll; 31 32 import de.ugoe.cs.autoquest.eventcore.gui.TextInput; 32 33 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; … … 103 104 correctTargets(taskInstanceList); 104 105 106 // validate the instance list 107 try { 108 new TaskTreeValidator().validate(taskInstanceList); 109 } 110 catch (java.lang.AssertionError e) { 111 throw new IllegalArgumentException(e.getMessage(), e); 112 } 113 105 114 return taskInstanceList; 106 115 } … … 226 235 } 227 236 228 // validate the instance229 try {230 new TaskTreeValidator().validate(instance);231 }232 catch (java.lang.AssertionError e) {233 throw new IllegalArgumentException(e.getMessage(), e);234 }235 236 237 return instance; 237 238 } … … 318 319 } 319 320 } 321 else if ("Optional".equals(type)) { 322 // update the optional with what is optional if available 323 if (children.size() == 1) { 324 ITask newChildTask = children.get(0).getTask(); 325 326 if (((IOptional) task).getMarkedTask() == null) { 327 taskBuilder.setMarkedTask((IOptional) task, newChildTask); 328 } 329 else if (!((IOptional) task).getMarkedTask().equals(newChildTask)) { 330 throw new IllegalArgumentException("all children of the same optional must " + 331 "be of an identical task model."); 332 } 333 } 334 } 320 335 321 336 return task; … … 349 364 * @return 350 365 */ 351 private IEventType determineType(String type, String enteredText) {366 private IEventType determineType(String type, String additionalInfo) { 352 367 if ("TextInput".equals(type)) { 353 return new TextInput(enteredText, new ArrayList<Event>()); 368 return new TextInput(additionalInfo, new ArrayList<Event>()); 369 } 370 else if ("Scroll".equals(type)) { 371 int x = 0; 372 int y = 0; 373 if (additionalInfo != null) { 374 String[] parts = additionalInfo.split(" "); 375 if (parts.length > 0) { 376 try { 377 x = Integer.parseInt(parts[0]); 378 } 379 catch (NumberFormatException e) { 380 throw new IllegalArgumentException("could not parse scroll coordinates", e); 381 } 382 } 383 if (parts.length > 1) { 384 try { 385 y = Integer.parseInt(parts[1]); 386 } 387 catch (NumberFormatException e) { 388 throw new IllegalArgumentException("could not parse scroll coordinates", e); 389 } 390 } 391 } 392 return new Scroll(x, y); 354 393 } 355 394 else { … … 428 467 else if (instance instanceof IOptionalInstance) { 429 468 IOptionalInstance optInst = (IOptionalInstance) instance; 430 taskBuilder.setChild(optInst, replaceTargets(optInst.getChild(), replacements)); 469 if (optInst.getChild() != null) { 470 taskBuilder.setChild(optInst, replaceTargets(optInst.getChild(), replacements)); 471 } 431 472 } 432 473 else if ((instance instanceof IEventTaskInstance) && -
trunk/autoquest-test-utils/src/main/java/de/ugoe/cs/autoquest/tasktrees/TaskTreeValidator.java
r1294 r1333 126 126 childTask instanceof IOptional); 127 127 128 assertNotNull("number of children of optional instance must be 1", 129 ((IOptionalInstance) taskInstance).getChild()); 130 131 assertEquals("task of optional child does not match optional model", 132 childTask, ((IOptionalInstance) taskInstance).getChild().getTask()); 128 if (((IOptionalInstance) taskInstance).getChild() != null) { 129 assertEquals("task of optional child does not match optional model", 130 childTask, ((IOptionalInstance) taskInstance).getChild().getTask()); 131 } 133 132 } 134 133 else if (taskInstance.getTask() instanceof IEventTask) { … … 151 150 } 152 151 else if (taskInstance instanceof IOptionalInstance) { 153 validate(((IOptionalInstance) taskInstance).getChild()); 152 if (((IOptionalInstance) taskInstance).getChild() != null) { 153 validate(((IOptionalInstance) taskInstance).getChild()); 154 } 154 155 } 155 156 }
Note: See TracChangeset
for help on using the changeset viewer.