Ignore:
Timestamp:
08/14/13 17:04:42 (11 years ago)
Author:
pharms
Message:
  • rework of task model to move event instance stuff to task instances
  • introduction of sequence, selection, iteration and optional instances
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-test-utils/src/main/java/de/ugoe/cs/autoquest/tasktrees/TaskTreeValidator.java

    r1146 r1294  
    2020 
    2121import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 
     22import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTaskInstance; 
    2223import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 
     24import de.ugoe.cs.autoquest.tasktrees.treeifc.IIterationInstance; 
    2325import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptional; 
     26import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptionalInstance; 
    2427import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 
     28import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelectionInstance; 
    2529import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 
     30import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequenceInstance; 
    2631import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
    2732import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 
     
    6671             
    6772            assertEquals("number of children of sequence instance must match sequence model", 
    68                          taskInstance.size(), task.getChildren().size()); 
     73                         ((ISequenceInstance) taskInstance).size(), task.getChildren().size()); 
    6974             
    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(); 
    7379                assertSame("task of sequence child " + i + " does not match sequence model", 
    7480                           childTask, task.getChildren().get(i)); 
     
    7884            ISelection task = (ISelection) taskInstance.getTask(); 
    7985             
    80             assertEquals 
    81                 ("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()); 
    8288            assertTrue 
    8389                ("number of children of selection must be larger 0", task.getChildren().size() > 0); 
     
    9096                assertFalse("child of selection model must not be an optional", 
    9197                            childTask instanceof IOptional); 
    92                 if (childTask.equals(taskInstance.get(0).getTask())) { 
     98                if (childTask.equals(((ISelectionInstance) taskInstance).getChild().getTask())) { 
    9399                    found = true; 
    94100                    break; 
     
    107113                        childTask instanceof IOptional); 
    108114             
    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)); 
    111118                assertSame("task of iteration child " + i + " does not match iteration model", 
    112                            childTask, taskInstance.get(i).getTask()); 
     119                           childTask, ((IIterationInstance) taskInstance).get(i).getTask()); 
    113120            } 
    114121        } 
     
    119126                        childTask instanceof IOptional); 
    120127             
    121             assertEquals 
    122                 ("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()); 
    123130             
    124131            assertEquals("task of optional child does not match optional model", 
    125                          childTask, taskInstance.get(0).getTask()); 
     132                         childTask, ((IOptionalInstance) taskInstance).getChild().getTask()); 
    126133        } 
    127134        else if (taskInstance.getTask() instanceof IEventTask) { 
    128135            IEventTask task = (IEventTask) taskInstance.getTask(); 
    129136            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()); 
    135139        } 
    136140        else { 
     
    138142        } 
    139143         
    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()); 
    142154        } 
    143155    } 
Note: See TracChangeset for help on using the changeset viewer.