source: branches/autoquest-core-tasktrees-alignment-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/taskequality/SequenceComparisonRuleTest.java @ 1735

Last change on this file since 1735 was 1294, checked in by pharms, 11 years ago
  • rework of task model to move event instance stuff to task instances
  • introduction of sequence, selection, iteration and optional instances
File size: 7.7 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.SequenceComparisonRule;
25import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence;
26import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask;
27import de.ugoe.cs.autoquest.test.DummyGUIElement;
28
29/**
30 * @author Patrick Harms
31 */
32public 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() {
189        SequenceComparisonRule rule = new SequenceComparisonRule();
190       
191        IEventType eventType1 = new StringEventType("eventType1");
192        IEventTarget eventTarget1 = new DummyGUIElement("elem1");
193
194        IEventType eventType2 = new StringEventType("eventType2");
195        IEventTarget eventTarget2 = new DummyGUIElement("elem2");
196
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);
265    }
266
267}
Note: See TracBrowser for help on using the repository browser.