source: trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/taskequality/EventTaskComparisonRuleTest.java @ 1146

Last change on this file since 1146 was 1146, checked in by pharms, 11 years ago
  • complete refactoring of task tree model with a separation of task models and task instances
  • appropriate adaptation of task tree generation process
  • appropriate adaptation of commands and task tree visualization
File size: 9.9 KB
Line 
1//   Copyright 2012 Georg-August-Universität Göttingen, Germany
2//
3//   Licensed under the Apache License, Version 2.0 (the "License");
4//   you may not use this file except in compliance with the License.
5//   You may obtain a copy of the License at
6//
7//       http://www.apache.org/licenses/LICENSE-2.0
8//
9//   Unless required by applicable law or agreed to in writing, software
10//   distributed under the License is distributed on an "AS IS" BASIS,
11//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//   See the License for the specific language governing permissions and
13//   limitations under the License.
14
15package de.ugoe.cs.autoquest.tasktrees.taskequality;
16
17import static org.junit.Assert.*;
18
19import org.junit.Test;
20
21import de.ugoe.cs.autoquest.eventcore.IEventTarget;
22import de.ugoe.cs.autoquest.eventcore.IEventType;
23import de.ugoe.cs.autoquest.eventcore.StringEventType;
24import de.ugoe.cs.autoquest.tasktrees.taskequality.EventTaskComparisonRule;
25import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality;
26import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask;
27import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory;
28import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskFactory;
29import de.ugoe.cs.autoquest.test.DummyGUIElement;
30
31/**
32 * @author Patrick Harms
33 */
34public class EventTaskComparisonRuleTest {
35
36    /**
37     *
38     */
39    @Test
40    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);
48
49        assertTrue(rule.isApplicable(task1, task1));
50    }
51   
52    /**
53     *
54     */
55    @Test
56    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);
64
65        IEventType eventType2 = new StringEventType("eventType2");
66        IEventTarget eventTarget2 = new DummyGUIElement("elem2");
67        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2);
68
69        assertTrue(rule.isApplicable(task1, task2));
70        assertTrue(rule.isApplicable(task2, task1));
71    }
72   
73    /**
74     *
75     */
76    @Test
77    public void test_isApplicable_03() {
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);
85       
86        ITask selection = taskFactory.createNewSelection();
87
88        assertFalse(rule.isApplicable(task1, selection));
89        assertFalse(rule.isApplicable(selection, task1));
90    }
91   
92    /**
93     *
94     */
95    @Test
96    public void test_isApplicable_04() {
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();
106
107        assertFalse(rule.isApplicable(task1, sequence));
108        assertFalse(rule.isApplicable(sequence, task1));
109    }
110   
111    /**
112     *
113     */
114    @Test
115    public void test_isApplicable_05() {
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();
125
126        assertFalse(rule.isApplicable(task1, iteration));
127        assertFalse(rule.isApplicable(iteration, task1));
128    }
129   
130    /**
131     *
132     */
133    @Test
134    public void test_isApplicable_06() {
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();
144
145        assertFalse(rule.isApplicable(task1, optional));
146        assertFalse(rule.isApplicable(optional, task1));
147    }
148   
149    /**
150     *
151     */
152    @Test
153    public void test_compare_01() {
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);
161       
162        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(task1, task1));
163        assertTrue(rule.areLexicallyEqual(task1, task1));
164        assertTrue(rule.areSyntacticallyEqual(task1, task1));
165        assertTrue(rule.areSemanticallyEqual(task1, task1));
166    }
167   
168    /**
169     *
170     */
171    @Test
172    public void test_compare_02() {
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);
182       
183        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(task1, task2));
184        assertTrue(rule.areLexicallyEqual(task1, task2));
185        assertTrue(rule.areSyntacticallyEqual(task1, task2));
186        assertTrue(rule.areSemanticallyEqual(task1, task2));
187
188        assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(task2, task1));
189        assertTrue(rule.areLexicallyEqual(task2, task1));
190        assertTrue(rule.areSyntacticallyEqual(task2, task1));
191        assertTrue(rule.areSemanticallyEqual(task2, task1));
192    }
193
194    /**
195     *
196     */
197    @Test
198    public void test_compare_03() {
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);
206       
207        IEventType eventType2 = new StringEventType("eventType2");
208        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget1);
209
210        assertEquals(TaskEquality.UNEQUAL, rule.compare(task1, task2));
211        assertFalse(rule.areLexicallyEqual(task1, task2));
212        assertFalse(rule.areSyntacticallyEqual(task1, task2));
213        assertFalse(rule.areSemanticallyEqual(task1, task2));
214
215        assertEquals(TaskEquality.UNEQUAL, rule.compare(task2, task1));
216        assertFalse(rule.areLexicallyEqual(task2, task1));
217        assertFalse(rule.areSyntacticallyEqual(task2, task1));
218        assertFalse(rule.areSemanticallyEqual(task2, task1));
219    }
220
221    /**
222     *
223     */
224    @Test
225    public void test_compare_04() {
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);
233       
234        IEventTarget eventTarget2 = new DummyGUIElement("elem2");
235        ITask task2 = taskFactory.createNewEventTask(eventType1, eventTarget2);
236       
237        assertEquals(TaskEquality.UNEQUAL, rule.compare(task1, task2));
238        assertFalse(rule.areLexicallyEqual(task1, task2));
239        assertFalse(rule.areSyntacticallyEqual(task1, task2));
240        assertFalse(rule.areSemanticallyEqual(task1, task2));
241
242        assertEquals(TaskEquality.UNEQUAL, rule.compare(task2, task1));
243        assertFalse(rule.areLexicallyEqual(task2, task1));
244        assertFalse(rule.areSyntacticallyEqual(task2, task1));
245        assertFalse(rule.areSemanticallyEqual(task2, task1));
246    }
247
248
249    /**
250     *
251     */
252    @Test
253    public void test_compare_05() {
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);
261       
262        IEventType eventType2 = new StringEventType("eventType2");
263        IEventTarget eventTarget2 = new DummyGUIElement("elem2");
264        ITask task2 = taskFactory.createNewEventTask(eventType2, eventTarget2);
265       
266        assertEquals(TaskEquality.UNEQUAL, rule.compare(task1, task2));
267        assertFalse(rule.areLexicallyEqual(task1, task2));
268        assertFalse(rule.areSyntacticallyEqual(task1, task2));
269        assertFalse(rule.areSemanticallyEqual(task1, task2));
270
271        assertEquals(TaskEquality.UNEQUAL, rule.compare(task2, task1));
272        assertFalse(rule.areLexicallyEqual(task2, task1));
273        assertFalse(rule.areSyntacticallyEqual(task2, task1));
274        assertFalse(rule.areSemanticallyEqual(task2, task1));
275    }
276
277}
Note: See TracBrowser for help on using the repository browser.