[927] | 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 | |
---|
[1146] | 15 | package de.ugoe.cs.autoquest.tasktrees.taskequality; |
---|
[817] | 16 | |
---|
| 17 | import static org.junit.Assert.*; |
---|
| 18 | |
---|
| 19 | import org.junit.Test; |
---|
| 20 | |
---|
[1146] | 21 | import de.ugoe.cs.autoquest.eventcore.IEventTarget; |
---|
| 22 | import de.ugoe.cs.autoquest.eventcore.IEventType; |
---|
| 23 | import de.ugoe.cs.autoquest.eventcore.StringEventType; |
---|
| 24 | import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskAndIterationComparisonRule; |
---|
[922] | 25 | import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; |
---|
| 26 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; |
---|
[1146] | 27 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; |
---|
| 28 | import de.ugoe.cs.autoquest.test.DummyGUIElement; |
---|
[817] | 29 | |
---|
| 30 | /** |
---|
| 31 | * @author Patrick Harms |
---|
| 32 | */ |
---|
[1294] | 33 | public class TaskAndIterationComparisonRuleTest extends AbstractComparisonRuleTest { |
---|
[817] | 34 | |
---|
| 35 | /** |
---|
| 36 | * |
---|
| 37 | */ |
---|
| 38 | @Test |
---|
[1294] | 39 | public void test_isApplicable_01() { |
---|
| 40 | TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); |
---|
[817] | 41 | |
---|
[1294] | 42 | ITask task1 = createNewSequence(); |
---|
| 43 | |
---|
| 44 | assertFalse(rule.isApplicable(task1, task1)); |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | /** |
---|
| 48 | * |
---|
| 49 | */ |
---|
| 50 | @Test |
---|
| 51 | public void test_isApplicable_02() { |
---|
[1190] | 52 | TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); |
---|
[817] | 53 | |
---|
[1294] | 54 | ITask task1 = createNewSelection(); |
---|
| 55 | |
---|
| 56 | assertFalse(rule.isApplicable(task1, task1)); |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | /** |
---|
| 60 | * |
---|
| 61 | */ |
---|
| 62 | @Test |
---|
| 63 | public void test_isApplicable_03() { |
---|
| 64 | TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); |
---|
| 65 | |
---|
| 66 | ITask task1 = createNewIteration(); |
---|
| 67 | |
---|
| 68 | assertFalse(rule.isApplicable(task1, task1)); |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | /** |
---|
| 72 | * |
---|
| 73 | */ |
---|
| 74 | @Test |
---|
| 75 | public void test_isApplicable_04() { |
---|
| 76 | TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); |
---|
| 77 | |
---|
| 78 | ITask task1 = createNewOptional(); |
---|
| 79 | |
---|
| 80 | assertFalse(rule.isApplicable(task1, task1)); |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | /** |
---|
| 84 | * |
---|
| 85 | */ |
---|
| 86 | @Test |
---|
| 87 | public void test_isApplicable_05() { |
---|
| 88 | TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); |
---|
| 89 | |
---|
[1146] | 90 | IEventType eventType1 = new StringEventType("eventType1"); |
---|
| 91 | IEventTarget eventTarget1 = new DummyGUIElement("elem1"); |
---|
[1294] | 92 | |
---|
| 93 | ITask task1 = createNewEventTask(eventType1, eventTarget1); |
---|
[817] | 94 | |
---|
[1294] | 95 | assertFalse(rule.isApplicable(task1, task1)); |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | /** |
---|
| 99 | * |
---|
| 100 | */ |
---|
| 101 | @Test |
---|
| 102 | public void test_isApplicable_06() { |
---|
| 103 | TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); |
---|
| 104 | |
---|
| 105 | ITask task1 = createNewIteration(); |
---|
| 106 | ITask task2 = createNewSequence(); |
---|
[817] | 107 | |
---|
[1294] | 108 | assertTrue(rule.isApplicable(task1, task2)); |
---|
| 109 | assertTrue(rule.isApplicable(task2, task1)); |
---|
| 110 | } |
---|
[817] | 111 | |
---|
[1294] | 112 | /** |
---|
| 113 | * |
---|
| 114 | */ |
---|
| 115 | @Test |
---|
| 116 | public void test_isApplicable_07() { |
---|
| 117 | TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); |
---|
| 118 | |
---|
| 119 | ITask task1 = createNewIteration(); |
---|
| 120 | ITask task2 = createNewSelection(); |
---|
[817] | 121 | |
---|
[1294] | 122 | assertTrue(rule.isApplicable(task1, task2)); |
---|
| 123 | assertTrue(rule.isApplicable(task2, task1)); |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | /** |
---|
| 127 | * |
---|
| 128 | */ |
---|
| 129 | @Test |
---|
| 130 | public void test_isApplicable_08() { |
---|
| 131 | TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); |
---|
| 132 | |
---|
| 133 | ITask task1 = createNewIteration(); |
---|
| 134 | ITask task2 = createNewOptional(); |
---|
[817] | 135 | |
---|
[1294] | 136 | assertTrue(rule.isApplicable(task1, task2)); |
---|
| 137 | assertTrue(rule.isApplicable(task2, task1)); |
---|
| 138 | } |
---|
| 139 | |
---|
| 140 | /** |
---|
| 141 | * |
---|
| 142 | */ |
---|
| 143 | @Test |
---|
| 144 | public void test_isApplicable_09() { |
---|
| 145 | TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); |
---|
| 146 | |
---|
| 147 | ITask task1 = createNewIteration(); |
---|
[817] | 148 | |
---|
[1294] | 149 | IEventType eventType1 = new StringEventType("eventType1"); |
---|
| 150 | IEventTarget eventTarget1 = new DummyGUIElement("elem1"); |
---|
| 151 | |
---|
| 152 | ITask task2 = createNewEventTask(eventType1, eventTarget1); |
---|
| 153 | |
---|
| 154 | assertTrue(rule.isApplicable(task1, task2)); |
---|
| 155 | assertTrue(rule.isApplicable(task2, task1)); |
---|
[817] | 156 | } |
---|
| 157 | |
---|
[1294] | 158 | /** |
---|
| 159 | * |
---|
| 160 | */ |
---|
| 161 | @Test |
---|
| 162 | public void test_isApplicable_10() { |
---|
| 163 | TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); |
---|
| 164 | |
---|
| 165 | ITask task1 = createNewSequence(); |
---|
| 166 | ITask task2 = createNewSelection(); |
---|
| 167 | |
---|
| 168 | assertFalse(rule.isApplicable(task1, task2)); |
---|
| 169 | assertFalse(rule.isApplicable(task2, task1)); |
---|
| 170 | } |
---|
| 171 | |
---|
| 172 | /** |
---|
| 173 | * |
---|
| 174 | */ |
---|
| 175 | @Test |
---|
| 176 | public void test_isApplicable_11() { |
---|
| 177 | TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); |
---|
| 178 | |
---|
| 179 | ITask task1 = createNewSequence(); |
---|
| 180 | ITask task2 = createNewOptional(); |
---|
| 181 | |
---|
| 182 | assertFalse(rule.isApplicable(task1, task2)); |
---|
| 183 | assertFalse(rule.isApplicable(task2, task1)); |
---|
| 184 | } |
---|
| 185 | |
---|
| 186 | /** |
---|
| 187 | * |
---|
| 188 | */ |
---|
| 189 | @Test |
---|
| 190 | public void test_isApplicable_12() { |
---|
| 191 | TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); |
---|
| 192 | |
---|
| 193 | ITask task1 = createNewSequence(); |
---|
| 194 | |
---|
| 195 | IEventType eventType1 = new StringEventType("eventType1"); |
---|
| 196 | IEventTarget eventTarget1 = new DummyGUIElement("elem1"); |
---|
| 197 | |
---|
| 198 | ITask task2 = createNewEventTask(eventType1, eventTarget1); |
---|
| 199 | |
---|
| 200 | assertFalse(rule.isApplicable(task1, task2)); |
---|
| 201 | assertFalse(rule.isApplicable(task2, task1)); |
---|
| 202 | } |
---|
| 203 | |
---|
| 204 | /** |
---|
| 205 | * |
---|
| 206 | */ |
---|
| 207 | @Test |
---|
| 208 | public void test_isApplicable_13() { |
---|
| 209 | TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); |
---|
| 210 | |
---|
| 211 | ITask task1 = createNewSelection(); |
---|
| 212 | ITask task2 = createNewOptional(); |
---|
| 213 | |
---|
| 214 | assertFalse(rule.isApplicable(task1, task2)); |
---|
| 215 | assertFalse(rule.isApplicable(task2, task1)); |
---|
| 216 | } |
---|
| 217 | |
---|
| 218 | /** |
---|
| 219 | * |
---|
| 220 | */ |
---|
| 221 | @Test |
---|
| 222 | public void test_isApplicable_14() { |
---|
| 223 | TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); |
---|
| 224 | |
---|
| 225 | ITask task1 = createNewSelection(); |
---|
| 226 | |
---|
| 227 | IEventType eventType1 = new StringEventType("eventType1"); |
---|
| 228 | IEventTarget eventTarget1 = new DummyGUIElement("elem1"); |
---|
| 229 | |
---|
| 230 | ITask task2 = createNewEventTask(eventType1, eventTarget1); |
---|
| 231 | |
---|
| 232 | assertFalse(rule.isApplicable(task1, task2)); |
---|
| 233 | assertFalse(rule.isApplicable(task2, task1)); |
---|
| 234 | } |
---|
| 235 | |
---|
| 236 | /** |
---|
| 237 | * |
---|
| 238 | */ |
---|
| 239 | @Test |
---|
| 240 | public void test_compare_01() { |
---|
| 241 | TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); |
---|
| 242 | |
---|
| 243 | IEventType eventType1 = new StringEventType("eventType1"); |
---|
| 244 | IEventTarget eventTarget1 = new DummyGUIElement("elem1"); |
---|
| 245 | ITask task1 = createNewEventTask(eventType1, eventTarget1); |
---|
| 246 | |
---|
| 247 | IIteration iteration1 = createNewIteration(); |
---|
| 248 | |
---|
| 249 | assertNullEquality(rule, iteration1, task1); |
---|
| 250 | } |
---|
| 251 | |
---|
| 252 | /** |
---|
| 253 | * |
---|
| 254 | */ |
---|
| 255 | @Test |
---|
| 256 | public void test_compare_02() { |
---|
| 257 | TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); |
---|
| 258 | |
---|
| 259 | IEventType eventType1 = new StringEventType("eventType1"); |
---|
| 260 | IEventTarget eventTarget1 = new DummyGUIElement("elem1"); |
---|
| 261 | ITask task1 = createNewEventTask(eventType1, eventTarget1); |
---|
| 262 | |
---|
| 263 | IIteration iteration1 = createNewIteration(); |
---|
| 264 | setMarkedTask(iteration1, task1); |
---|
| 265 | |
---|
| 266 | assertLexicallyEqual(rule, task1, iteration1); |
---|
| 267 | } |
---|
| 268 | |
---|
| 269 | /** |
---|
| 270 | * |
---|
| 271 | */ |
---|
| 272 | @Test |
---|
| 273 | public void test_compare_03() { |
---|
| 274 | TaskAndIterationComparisonRule rule = new TaskAndIterationComparisonRule(); |
---|
| 275 | |
---|
| 276 | IEventType eventType1 = new StringEventType("eventType1"); |
---|
| 277 | IEventTarget eventTarget1 = new DummyGUIElement("elem1"); |
---|
| 278 | ITask task1 = createNewEventTask(eventType1, eventTarget1); |
---|
| 279 | |
---|
| 280 | IIteration iteration1 = createNewIteration(); |
---|
| 281 | |
---|
| 282 | ISelection selection1 = createNewSelection(); |
---|
| 283 | addChild(selection1, task1); |
---|
| 284 | setMarkedTask(iteration1, selection1); |
---|
| 285 | |
---|
| 286 | assertLexicallyEqual(rule, task1, iteration1); |
---|
| 287 | } |
---|
| 288 | |
---|
[817] | 289 | } |
---|