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-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/taskequality/SelectionComparisonRuleTest.java

    r1190 r1294  
    2222import de.ugoe.cs.autoquest.eventcore.IEventType; 
    2323import de.ugoe.cs.autoquest.eventcore.StringEventType; 
    24 import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality; 
    2524import de.ugoe.cs.autoquest.tasktrees.taskequality.SelectionComparisonRule; 
    2625import 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; 
    2926import 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; 
    3327import de.ugoe.cs.autoquest.test.DummyGUIElement; 
    3428 
     
    3630 * @author Patrick Harms 
    3731 */ 
    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          
     32public 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() { 
    48189        SelectionComparisonRule rule = new SelectionComparisonRule(); 
    49190         
     
    54195        IEventTarget eventTarget2 = new DummyGUIElement("elem2"); 
    55196 
    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); 
    106237    } 
    107238 
Note: See TracChangeset for help on using the changeset viewer.