[445] | 1 | // Module : $RCSfile: DefaultIterationDetectionRuleTest.java,v $ |
---|
| 2 | // Version : $Revision: 0.0 $ $Author: patrick $ $Date: 28.04.2012 $ |
---|
| 3 | // Project : TaskTreeTemporalRelationship |
---|
| 4 | // Creation : 2012 by patrick |
---|
| 5 | // Copyright : Patrick Harms, 2012 |
---|
[557] | 6 | |
---|
[445] | 7 | package de.ugoe.cs.quest.tasktrees.temporalrelation; |
---|
| 8 | |
---|
| 9 | import org.junit.Test; |
---|
| 10 | |
---|
[557] | 11 | import de.ugoe.cs.quest.eventcore.IEventTarget; |
---|
| 12 | import de.ugoe.cs.quest.eventcore.IEventType; |
---|
[445] | 13 | import de.ugoe.cs.quest.tasktrees.testutils.DummyGUIElement; |
---|
| 14 | import de.ugoe.cs.quest.tasktrees.testutils.DummyInteraction; |
---|
| 15 | import de.ugoe.cs.quest.tasktrees.testutils.TaskTreeChecker; |
---|
| 16 | |
---|
| 17 | /** |
---|
| 18 | * TODO comment |
---|
| 19 | * |
---|
| 20 | * @version $Revision: $ $Date: 28.04.2012$ |
---|
| 21 | * @author 2012, last modified by $Author: patrick$ |
---|
| 22 | */ |
---|
[557] | 23 | public class DefaultIterationDetectionRuleTest extends AbstractTemporalRelationshipTC { |
---|
[445] | 24 | |
---|
[557] | 25 | /** |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | @Test |
---|
| 29 | public void testInteractionIterationDetection() throws Exception { |
---|
| 30 | IEventTarget element1 = new DummyGUIElement("elem1"); |
---|
| 31 | IEventType event1 = new DummyInteraction("bla", 1); |
---|
| 32 | simulateEvent(event1, element1); |
---|
| 33 | new TaskTreeChecker().assertTaskTree |
---|
| 34 | ("Sequence sequence1 {" + |
---|
| 35 | " Event bla {}" + |
---|
| 36 | "}", getTaskTree()); |
---|
[445] | 37 | |
---|
[557] | 38 | simulateEvent(event1, element1); |
---|
| 39 | new TaskTreeChecker().assertTaskTree |
---|
| 40 | ("Sequence sequence1 {" + |
---|
| 41 | " Iteration iteration1 {" + |
---|
| 42 | " Event bla {}" + |
---|
| 43 | " }" + |
---|
| 44 | "}", getTaskTree()); |
---|
[445] | 45 | |
---|
[557] | 46 | simulateEvent(event1, element1); |
---|
| 47 | new TaskTreeChecker().assertTaskTree |
---|
| 48 | ("Sequence sequence1 {" + |
---|
| 49 | " Iteration iteration1 {" + |
---|
| 50 | " Event bla {}" + |
---|
| 51 | " }" + |
---|
| 52 | "}", getTaskTree()); |
---|
[445] | 53 | |
---|
[557] | 54 | for (int i = 0; i < 10; i++) { |
---|
| 55 | simulateEvent(event1, element1); |
---|
| 56 | } |
---|
[445] | 57 | |
---|
[557] | 58 | new TaskTreeChecker().assertTaskTree |
---|
| 59 | ("Sequence sequence1 {" + |
---|
| 60 | " Iteration iteration1 {" + |
---|
| 61 | " Event bla {}" + |
---|
| 62 | " }" + |
---|
| 63 | "}", getTaskTree()); |
---|
[445] | 64 | |
---|
[557] | 65 | // now test with preceding and trailing other events |
---|
| 66 | IEventType event2 = new DummyInteraction("bli", 1); |
---|
| 67 | IEventType event3 = new DummyInteraction("blup", 1); |
---|
| 68 | |
---|
| 69 | simulateEvent(event2, element1); |
---|
| 70 | simulateEvent(event3, element1); |
---|
| 71 | for (int i = 0; i < 10; i++) { |
---|
| 72 | simulateEvent(event1, element1); |
---|
| 73 | } |
---|
| 74 | simulateEvent(event3, element1); |
---|
| 75 | simulateEvent(event2, element1); |
---|
| 76 | |
---|
| 77 | new TaskTreeChecker().assertTaskTree |
---|
| 78 | ("Sequence sequence1 {" + |
---|
| 79 | " Iteration iteration1 {" + |
---|
| 80 | " Event bla {}" + |
---|
| 81 | " }" + |
---|
| 82 | " Event bli {}" + |
---|
| 83 | " Event blup {}" + |
---|
| 84 | " Iteration iteration2 {" + |
---|
| 85 | " Event bla {}" + |
---|
| 86 | " }" + |
---|
| 87 | " Event blup {}" + |
---|
| 88 | " Event bli {}" + |
---|
| 89 | "}", getTaskTree()); |
---|
| 90 | |
---|
| 91 | // now test with iterations of iterations |
---|
| 92 | |
---|
| 93 | for (int i = 0; i < 10; i++) { |
---|
| 94 | for (int j = 0; j < 5; j++) { |
---|
| 95 | simulateEvent(event1, element1); |
---|
| 96 | } |
---|
| 97 | for (int j = 0; j < 5; j++) { |
---|
| 98 | simulateEvent(event2, element1); |
---|
| 99 | } |
---|
| 100 | for (int j = 0; j < 5; j++) { |
---|
| 101 | simulateEvent(event3, element1); |
---|
| 102 | } |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | new TaskTreeChecker().assertTaskTree |
---|
| 106 | ("Sequence sequence1 {" + |
---|
| 107 | " Iteration iteration1 {" + |
---|
| 108 | " Event bla {}" + |
---|
| 109 | " }" + |
---|
| 110 | " Event bli {}" + |
---|
| 111 | " Event blup {}" + |
---|
| 112 | " Iteration iteration2 {" + |
---|
| 113 | " Event bla {}" + |
---|
| 114 | " }" + |
---|
| 115 | " Event blup {}" + |
---|
| 116 | " Event bli {}" + |
---|
| 117 | " Iteration iteration3 {" + |
---|
| 118 | " Sequence sequence2 {" + |
---|
| 119 | " Iteration iteration4 {" + |
---|
| 120 | " Event bla {}" + |
---|
| 121 | " }" + |
---|
| 122 | " Iteration iteration5 {" + |
---|
| 123 | " Event bli {}" + |
---|
| 124 | " }" + |
---|
| 125 | " Iteration iteration6 {" + |
---|
| 126 | " Event blup {}" + |
---|
| 127 | " }" + |
---|
| 128 | " }" + |
---|
| 129 | " }" + |
---|
| 130 | "}", getTaskTree()); |
---|
| 131 | |
---|
[445] | 132 | } |
---|
| 133 | |
---|
[557] | 134 | /** |
---|
| 135 | * |
---|
| 136 | */ |
---|
| 137 | @Test |
---|
| 138 | public void testSequenceIterationDetection() throws Exception { |
---|
| 139 | IEventTarget element1 = new DummyGUIElement("elem1"); |
---|
| 140 | IEventType event1 = new DummyInteraction("bla", 1); |
---|
| 141 | IEventType event2 = new DummyInteraction("bli", 1); |
---|
| 142 | IEventType event3 = new DummyInteraction("blup", 1); |
---|
| 143 | simulateEvent(event1, element1); |
---|
| 144 | simulateEvent(event2, element1); |
---|
| 145 | simulateEvent(event3, element1); |
---|
| 146 | new TaskTreeChecker().assertTaskTree |
---|
| 147 | ("Sequence sequence1 {" + |
---|
| 148 | " Event bla {}" + |
---|
| 149 | " Event bli {}" + |
---|
| 150 | " Event blup {}" + |
---|
| 151 | "}", getTaskTree()); |
---|
[445] | 152 | |
---|
[557] | 153 | simulateEvent(event1, element1); |
---|
| 154 | simulateEvent(event2, element1); |
---|
| 155 | simulateEvent(event3, element1); |
---|
| 156 | new TaskTreeChecker().assertTaskTree |
---|
| 157 | ("Sequence sequence1 {" + |
---|
| 158 | " Iteration iteration1 {" + |
---|
| 159 | " Sequence sequence2 {" + |
---|
| 160 | " Event bla {}" + |
---|
| 161 | " Event bli {}" + |
---|
| 162 | " Event blup {}" + |
---|
| 163 | " }" + |
---|
| 164 | " }" + |
---|
| 165 | "}", getTaskTree()); |
---|
[445] | 166 | |
---|
[557] | 167 | simulateEvent(event1, element1); |
---|
| 168 | simulateEvent(event2, element1); |
---|
| 169 | simulateEvent(event3, element1); |
---|
| 170 | new TaskTreeChecker().assertTaskTree |
---|
| 171 | ("Sequence sequence1 {" + |
---|
| 172 | " Iteration iteration1 {" + |
---|
| 173 | " Sequence sequence2 {" + |
---|
| 174 | " Event bla {}" + |
---|
| 175 | " Event bli {}" + |
---|
| 176 | " Event blup {}" + |
---|
| 177 | " }" + |
---|
| 178 | " }" + |
---|
| 179 | "}", getTaskTree()); |
---|
| 180 | |
---|
| 181 | for (int i = 0; i < 10; i++) { |
---|
| 182 | simulateEvent(event1, element1); |
---|
| 183 | simulateEvent(event2, element1); |
---|
| 184 | simulateEvent(event3, element1); |
---|
| 185 | } |
---|
| 186 | |
---|
| 187 | new TaskTreeChecker().assertTaskTree |
---|
| 188 | ("Sequence sequence1 {" + |
---|
| 189 | " Iteration iteration1 {" + |
---|
| 190 | " Sequence sequence2 {" + |
---|
| 191 | " Event bla {}" + |
---|
| 192 | " Event bli {}" + |
---|
| 193 | " Event blup {}" + |
---|
| 194 | " }" + |
---|
| 195 | " }" + |
---|
| 196 | "}", getTaskTree()); |
---|
| 197 | |
---|
| 198 | // now test with preceding and trailing other events |
---|
| 199 | IEventType event4 = new DummyInteraction("ble", 1); |
---|
| 200 | IEventType event5 = new DummyInteraction("blo", 1); |
---|
| 201 | IEventType event6 = new DummyInteraction("blu", 1); |
---|
| 202 | simulateEvent(event4, element1); |
---|
| 203 | simulateEvent(event5, element1); |
---|
| 204 | simulateEvent(event6, element1); |
---|
| 205 | for (int i = 0; i < 10; i++) { |
---|
| 206 | simulateEvent(event1, element1); |
---|
| 207 | simulateEvent(event2, element1); |
---|
| 208 | simulateEvent(event3, element1); |
---|
| 209 | } |
---|
| 210 | simulateEvent(event6, element1); |
---|
| 211 | simulateEvent(event5, element1); |
---|
| 212 | simulateEvent(event4, element1); |
---|
| 213 | |
---|
| 214 | new TaskTreeChecker().assertTaskTree |
---|
| 215 | ("Sequence sequence1 {" + |
---|
| 216 | " Iteration iteration1 {" + |
---|
| 217 | " Sequence sequence2 {" + |
---|
| 218 | " Event bla {}" + |
---|
| 219 | " Event bli {}" + |
---|
| 220 | " Event blup {}" + |
---|
| 221 | " }" + |
---|
| 222 | " }" + |
---|
| 223 | " Event ble {}" + |
---|
| 224 | " Event blo {}" + |
---|
| 225 | " Event blu {}" + |
---|
| 226 | " Iteration iteration2 {" + |
---|
| 227 | " Sequence sequence3 {" + |
---|
| 228 | " Event bla {}" + |
---|
| 229 | " Event bli {}" + |
---|
| 230 | " Event blup {}" + |
---|
| 231 | " }" + |
---|
| 232 | " }" + |
---|
| 233 | " Event blu {}" + |
---|
| 234 | " Event blo {}" + |
---|
| 235 | " Event ble {}" + |
---|
| 236 | "}", getTaskTree()); |
---|
| 237 | |
---|
| 238 | // now test with iterations of iterations |
---|
| 239 | for (int i = 0; i < 10; i++) { |
---|
| 240 | for (int j = 0; j < 5; j++) { |
---|
| 241 | simulateEvent(event1, element1); |
---|
| 242 | simulateEvent(event2, element1); |
---|
| 243 | simulateEvent(event3, element1); |
---|
| 244 | } |
---|
| 245 | for (int j = 0; j < 5; j++) { |
---|
| 246 | simulateEvent(event2, element1); |
---|
| 247 | simulateEvent(event1, element1); |
---|
| 248 | simulateEvent(event3, element1); |
---|
| 249 | } |
---|
| 250 | for (int j = 0; j < 5; j++) { |
---|
| 251 | simulateEvent(event1, element1); |
---|
| 252 | simulateEvent(event2, element1); |
---|
| 253 | simulateEvent(event3, element1); |
---|
| 254 | } |
---|
| 255 | } |
---|
| 256 | |
---|
| 257 | new TaskTreeChecker().assertTaskTree |
---|
| 258 | ("Sequence sequence1 {" + |
---|
| 259 | " Iteration iteration1 {" + |
---|
| 260 | " Sequence sequence2 {" + |
---|
| 261 | " Event bla {}" + |
---|
| 262 | " Event bli {}" + |
---|
| 263 | " Event blup {}" + |
---|
| 264 | " }" + |
---|
| 265 | " }" + |
---|
| 266 | " Event ble {}" + |
---|
| 267 | " Event blo {}" + |
---|
| 268 | " Event blu {}" + |
---|
| 269 | " Iteration iteration2 {" + |
---|
| 270 | " Sequence sequence3 {" + |
---|
| 271 | " Event bla {}" + |
---|
| 272 | " Event bli {}" + |
---|
| 273 | " Event blup {}" + |
---|
| 274 | " }" + |
---|
| 275 | " }" + |
---|
| 276 | " Event blu {}" + |
---|
| 277 | " Event blo {}" + |
---|
| 278 | " Event ble {}" + |
---|
| 279 | " Iteration iteration3 {" + |
---|
| 280 | " Sequence sequence4 {" + |
---|
| 281 | " Iteration iteration4 {" + |
---|
| 282 | " Sequence sequence4 {" + |
---|
| 283 | " Event bla {}" + |
---|
| 284 | " Event bli {}" + |
---|
| 285 | " Event blup {}" + |
---|
| 286 | " }" + |
---|
| 287 | " }" + |
---|
| 288 | " Iteration iteration5 {" + |
---|
| 289 | " Sequence sequence5 {" + |
---|
| 290 | " Event bli {}" + |
---|
| 291 | " Event bla {}" + |
---|
| 292 | " Event blup {}" + |
---|
| 293 | " }" + |
---|
| 294 | " }" + |
---|
| 295 | " Iteration iteration6 {" + |
---|
| 296 | " Sequence sequence6 {" + |
---|
| 297 | " Event bla {}" + |
---|
| 298 | " Event bli {}" + |
---|
| 299 | " Event blup {}" + |
---|
| 300 | " }" + |
---|
| 301 | " }" + |
---|
| 302 | " }" + |
---|
| 303 | " }" + |
---|
| 304 | "}", getTaskTree()); |
---|
[445] | 305 | } |
---|
[557] | 306 | |
---|
[445] | 307 | } |
---|