Changeset 1171 for trunk/autoquest-core-usability-evaluation-test
- Timestamp:
- 04/20/13 21:33:32 (12 years ago)
- Location:
- trunk/autoquest-core-usability-evaluation-test/src/main/java/de/ugoe/cs/autoquest/usability/rules
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-usability-evaluation-test/src/main/java/de/ugoe/cs/autoquest/usability/rules/metrics/NoLetterOrDigitTextInputsEvaluatorTest.java
r1151 r1171 27 27 import com.google.common.base.Optional; 28 28 29 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask Tree;29 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; 30 30 import de.ugoe.cs.autoquest.usability.result.UsabilityDefect; 31 import de.ugoe.cs.autoquest.usability. rules.metrics.NoLetterOrDigitRatioMetric;31 import de.ugoe.cs.autoquest.usability.testutil.GenerateTaskModelUtil; 32 32 33 33 /** … … 38 38 * @author Alexander Deicke 39 39 */ 40 public class NoLetterOrDigitTextInputsEvaluatorTest extends AbstractUsabilityEvaluationTC{40 public class NoLetterOrDigitTextInputsEvaluatorTest { 41 41 42 42 @Test … … 46 46 " TextInput () {}" + 47 47 "}"; 48 ITask Tree taskTree = createTaskTree(spec);48 ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec); 49 49 // When 50 50 Optional<UsabilityDefect> recommendation = new NoLetterOrDigitRatioMetric(taskTree).calculate(); … … 61 61 "12345678901234567890123456789012345) {}" + 62 62 "}"; 63 ITask Tree taskTree = createTaskTree(spec);63 ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec); 64 64 // When 65 65 Optional<UsabilityDefect> recommendation = new NoLetterOrDigitRatioMetric(taskTree).calculate(); … … 75 75 " TextInput (123456789012345678901234567890_123456789012345) {}" + 76 76 "}"; 77 ITask Tree taskTree = createTaskTree(spec);77 ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec); 78 78 // When 79 79 Optional<UsabilityDefect> recommendation = new NoLetterOrDigitRatioMetric(taskTree).calculate(); … … 88 88 " TextInput (12345_6789012345) {}" + 89 89 "}"; 90 ITask Tree taskTree = createTaskTree(spec);90 ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec); 91 91 // When 92 92 Optional<UsabilityDefect> recommendation = new NoLetterOrDigitRatioMetric(taskTree).calculate(); … … 101 101 " TextInput (_a_b_c_) {}" + 102 102 "}"; 103 ITask Tree taskTree = createTaskTree(spec);103 ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec); 104 104 // When 105 105 Optional<UsabilityDefect> recommendation = new NoLetterOrDigitRatioMetric(taskTree).calculate(); -
trunk/autoquest-core-usability-evaluation-test/src/main/java/de/ugoe/cs/autoquest/usability/rules/metrics/TextInputEntryRepetitionsEvaluatorTest.java
r1151 r1171 27 27 import com.google.common.base.Optional; 28 28 29 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask Tree;29 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; 30 30 import de.ugoe.cs.autoquest.usability.result.UsabilityDefect; 31 import de.ugoe.cs.autoquest.usability. rules.metrics.TextInputEntryRepetitionsMetric;31 import de.ugoe.cs.autoquest.usability.testutil.GenerateTaskModelUtil; 32 32 33 33 /** … … 38 38 * @author Alexander Deicke 39 39 */ 40 public class TextInputEntryRepetitionsEvaluatorTest extends AbstractUsabilityEvaluationTC{40 public class TextInputEntryRepetitionsEvaluatorTest { 41 41 42 42 @Test … … 44 44 // Given 45 45 String spec = "Sequence {" + " TextInput () {}" + "}"; 46 ITask Tree taskTree = createTaskTree(spec);46 ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec); 47 47 // When 48 48 Optional<UsabilityDefect> recommendation = new TextInputEntryRepetitionsMetric(taskTree).calculate(); … … 57 57 "Sequence {" + " TextInput (a b c) {}" + " Sequence {" + " TextInput (a) {}" 58 58 + " TextInput (d) {}" + " TextInput (e) {}" + " }" + "}"; 59 ITask Tree taskTree = createTaskTree(spec);59 ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec); 60 60 // When 61 61 Optional<UsabilityDefect> recommendation = new TextInputEntryRepetitionsMetric(taskTree).calculate(); … … 70 70 "Sequence {" + " TextInput (a b c) {}" + " Sequence {" + " TextInput (a) {}" 71 71 + " TextInput (b) {}" + " TextInput (c) {}" + " }" + "}"; 72 ITask Tree taskTree = createTaskTree(spec);72 ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec); 73 73 // When 74 74 Optional<UsabilityDefect> recommendation = new TextInputEntryRepetitionsMetric(taskTree).calculate(); … … 89 89 + " TextInput (b) {}" + " TextInput (c) {}" + " TextInput (d) {}" 90 90 + " TextInput (e) {}" + " }" + " }" + " TextInput (f) {}" + "}"; 91 ITask Tree taskTree = createTaskTree(spec);91 ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec); 92 92 // When 93 93 Optional<UsabilityDefect> recommendation = new TextInputEntryRepetitionsMetric(taskTree).calculate(); … … 108 108 + " TextInput (b b b a) {}" + " TextInput (a a c c) {}" 109 109 + " TextInput (b b a) {}" + " }" + " }" + " TextInput (d) {}" + "}"; 110 ITask Tree taskTree = createTaskTree(spec);110 ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec); 111 111 // When 112 112 Optional<UsabilityDefect> recommendation = new TextInputEntryRepetitionsMetric(taskTree).calculate(); -
trunk/autoquest-core-usability-evaluation-test/src/main/java/de/ugoe/cs/autoquest/usability/rules/metrics/TextInputRatioEvaluatorTest.java
r1151 r1171 27 27 import com.google.common.base.Optional; 28 28 29 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask Tree;29 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; 30 30 import de.ugoe.cs.autoquest.usability.result.UsabilityDefect; 31 import de.ugoe.cs.autoquest.usability. rules.metrics.TextInputRatioMetric;31 import de.ugoe.cs.autoquest.usability.testutil.GenerateTaskModelUtil; 32 32 33 33 /** … … 38 38 * @author Alexander Deicke 39 39 */ 40 public class TextInputRatioEvaluatorTest extends AbstractUsabilityEvaluationTC{40 public class TextInputRatioEvaluatorTest { 41 41 42 42 @Test … … 47 47 + " Interaction {}" + " TextInput (c) {}" + " Interaction {}" 48 48 + " Interaction {}" + " Interaction {}" + "}"; 49 ITask Tree taskTree = createTaskTree(spec);49 ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec); 50 50 // When 51 51 Optional<UsabilityDefect> recommendation = new TextInputRatioMetric(taskTree).calculate(); … … 60 60 "Sequence {" + " Interaction {}" + " TextInput (a) {}" + " Interaction {}" 61 61 + " Interaction {}" + " TextInput (c) {}" + "}"; 62 ITask Tree taskTree = createTaskTree(spec);62 ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec); 63 63 // When 64 64 Optional<UsabilityDefect> recommendation = new TextInputRatioMetric(taskTree).calculate(); … … 73 73 "Sequence {" + " Interaction {}" + " TextInput (a) {}" + " TextInput (b) {}" 74 74 + " Interaction {}" + " TextInput (c) {}" + "}"; 75 ITask Tree taskTree = createTaskTree(spec);75 ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec); 76 76 // When 77 77 Optional<UsabilityDefect> recommendation = new TextInputRatioMetric(taskTree).calculate(); … … 86 86 "Sequence {" + " TextInput (a) {}" + " TextInput (b) {}" + " Interaction {}" 87 87 + " TextInput (c) {}" + "}"; 88 ITask Tree taskTree = createTaskTree(spec);88 ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec); 89 89 // When 90 90 Optional<UsabilityDefect> recommendation = new TextInputRatioMetric(taskTree).calculate(); … … 97 97 // Given 98 98 String spec = "TextInput (bla) {}"; 99 ITask Tree taskTree = createTaskTree(spec);99 ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec); 100 100 // When 101 101 Optional<UsabilityDefect> recommendation = new TextInputRatioMetric(taskTree).calculate(); -
trunk/autoquest-core-usability-evaluation-test/src/main/java/de/ugoe/cs/autoquest/usability/rules/patterns/LongFormUsageDefectTest.java
r1151 r1171 23 23 import com.google.common.base.Optional; 24 24 25 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask Tree;25 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; 26 26 import de.ugoe.cs.autoquest.usability.result.UsabilityDefect; 27 import de.ugoe.cs.autoquest.usability.testutil.GenerateTask TreeUtil;27 import de.ugoe.cs.autoquest.usability.testutil.GenerateTaskModelUtil; 28 28 29 29 /** … … 36 36 public class LongFormUsageDefectTest { 37 37 38 38 @Test 39 39 public void should_be_present() { 40 40 // Given 41 String spec = "Sequence {" + 42 " Selection {" + 43 " MouseClick() {}" + 44 " Sequence() {" + 45 " MouseClick() {}" + 46 " Iteration {" + 47 " Sequence {" + 48 " TextInput() {}" + 49 " Scroll () {}" + 50 " }" + 51 " }" + 52 " MouseClick() {}" + 53 " }" + 54 " }" + 41 String spec = "UserSession {" + 42 " Sequence sequence1 {" + 43 " MouseClick t1 {}" + 44 " Iteration iteration1 {" + 45 " Sequence sequence3 {" + 46 " TextInput t {}" + 47 " Scroll p {}" + 48 " }" + 49 " }" + 50 " MouseClick b2 {}" + 51 " }" + 55 52 "}"; 56 ITask Tree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec);53 ITaskModel taskModel = GenerateTaskModelUtil.getTaskModelFromSpec(spec); 57 54 // When 58 Optional<UsabilityDefect> recommendation = new LongFormUsageDefect(task Tree).check();55 Optional<UsabilityDefect> recommendation = new LongFormUsageDefect(taskModel).check(); 59 56 // Then 60 57 assertThat(recommendation).is(present()); … … 64 61 public void should_be_absent() { 65 62 // Given 66 String spec = "Sequence {" + 67 " Selection {" + 68 " MouseClick() {}" + 69 " Sequence() {" + 70 " MouseClick() {}" + 71 " TextInput() {}" + 72 " Iteration {" + 73 " Scroll () {}" + 74 " }" + 75 " MouseClick() {}" + 76 " }" + 77 " }" + 63 String spec = "UserSession {" + 64 " Sequence sequence1 {" + 65 " MouseClick t1 {}" + 66 " TextInput t {}" + 67 " Scroll p {}" + 68 " MouseClick b2 {}" + 69 " }" + 78 70 "}"; 79 ITask Tree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec);71 ITaskModel taskModel = GenerateTaskModelUtil.getTaskModelFromSpec(spec); 80 72 // When 81 Optional<UsabilityDefect> recommendation = new LongFormUsageDefect(task Tree).check();73 Optional<UsabilityDefect> recommendation = new LongFormUsageDefect(taskModel).check(); 82 74 // Then 83 75 assertThat(recommendation).is(absent()); -
trunk/autoquest-core-usability-evaluation-test/src/main/java/de/ugoe/cs/autoquest/usability/rules/patterns/visitors/contains/ContainsAndEndsWithEventTest.java
r1152 r1171 17 17 import static de.ugoe.cs.autoquest.usability.tasktree.filters.EventTypeFilter.MOUSE_CLICK; 18 18 import static de.ugoe.cs.autoquest.usability.tasktree.filters.EventTypeFilter.TEXT_INPUT; 19 import static de.ugoe.cs.autoquest.usability.tasktree.filters.TaskTypeFilter.ITERATION;20 19 import static de.ugoe.cs.autoquest.usability.tasktree.filters.TaskTypeFilter.SELECTION; 21 20 import static de.ugoe.cs.autoquest.usability.tasktree.filters.TaskTypeFilter.SEQUENCE; … … 24 23 import org.junit.Test; 25 24 26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask Tree;25 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; 27 26 import de.ugoe.cs.autoquest.usability.rules.patterns.UsagePattern; 28 27 import de.ugoe.cs.autoquest.usability.rules.patterns.UsagePatternBuilder; 29 import de.ugoe.cs.autoquest.usability.testutil.GenerateTask TreeUtil;28 import de.ugoe.cs.autoquest.usability.testutil.GenerateTaskModelUtil; 30 29 31 30 /** … … 38 37 public class ContainsAndEndsWithEventTest { 39 38 40 41 public void sequence_ends_with_positive_1() {39 @Test 40 public void contains_and_ends_with_event_positive() { 42 41 // Given 43 String spec = "Sequence {" + 44 " TextInput () {}" + 42 String spec = "UserSession {" + 43 " Sequence seq1 {" + 44 " TextInput t1 {}" + 45 " }" + 45 46 "}"; 46 ITask Tree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec);47 ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec); 47 48 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SEQUENCE).contains(TEXT_INPUT).endsWith(TEXT_INPUT).build(); 48 49 // When … … 52 53 } 53 54 54 @Test55 public void sequence_ends_with_positive_2() {56 // Given57 String spec = "Selection {" +58 " EventTask target1 {}" +59 " Sequence {" +60 " MouseClick target2 {}" +61 " TextInput target3 {}" +62 " }" +63 "}";64 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec);65 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SEQUENCE).contains(MOUSE_CLICK).endsWith(TEXT_INPUT).build();66 // When67 boolean patternContained = pattern.containedIn(taskTree);68 // Then69 assertThat(patternContained).isTrue();70 }71 55 72 56 @Test 73 public void sequence_ends_with_positive_3() {57 public void contains_and_ends_with_event_negative() { 74 58 // Given 75 String spec = "Sequence {" + 76 " Optional {" + 77 " Sequence {" + 78 " EventTask target4 {}" + 79 " EventTask target3 {}" + 80 " }" + 81 " }" + 82 " EventTask target1 {}" + 83 " MouseClick target2 {}" + 84 " EventTask target3 {}" + 85 " EventTask target4 {}" + 86 " Selection {" + 87 " EventTask target5 {}" + 88 " Sequence {" + 89 " EventTask target4 {}" + 90 " EventTask target2 {}" + 91 " }" + 92 " }" + 93 " EventTask target6 {}" + 94 " TextInput target7 {}" + 95 "}"; 96 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 97 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SEQUENCE).contains(MOUSE_CLICK).endsWith(TEXT_INPUT).build(); 98 // When 99 boolean patternContained = pattern.containedIn(taskTree); 100 // Then 101 assertThat(patternContained).isTrue(); 102 } 103 104 @Test 105 public void sequence_ends_with_negative_1() { 106 // Given 107 String spec = "Sequence {" + 108 " MouseClick () {}" + 109 "}"; 110 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 111 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SEQUENCE).contains(TEXT_INPUT).endsWith(TEXT_INPUT).build(); 112 // When 113 boolean patternContained = pattern.containedIn(taskTree); 114 // Then 115 assertThat(patternContained).isFalse(); 116 } 117 118 @Test 119 public void sequence_ends_with_negative_2() { 120 // Given 121 String spec = "Selection {" + 122 " Sequence {" + 123 " EventTask target1 {}" + 124 " EventTask target2 {}" + 125 " }" + 126 " Sequence {" + 127 " EventTask target3 {}" + 128 " EventTask target4 {}" + 129 " }" + 130 " Sequence {" + 131 " EventTask target5 {}" + 132 " EventTask target6 {}" + 133 " }" + 134 "}"; 135 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 136 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SEQUENCE).contains(TEXT_INPUT).endsWith(MOUSE_CLICK).build(); 137 // When 138 boolean patternContained = pattern.containedIn(taskTree); 139 // Then 140 assertThat(patternContained).isFalse(); 141 } 142 143 @Test 144 public void sequence_ends_with_negative_3() { 145 // Given 146 String spec = "Iteration {" + 147 " Selection {" + 148 " EventTask target2 {}" + 149 " EventTask target3 {}" + 150 " }" + 151 "}"; 152 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 153 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SEQUENCE).contains(TEXT_INPUT).endsWith(MOUSE_CLICK).build(); 154 // When 155 boolean patternContained = pattern.containedIn(taskTree); 156 // Then 157 assertThat(patternContained).isFalse(); 158 } 159 160 @Test 161 public void iteration_ends_with_positive_1() { 162 // Given 163 String spec = "Iteration {" + 164 " TextInput () {}" + 165 "}"; 166 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 167 UsagePattern pattern = new UsagePatternBuilder().concernedNode(ITERATION).contains(TEXT_INPUT).endsWith(TEXT_INPUT).build(); 168 // When 169 boolean patternContained = pattern.containedIn(taskTree); 170 // Then 171 assertThat(patternContained).isTrue(); 172 } 173 174 @Test 175 public void iteration_ends_with_positive_2() { 176 // Given 177 String spec = "Iteration {" + 178 " Sequence {" + 179 " MouseClick target1 {}" + 180 " Selection {" + 181 " EventTask target2 {}" + 182 " TextInput target2 {}" + 59 String spec = "UserSession {" + 60 " Iteration it1 {" + 61 " Sequence seq1 {" + 62 " EventTask t1 {}" + 63 " EventTask t2 {}" + 183 64 " }" + 184 65 " }" + 185 66 "}"; 186 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 187 UsagePattern pattern = new UsagePatternBuilder().concernedNode(ITERATION).contains(MOUSE_CLICK).endsWith(TEXT_INPUT).build(); 188 // When 189 boolean patternContained = pattern.containedIn(taskTree); 190 // Then 191 assertThat(patternContained).isTrue(); 192 } 193 194 @Test 195 public void iteration_ends_with_positive_3() { 196 // Given 197 String spec = "Iteration {" + 198 " Selection {" + 199 " TextInput target1 {}" + 200 " Sequence {" + 201 " EventTask target2 {}" + 202 " EventTask target3 {}" + 203 " }" + 204 " }" + 205 "}"; 206 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 207 UsagePattern pattern = new UsagePatternBuilder().concernedNode(ITERATION).contains(TEXT_INPUT).endsWith(TEXT_INPUT).build(); 208 // When 209 boolean patternContained = pattern.containedIn(taskTree); 210 // Then 211 assertThat(patternContained).isTrue(); 212 } 213 214 @Test 215 public void iteration_ends_with_negative_1() { 216 // Given 217 String spec = "Iteration {" + 218 " MouseClick () {}" + 219 "}"; 220 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 221 UsagePattern pattern = new UsagePatternBuilder().concernedNode(ITERATION).contains(TEXT_INPUT).endsWith(MOUSE_CLICK).build(); 222 // When 223 boolean patternContained = pattern.containedIn(taskTree); 224 // Then 225 assertThat(patternContained).isFalse(); 226 } 227 228 @Test 229 public void iteration_ends_with_negative_2() { 230 // Given 231 String spec = "Iteration {" + 232 " Sequence {" + 233 " EventTask target1 {}" + 234 " Optional {" + 235 " EventTask target2 {}" + 236 " }" + 237 " }" + 238 "}"; 239 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 240 UsagePattern pattern = new UsagePatternBuilder().concernedNode(ITERATION).contains(TEXT_INPUT).endsWith(TEXT_INPUT).build(); 241 // When 242 boolean patternContained = pattern.containedIn(taskTree); 243 // Then 244 assertThat(patternContained).isFalse(); 245 } 246 247 @Test 248 public void iteration_ends_with_negative_3() { 249 // Given 250 String spec = "Iteration {" + 251 " Selection {" + 252 " EventTask target1 {}" + 253 " Sequence {" + 254 " TextInput target2 {}" + 255 " EventTask target3 {}" + 256 " }" + 257 " }" + 258 "}"; 259 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 260 UsagePattern pattern = new UsagePatternBuilder().concernedNode(ITERATION).contains(TEXT_INPUT).endsWith(MOUSE_CLICK).build(); 261 // When 262 boolean patternContained = pattern.containedIn(taskTree); 263 // Then 264 assertThat(patternContained).isFalse(); 265 } 266 267 @Test 268 public void selection_ends_with_positive_1() { 269 // Given 270 String spec = "Selection {" + 271 " MouseClick () {}" + 272 " TextInput () {}" + 273 "}"; 274 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 275 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SELECTION).contains(TEXT_INPUT).endsWith(TEXT_INPUT).build(); 276 // When 277 boolean patternContained = pattern.containedIn(taskTree); 278 // Then 279 assertThat(patternContained).isTrue(); 280 } 281 282 @Test 283 public void selection_ends_with_positive_2() { 284 // Given 285 String spec = "Sequence {" + 286 " Optional {" + 287 " Sequence {" + 288 " EventTask target4 {}" + 289 " EventTask target3 {}" + 290 " }" + 291 " }" + 292 " EventTask target1 {}" + 293 " EventTask target2 {}" + 294 " EventTask target3 {}" + 295 " EventTask target4 {}" + 296 " Selection {" + 297 " EventTask target5 {}" + 298 " Sequence {" + 299 " TextInput target4 {}" + 300 " TextInput target2 {}" + 301 " }" + 302 " }" + 303 " EventTask target6 {}" + 304 " EventTask target7 {}" + 305 "}"; 306 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 307 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SELECTION).contains(TEXT_INPUT).endsWith(TEXT_INPUT).build(); 308 // When 309 boolean patternContained = pattern.containedIn(taskTree); 310 // Then 311 assertThat(patternContained).isTrue(); 312 } 313 314 @Test 315 public void selection_ends_with_positive_3() { 316 // Given 317 String spec = "Iteration {" + 318 " Selection {" + 319 " Sequence {" + 320 " EventTask target3 {}" + 321 " TextInput target4 {}" + 322 " }" + 323 " Sequence {" + 324 " TextInput target5 {}" + 325 " EventTask target6 {}" + 326 " }" + 327 " }" + 328 "}"; 329 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 330 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SELECTION).contains(TEXT_INPUT).endsWith(TEXT_INPUT).build(); 331 // When 332 boolean patternContained = pattern.containedIn(taskTree); 333 // Then 334 assertThat(patternContained).isTrue(); 335 } 336 337 @Test 338 public void selection_ends_with_negative_1() { 339 // Given 340 String spec = "Selection {" + 341 " DragAndDrop () {}" + 342 " MouseClick () {}" + 343 "}"; 344 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 345 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SELECTION).contains(TEXT_INPUT).endsWith(MOUSE_CLICK).build(); 346 // When 347 boolean patternContained = pattern.containedIn(taskTree); 348 // Then 349 assertThat(patternContained).isFalse(); 350 } 351 352 @Test 353 public void selection_ends_with_negative_2() { 354 // Given 355 String spec = "Iteration {" + 356 " Selection {" + 357 " Sequence {" + 358 " EventTask target3 {}" + 359 " EventTask target4 {}" + 360 " }" + 361 " Sequence {" + 362 " EventTask target5 {}" + 363 " EventTask target6 {}" + 364 " }" + 365 " }" + 366 "}"; 367 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 67 ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec); 368 68 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SELECTION).contains(TEXT_INPUT).endsWith(MOUSE_CLICK).build(); 369 69 // When -
trunk/autoquest-core-usability-evaluation-test/src/main/java/de/ugoe/cs/autoquest/usability/rules/patterns/visitors/contains/ContainsEventTest.java
r1152 r1171 16 16 17 17 import static de.ugoe.cs.autoquest.usability.tasktree.filters.EventTypeFilter.TEXT_INPUT; 18 import static de.ugoe.cs.autoquest.usability.tasktree.filters.TaskTypeFilter.ITERATION;19 18 import static de.ugoe.cs.autoquest.usability.tasktree.filters.TaskTypeFilter.SELECTION; 20 19 import static de.ugoe.cs.autoquest.usability.tasktree.filters.TaskTypeFilter.SEQUENCE; … … 23 22 import org.junit.Test; 24 23 25 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask Tree;24 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; 26 25 import de.ugoe.cs.autoquest.usability.rules.patterns.UsagePattern; 27 26 import de.ugoe.cs.autoquest.usability.rules.patterns.UsagePatternBuilder; 28 import de.ugoe.cs.autoquest.usability.testutil.GenerateTask TreeUtil;27 import de.ugoe.cs.autoquest.usability.testutil.GenerateTaskModelUtil; 29 28 30 29 /** … … 37 36 public class ContainsEventTest { 38 37 39 40 public void sequence_ends_with_positive_1() {38 @Test 39 public void contains_event_positive() { 41 40 // Given 42 String spec = "Sequence {" + 43 " TextInput () {}" + 41 String spec = "UserSession {" + 42 " Sequence seq1 {" + 43 " TextInput t1 {}" + 44 " }" + 44 45 "}"; 45 ITask Tree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec);46 ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec); 46 47 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SEQUENCE).contains(TEXT_INPUT).build(); 47 48 // When … … 52 53 53 54 @Test 54 public void sequence_ends_with_positive_2() {55 public void contains_event_negative() { 55 56 // Given 56 String spec = "Selection {" + 57 " EventTask target1 {}" + 58 " Sequence {" + 59 " EventTask target2 {}" + 60 " TextInput target3 {}" + 61 " }" + 62 "}"; 63 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 64 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SEQUENCE).contains(TEXT_INPUT).build(); 65 // When 66 boolean patternContained = pattern.containedIn(taskTree); 67 // Then 68 assertThat(patternContained).isTrue(); 69 } 70 71 @Test 72 public void sequence_ends_with_positive_3() { 73 // Given 74 String spec = "Sequence {" + 75 " Optional {" + 76 " Sequence {" + 77 " EventTask target4 {}" + 78 " EventTask target3 {}" + 79 " }" + 80 " }" + 81 " EventTask target1 {}" + 82 " EventTask target2 {}" + 83 " EventTask target3 {}" + 84 " EventTask target4 {}" + 85 " Selection {" + 86 " EventTask target5 {}" + 87 " Sequence {" + 88 " EventTask target4 {}" + 89 " EventTask target2 {}" + 90 " }" + 91 " }" + 92 " EventTask target6 {}" + 93 " TextInput target7 {}" + 94 "}"; 95 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 96 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SEQUENCE).contains(TEXT_INPUT).build(); 97 // When 98 boolean patternContained = pattern.containedIn(taskTree); 99 // Then 100 assertThat(patternContained).isTrue(); 101 } 102 103 @Test 104 public void sequence_ends_with_negative_1() { 105 // Given 106 String spec = "Sequence {" + 107 " MouseClick () {}" + 108 "}"; 109 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 110 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SEQUENCE).contains(TEXT_INPUT).build(); 111 // When 112 boolean patternContained = pattern.containedIn(taskTree); 113 // Then 114 assertThat(patternContained).isFalse(); 115 } 116 117 @Test 118 public void sequence_ends_with_negative_2() { 119 // Given 120 String spec = "Selection {" + 121 " Sequence {" + 122 " EventTask target1 {}" + 123 " EventTask target2 {}" + 124 " }" + 125 " Sequence {" + 126 " EventTask target3 {}" + 127 " EventTask target4 {}" + 128 " }" + 129 " Sequence {" + 130 " EventTask target5 {}" + 131 " EventTask target6 {}" + 132 " }" + 133 "}"; 134 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 135 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SEQUENCE).contains(TEXT_INPUT).build(); 136 // When 137 boolean patternContained = pattern.containedIn(taskTree); 138 // Then 139 assertThat(patternContained).isFalse(); 140 } 141 142 @Test 143 public void sequence_ends_with_negative_3() { 144 // Given 145 String spec = "Iteration {" + 146 " Selection {" + 147 " EventTask target2 {}" + 148 " EventTask target3 {}" + 149 " }" + 150 "}"; 151 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 152 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SEQUENCE).contains(TEXT_INPUT).build(); 153 // When 154 boolean patternContained = pattern.containedIn(taskTree); 155 // Then 156 assertThat(patternContained).isFalse(); 157 } 158 159 @Test 160 public void iteration_ends_with_positive_1() { 161 // Given 162 String spec = "Iteration {" + 163 " TextInput () {}" + 164 "}"; 165 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 166 UsagePattern pattern = new UsagePatternBuilder().concernedNode(ITERATION).contains(TEXT_INPUT).build(); 167 // When 168 boolean patternContained = pattern.containedIn(taskTree); 169 // Then 170 assertThat(patternContained).isTrue(); 171 } 172 173 @Test 174 public void iteration_ends_with_positive_2() { 175 // Given 176 String spec = "Iteration {" + 177 " Sequence {" + 178 " EventTask target1 {}" + 179 " Selection {" + 180 " EventTask target2 {}" + 181 " TextInput target2 {}" + 57 String spec = "UserSession {" + 58 " Iteration it1 {" + 59 " Sequence seq1 {" + 60 " MouseClick t1 {}" + 61 " MouseClick t2 {}" + 182 62 " }" + 183 63 " }" + 184 64 "}"; 185 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 186 UsagePattern pattern = new UsagePatternBuilder().concernedNode(ITERATION).contains(TEXT_INPUT).build(); 187 // When 188 boolean patternContained = pattern.containedIn(taskTree); 189 // Then 190 assertThat(patternContained).isTrue(); 191 } 192 193 @Test 194 public void iteration_ends_with_positive_3() { 195 // Given 196 String spec = "Iteration {" + 197 " Selection {" + 198 " TextInput target1 {}" + 199 " Sequence {" + 200 " EventTask target2 {}" + 201 " EventTask target3 {}" + 202 " }" + 203 " }" + 204 "}"; 205 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 206 UsagePattern pattern = new UsagePatternBuilder().concernedNode(ITERATION).contains(TEXT_INPUT).build(); 207 // When 208 boolean patternContained = pattern.containedIn(taskTree); 209 // Then 210 assertThat(patternContained).isTrue(); 211 } 212 213 @Test 214 public void iteration_ends_with_negative_1() { 215 // Given 216 String spec = "Iteration {" + 217 " MouseClick () {}" + 218 "}"; 219 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 220 UsagePattern pattern = new UsagePatternBuilder().concernedNode(ITERATION).contains(TEXT_INPUT).build(); 221 // When 222 boolean patternContained = pattern.containedIn(taskTree); 223 // Then 224 assertThat(patternContained).isFalse(); 225 } 226 227 @Test 228 public void iteration_ends_with_negative_2() { 229 // Given 230 String spec = "Iteration {" + 231 " Sequence {" + 232 " EventTask target1 {}" + 233 " Optional {" + 234 " EventTask target2 {}" + 235 " }" + 236 " }" + 237 "}"; 238 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 239 UsagePattern pattern = new UsagePatternBuilder().concernedNode(ITERATION).contains(TEXT_INPUT).build(); 240 // When 241 boolean patternContained = pattern.containedIn(taskTree); 242 // Then 243 assertThat(patternContained).isFalse(); 244 } 245 246 @Test 247 public void iteration_ends_with_negative_3() { 248 // Given 249 String spec = "Iteration {" + 250 " Selection {" + 251 " EventTask target1 {}" + 252 " Sequence {" + 253 " EventTask target2 {}" + 254 " EventTask target3 {}" + 255 " }" + 256 " }" + 257 "}"; 258 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 259 UsagePattern pattern = new UsagePatternBuilder().concernedNode(ITERATION).contains(TEXT_INPUT).build(); 260 // When 261 boolean patternContained = pattern.containedIn(taskTree); 262 // Then 263 assertThat(patternContained).isFalse(); 264 } 265 266 @Test 267 public void selection_ends_with_positive_1() { 268 // Given 269 String spec = "Selection {" + 270 " MouseClick () {}" + 271 " TextInput () {}" + 272 "}"; 273 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 274 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SELECTION).contains(TEXT_INPUT).build(); 275 // When 276 boolean patternContained = pattern.containedIn(taskTree); 277 // Then 278 assertThat(patternContained).isTrue(); 279 } 280 281 @Test 282 public void selection_ends_with_positive_2() { 283 // Given 284 String spec = "Sequence {" + 285 " Optional {" + 286 " Sequence {" + 287 " EventTask target4 {}" + 288 " EventTask target3 {}" + 289 " }" + 290 " }" + 291 " EventTask target1 {}" + 292 " EventTask target2 {}" + 293 " EventTask target3 {}" + 294 " EventTask target4 {}" + 295 " Selection {" + 296 " EventTask target5 {}" + 297 " Sequence {" + 298 " EventTask target4 {}" + 299 " TextInput target2 {}" + 300 " }" + 301 " }" + 302 " EventTask target6 {}" + 303 " EventTask target7 {}" + 304 "}"; 305 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 306 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SELECTION).contains(TEXT_INPUT).build(); 307 // When 308 boolean patternContained = pattern.containedIn(taskTree); 309 // Then 310 assertThat(patternContained).isTrue(); 311 } 312 313 @Test 314 public void selection_ends_with_positive_3() { 315 // Given 316 String spec = "Iteration {" + 317 " Selection {" + 318 " Sequence {" + 319 " EventTask target3 {}" + 320 " TextInput target4 {}" + 321 " }" + 322 " Sequence {" + 323 " TextInput target5 {}" + 324 " EventTask target6 {}" + 325 " }" + 326 " }" + 327 "}"; 328 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 329 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SELECTION).contains(TEXT_INPUT).build(); 330 // When 331 boolean patternContained = pattern.containedIn(taskTree); 332 // Then 333 assertThat(patternContained).isTrue(); 334 } 335 336 @Test 337 public void selection_ends_with_negative_1() { 338 // Given 339 String spec = "Selection {" + 340 " DragAndDrop () {}" + 341 " MouseClick () {}" + 342 "}"; 343 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 344 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SELECTION).contains(TEXT_INPUT).build(); 345 // When 346 boolean patternContained = pattern.containedIn(taskTree); 347 // Then 348 assertThat(patternContained).isFalse(); 349 } 350 351 @Test 352 public void selection_ends_with_negative_2() { 353 // Given 354 String spec = "Iteration {" + 355 " Selection {" + 356 " Sequence {" + 357 " EventTask target3 {}" + 358 " EventTask target4 {}" + 359 " }" + 360 " Sequence {" + 361 " EventTask target5 {}" + 362 " EventTask target6 {}" + 363 " }" + 364 " }" + 365 "}"; 366 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 65 ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec); 367 66 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SELECTION).contains(TEXT_INPUT).build(); 368 67 // When -
trunk/autoquest-core-usability-evaluation-test/src/main/java/de/ugoe/cs/autoquest/usability/rules/patterns/visitors/contains/ContainsPatternTest.java
r1152 r1171 16 16 17 17 import static de.ugoe.cs.autoquest.usability.tasktree.filters.EventTypeFilter.TEXT_INPUT; 18 import static de.ugoe.cs.autoquest.usability.tasktree.filters.TaskTypeFilter.ITERATION;19 18 import static de.ugoe.cs.autoquest.usability.tasktree.filters.TaskTypeFilter.SELECTION; 20 19 import static de.ugoe.cs.autoquest.usability.tasktree.filters.TaskTypeFilter.SEQUENCE; … … 23 22 import org.junit.Test; 24 23 25 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask Tree;24 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; 26 25 import de.ugoe.cs.autoquest.usability.rules.patterns.UsagePattern; 27 26 import de.ugoe.cs.autoquest.usability.rules.patterns.UsagePatternBuilder; 28 import de.ugoe.cs.autoquest.usability.testutil.GenerateTask TreeUtil;27 import de.ugoe.cs.autoquest.usability.testutil.GenerateTaskModelUtil; 29 28 30 29 /** … … 37 36 public class ContainsPatternTest { 38 37 39 40 public void sequence_ends_with_positive_1() {38 @Test 39 public void contains_pattern_positive() { 41 40 // Given 42 String spec = "Sequence {" + 43 " Selection {" + 44 " TextInput () {}" + 45 " MouseClick () {}" + 41 String spec = "UserSession {" + 42 " Sequence seq1 {" + 43 " Selection sel1 {" + 44 " TextInput t1 {}" + 45 " }" + 46 " Selection sel1 {" + 47 " MouseClick t2 {}" + 48 " }" + 46 49 " }" + 47 50 "}"; 48 ITask Tree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec);51 ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec); 49 52 UsagePatternBuilder patternBuilder = new UsagePatternBuilder(); 50 53 UsagePattern containsPattern = patternBuilder.concernedNode(SELECTION).startsWith(TEXT_INPUT).endsWith(TEXT_INPUT).build(); … … 57 60 58 61 @Test 59 public void sequence_ends_with_positive_2() {62 public void contains_pattern_negative() { 60 63 // Given 61 String spec = "Selection {" + 62 " EventTask target1 {}" + 63 " Sequence {" + 64 " EventTask target2 {}" + 65 " TextInput target3 {}" + 66 " }" + 67 "}"; 68 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 69 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SEQUENCE).contains(TEXT_INPUT).build(); 70 // When 71 boolean patternContained = pattern.containedIn(taskTree); 72 // Then 73 assertThat(patternContained).isTrue(); 74 } 75 76 @Test 77 public void sequence_ends_with_positive_3() { 78 // Given 79 String spec = "Sequence {" + 80 " Optional {" + 81 " Sequence {" + 82 " EventTask target4 {}" + 83 " EventTask target3 {}" + 84 " }" + 85 " }" + 86 " EventTask target1 {}" + 87 " EventTask target2 {}" + 88 " EventTask target3 {}" + 89 " EventTask target4 {}" + 90 " Selection {" + 91 " EventTask target5 {}" + 92 " Sequence {" + 93 " EventTask target4 {}" + 94 " EventTask target2 {}" + 95 " }" + 96 " }" + 97 " EventTask target6 {}" + 98 " TextInput target7 {}" + 99 "}"; 100 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 101 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SEQUENCE).contains(TEXT_INPUT).build(); 102 // When 103 boolean patternContained = pattern.containedIn(taskTree); 104 // Then 105 assertThat(patternContained).isTrue(); 106 } 107 108 @Test 109 public void sequence_ends_with_negative_1() { 110 // Given 111 String spec = "Sequence {" + 112 " MouseClick () {}" + 113 "}"; 114 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 115 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SEQUENCE).contains(TEXT_INPUT).build(); 116 // When 117 boolean patternContained = pattern.containedIn(taskTree); 118 // Then 119 assertThat(patternContained).isFalse(); 120 } 121 122 @Test 123 public void sequence_ends_with_negative_2() { 124 // Given 125 String spec = "Selection {" + 126 " Sequence {" + 127 " EventTask target1 {}" + 128 " EventTask target2 {}" + 129 " }" + 130 " Sequence {" + 131 " EventTask target3 {}" + 132 " EventTask target4 {}" + 133 " }" + 134 " Sequence {" + 135 " EventTask target5 {}" + 136 " EventTask target6 {}" + 137 " }" + 138 "}"; 139 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 140 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SEQUENCE).contains(TEXT_INPUT).build(); 141 // When 142 boolean patternContained = pattern.containedIn(taskTree); 143 // Then 144 assertThat(patternContained).isFalse(); 145 } 146 147 @Test 148 public void sequence_ends_with_negative_3() { 149 // Given 150 String spec = "Iteration {" + 151 " Selection {" + 152 " EventTask target2 {}" + 153 " EventTask target3 {}" + 154 " }" + 155 "}"; 156 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 157 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SEQUENCE).contains(TEXT_INPUT).build(); 158 // When 159 boolean patternContained = pattern.containedIn(taskTree); 160 // Then 161 assertThat(patternContained).isFalse(); 162 } 163 164 @Test 165 public void iteration_ends_with_positive_1() { 166 // Given 167 String spec = "Iteration {" + 168 " TextInput () {}" + 169 "}"; 170 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 171 UsagePattern pattern = new UsagePatternBuilder().concernedNode(ITERATION).contains(TEXT_INPUT).build(); 172 // When 173 boolean patternContained = pattern.containedIn(taskTree); 174 // Then 175 assertThat(patternContained).isTrue(); 176 } 177 178 @Test 179 public void iteration_ends_with_positive_2() { 180 // Given 181 String spec = "Iteration {" + 182 " Sequence {" + 183 " EventTask target1 {}" + 184 " Selection {" + 185 " EventTask target2 {}" + 186 " TextInput target2 {}" + 64 String spec = "UserSession {" + 65 " Iteration it1 {" + 66 " Selection sel1 {" + 67 " Sequence seq1 {" + 68 " EventTask t1 {}" + 69 " EventTask t2 {}" + 70 " }" + 71 " }" + 72 " Selection sel1 {" + 73 " Sequence seq2 {" + 74 " EventTask t2 {}" + 75 " EventTask t1 {}" + 76 " }" + 187 77 " }" + 188 78 " }" + 189 79 "}"; 190 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 191 UsagePattern pattern = new UsagePatternBuilder().concernedNode(ITERATION).contains(TEXT_INPUT).build(); 192 // When 193 boolean patternContained = pattern.containedIn(taskTree); 194 // Then 195 assertThat(patternContained).isTrue(); 196 } 197 198 @Test 199 public void iteration_ends_with_positive_3() { 200 // Given 201 String spec = "Iteration {" + 202 " Selection {" + 203 " TextInput target1 {}" + 204 " Sequence {" + 205 " EventTask target2 {}" + 206 " EventTask target3 {}" + 207 " }" + 208 " }" + 209 "}"; 210 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 211 UsagePattern pattern = new UsagePatternBuilder().concernedNode(ITERATION).contains(TEXT_INPUT).build(); 212 // When 213 boolean patternContained = pattern.containedIn(taskTree); 214 // Then 215 assertThat(patternContained).isTrue(); 216 } 217 218 @Test 219 public void iteration_ends_with_negative_1() { 220 // Given 221 String spec = "Iteration {" + 222 " MouseClick () {}" + 223 "}"; 224 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 225 UsagePattern pattern = new UsagePatternBuilder().concernedNode(ITERATION).contains(TEXT_INPUT).build(); 226 // When 227 boolean patternContained = pattern.containedIn(taskTree); 228 // Then 229 assertThat(patternContained).isFalse(); 230 } 231 232 @Test 233 public void iteration_ends_with_negative_2() { 234 // Given 235 String spec = "Iteration {" + 236 " Sequence {" + 237 " EventTask target1 {}" + 238 " Optional {" + 239 " EventTask target2 {}" + 240 " }" + 241 " }" + 242 "}"; 243 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 244 UsagePattern pattern = new UsagePatternBuilder().concernedNode(ITERATION).contains(TEXT_INPUT).build(); 245 // When 246 boolean patternContained = pattern.containedIn(taskTree); 247 // Then 248 assertThat(patternContained).isFalse(); 249 } 250 251 @Test 252 public void iteration_ends_with_negative_3() { 253 // Given 254 String spec = "Iteration {" + 255 " Selection {" + 256 " EventTask target1 {}" + 257 " Sequence {" + 258 " EventTask target2 {}" + 259 " EventTask target3 {}" + 260 " }" + 261 " }" + 262 "}"; 263 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 264 UsagePattern pattern = new UsagePatternBuilder().concernedNode(ITERATION).contains(TEXT_INPUT).build(); 265 // When 266 boolean patternContained = pattern.containedIn(taskTree); 267 // Then 268 assertThat(patternContained).isFalse(); 269 } 270 271 @Test 272 public void selection_ends_with_positive_1() { 273 // Given 274 String spec = "Selection {" + 275 " MouseClick () {}" + 276 " TextInput () {}" + 277 "}"; 278 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 279 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SELECTION).contains(TEXT_INPUT).build(); 280 // When 281 boolean patternContained = pattern.containedIn(taskTree); 282 // Then 283 assertThat(patternContained).isTrue(); 284 } 285 286 @Test 287 public void selection_ends_with_positive_2() { 288 // Given 289 String spec = "Sequence {" + 290 " Optional {" + 291 " Sequence {" + 292 " EventTask target4 {}" + 293 " EventTask target3 {}" + 294 " }" + 295 " }" + 296 " EventTask target1 {}" + 297 " EventTask target2 {}" + 298 " EventTask target3 {}" + 299 " EventTask target4 {}" + 300 " Selection {" + 301 " EventTask target5 {}" + 302 " Sequence {" + 303 " EventTask target4 {}" + 304 " TextInput target2 {}" + 305 " }" + 306 " }" + 307 " EventTask target6 {}" + 308 " EventTask target7 {}" + 309 "}"; 310 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 311 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SELECTION).contains(TEXT_INPUT).build(); 312 // When 313 boolean patternContained = pattern.containedIn(taskTree); 314 // Then 315 assertThat(patternContained).isTrue(); 316 } 317 318 @Test 319 public void selection_ends_with_positive_3() { 320 // Given 321 String spec = "Iteration {" + 322 " Selection {" + 323 " Sequence {" + 324 " EventTask target3 {}" + 325 " TextInput target4 {}" + 326 " }" + 327 " Sequence {" + 328 " TextInput target5 {}" + 329 " EventTask target6 {}" + 330 " }" + 331 " }" + 332 "}"; 333 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 334 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SELECTION).contains(TEXT_INPUT).build(); 335 // When 336 boolean patternContained = pattern.containedIn(taskTree); 337 // Then 338 assertThat(patternContained).isTrue(); 339 } 340 341 @Test 342 public void selection_ends_with_negative_1() { 343 // Given 344 String spec = "Selection {" + 345 " DragAndDrop () {}" + 346 " MouseClick () {}" + 347 "}"; 348 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 349 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SELECTION).contains(TEXT_INPUT).build(); 350 // When 351 boolean patternContained = pattern.containedIn(taskTree); 352 // Then 353 assertThat(patternContained).isFalse(); 354 } 355 356 @Test 357 public void selection_ends_with_negative_2() { 358 // Given 359 String spec = "Iteration {" + 360 " Selection {" + 361 " Sequence {" + 362 " EventTask target3 {}" + 363 " EventTask target4 {}" + 364 " }" + 365 " Sequence {" + 366 " EventTask target5 {}" + 367 " EventTask target6 {}" + 368 " }" + 369 " }" + 370 "}"; 371 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 80 ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec); 372 81 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SELECTION).contains(TEXT_INPUT).build(); 373 82 // When -
trunk/autoquest-core-usability-evaluation-test/src/main/java/de/ugoe/cs/autoquest/usability/rules/patterns/visitors/endswith/EndsWithEventTest.java
r1152 r1171 16 16 17 17 import static de.ugoe.cs.autoquest.usability.tasktree.filters.EventTypeFilter.TEXT_INPUT; 18 import static de.ugoe.cs.autoquest.usability.tasktree.filters.TaskTypeFilter.ITERATION;19 import static de.ugoe.cs.autoquest.usability.tasktree.filters.TaskTypeFilter.SELECTION;20 18 import static de.ugoe.cs.autoquest.usability.tasktree.filters.TaskTypeFilter.SEQUENCE; 21 19 import static org.fest.assertions.api.Assertions.assertThat; … … 23 21 import org.junit.Test; 24 22 25 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask Tree;23 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; 26 24 import de.ugoe.cs.autoquest.usability.rules.patterns.UsagePattern; 27 25 import de.ugoe.cs.autoquest.usability.rules.patterns.UsagePatternBuilder; 28 import de.ugoe.cs.autoquest.usability.testutil.GenerateTask TreeUtil;26 import de.ugoe.cs.autoquest.usability.testutil.GenerateTaskModelUtil; 29 27 30 28 /** … … 36 34 */ 37 35 public class EndsWithEventTest { 38 36 39 37 @Test 40 public void sequence_ends_with_positive_1() {38 public void ends_with_event_positive() { 41 39 // Given 42 String spec = "Sequence {" + 43 " TextInput () {}" + 40 String spec = "UserSession {" + 41 " Selection sel1 {" + 42 " Sequence seq1 {" + 43 " EventTask target1 {}" + 44 " }" + 45 " }" + 46 " Selection sel1 {" + 47 " Sequence seq2 {" + 48 " EventTask target2 {}" + 49 " TextInput target3 {}" + 50 " }" + 51 " }" + 44 52 "}"; 45 ITask Tree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec);53 ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec); 46 54 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SEQUENCE).endsWith(TEXT_INPUT).build(); 47 55 // When … … 52 60 53 61 @Test 54 public void sequence_ends_with_positive_2() {62 public void ends_with_event_negative() { 55 63 // Given 56 String spec = "Selection {" + 57 " EventTask target1 {}" + 58 " Sequence {" + 59 " EventTask target2 {}" + 60 " TextInput target3 {}" + 61 " }" + 62 "}"; 63 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 64 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SEQUENCE).endsWith(TEXT_INPUT).build(); 65 // When 66 boolean patternContained = pattern.containedIn(taskTree); 67 // Then 68 assertThat(patternContained).isTrue(); 69 } 70 71 @Test 72 public void sequence_ends_with_positive_3() { 73 // Given 74 String spec = "Sequence {" + 75 " Optional {" + 76 " Sequence {" + 77 " EventTask target4 {}" + 78 " EventTask target3 {}" + 79 " }" + 80 " }" + 81 " EventTask target1 {}" + 82 " EventTask target2 {}" + 83 " EventTask target3 {}" + 84 " EventTask target4 {}" + 85 " Selection {" + 86 " EventTask target5 {}" + 87 " Sequence {" + 88 " EventTask target4 {}" + 89 " EventTask target2 {}" + 90 " }" + 91 " }" + 92 " EventTask target6 {}" + 93 " TextInput target7 {}" + 94 "}"; 95 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 96 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SEQUENCE).endsWith(TEXT_INPUT).build(); 97 // When 98 boolean patternContained = pattern.containedIn(taskTree); 99 // Then 100 assertThat(patternContained).isTrue(); 101 } 102 103 @Test 104 public void sequence_ends_with_negative_1() { 105 // Given 106 String spec = "Sequence {" + 107 " MouseClick () {}" + 108 "}"; 109 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 110 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SEQUENCE).endsWith(TEXT_INPUT).build(); 111 // When 112 boolean patternContained = pattern.containedIn(taskTree); 113 // Then 114 assertThat(patternContained).isFalse(); 115 } 116 117 @Test 118 public void sequence_ends_with_negative_2() { 119 // Given 120 String spec = "Selection {" + 121 " Sequence {" + 122 " EventTask target1 {}" + 123 " EventTask target2 {}" + 124 " }" + 125 " Sequence {" + 126 " EventTask target3 {}" + 127 " EventTask target4 {}" + 128 " }" + 129 " Sequence {" + 130 " EventTask target5 {}" + 131 " EventTask target6 {}" + 132 " }" + 133 "}"; 134 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 135 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SEQUENCE).endsWith(TEXT_INPUT).build(); 136 // When 137 boolean patternContained = pattern.containedIn(taskTree); 138 // Then 139 assertThat(patternContained).isFalse(); 140 } 141 142 @Test 143 public void sequence_ends_with_negative_3() { 144 // Given 145 String spec = "Iteration {" + 146 " Selection {" + 147 " EventTask target2 {}" + 148 " EventTask target3 {}" + 149 " }" + 150 "}"; 151 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 152 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SEQUENCE).endsWith(TEXT_INPUT).build(); 153 // When 154 boolean patternContained = pattern.containedIn(taskTree); 155 // Then 156 assertThat(patternContained).isFalse(); 157 } 158 159 @Test 160 public void iteration_ends_with_positive_1() { 161 // Given 162 String spec = "Iteration {" + 163 " TextInput () {}" + 164 "}"; 165 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 166 UsagePattern pattern = new UsagePatternBuilder().concernedNode(ITERATION).endsWith(TEXT_INPUT).build(); 167 // When 168 boolean patternContained = pattern.containedIn(taskTree); 169 // Then 170 assertThat(patternContained).isTrue(); 171 } 172 173 @Test 174 public void iteration_ends_with_positive_2() { 175 // Given 176 String spec = "Iteration {" + 177 " Sequence {" + 178 " EventTask target1 {}" + 179 " Selection {" + 180 " EventTask target2 {}" + 181 " TextInput target2 {}" + 182 " }" + 183 " }" + 184 "}"; 185 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 186 UsagePattern pattern = new UsagePatternBuilder().concernedNode(ITERATION).endsWith(TEXT_INPUT).build(); 187 // When 188 boolean patternContained = pattern.containedIn(taskTree); 189 // Then 190 assertThat(patternContained).isTrue(); 191 } 192 193 @Test 194 public void iteration_ends_with_positive_3() { 195 // Given 196 String spec = "Iteration {" + 197 " Selection {" + 198 " TextInput target1 {}" + 199 " Sequence {" + 200 " EventTask target2 {}" + 201 " EventTask target3 {}" + 202 " }" + 203 " }" + 204 "}"; 205 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 206 UsagePattern pattern = new UsagePatternBuilder().concernedNode(ITERATION).endsWith(TEXT_INPUT).build(); 207 // When 208 boolean patternContained = pattern.containedIn(taskTree); 209 // Then 210 assertThat(patternContained).isTrue(); 211 } 212 213 @Test 214 public void iteration_ends_with_negative_1() { 215 // Given 216 String spec = "Iteration {" + 217 " MouseClick () {}" + 218 "}"; 219 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 220 UsagePattern pattern = new UsagePatternBuilder().concernedNode(ITERATION).endsWith(TEXT_INPUT).build(); 221 // When 222 boolean patternContained = pattern.containedIn(taskTree); 223 // Then 224 assertThat(patternContained).isFalse(); 225 } 226 227 @Test 228 public void iteration_ends_with_negative_2() { 229 // Given 230 String spec = "Iteration {" + 231 " Sequence {" + 232 " EventTask target1 {}" + 233 " Optional {" + 64 String spec = "UserSession {" + 65 " Selection sel1 {" + 66 " Sequence seq1 {" + 67 " EventTask target1 {}" + 234 68 " EventTask target2 {}" + 235 69 " }" + 236 70 " }" + 237 "}"; 238 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 239 UsagePattern pattern = new UsagePatternBuilder().concernedNode(ITERATION).endsWith(TEXT_INPUT).build(); 240 // When 241 boolean patternContained = pattern.containedIn(taskTree); 242 // Then 243 assertThat(patternContained).isFalse(); 244 } 245 246 @Test 247 public void iteration_ends_with_negative_3() { 248 // Given 249 String spec = "Iteration {" + 250 " Selection {" + 251 " EventTask target1 {}" + 252 " Sequence {" + 253 " EventTask target2 {}" + 71 " Selection sel1 {" + 72 " Sequence seq2 {" + 254 73 " EventTask target3 {}" + 74 " EventTask target4 {}" + 255 75 " }" + 256 76 " }" + 257 "}"; 258 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 259 UsagePattern pattern = new UsagePatternBuilder().concernedNode(ITERATION).endsWith(TEXT_INPUT).build(); 260 // When 261 boolean patternContained = pattern.containedIn(taskTree); 262 // Then 263 assertThat(patternContained).isFalse(); 264 } 265 266 @Test 267 public void selection_ends_with_positive_1() { 268 // Given 269 String spec = "Selection {" + 270 " MouseClick () {}" + 271 " TextInput () {}" + 272 "}"; 273 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 274 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SELECTION).endsWith(TEXT_INPUT).build(); 275 // When 276 boolean patternContained = pattern.containedIn(taskTree); 277 // Then 278 assertThat(patternContained).isTrue(); 279 } 280 281 @Test 282 public void selection_ends_with_positive_2() { 283 // Given 284 String spec = "Sequence {" + 285 " Optional {" + 286 " Sequence {" + 287 " EventTask target4 {}" + 288 " EventTask target3 {}" + 289 " }" + 290 " }" + 291 " EventTask target1 {}" + 292 " EventTask target2 {}" + 293 " EventTask target3 {}" + 294 " EventTask target4 {}" + 295 " Selection {" + 296 " EventTask target5 {}" + 297 " Sequence {" + 298 " EventTask target4 {}" + 299 " TextInput target2 {}" + 300 " }" + 301 " }" + 302 " EventTask target6 {}" + 303 " EventTask target7 {}" + 304 "}"; 305 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 306 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SELECTION).endsWith(TEXT_INPUT).build(); 307 // When 308 boolean patternContained = pattern.containedIn(taskTree); 309 // Then 310 assertThat(patternContained).isTrue(); 311 } 312 313 @Test 314 public void selection_ends_with_positive_3() { 315 // Given 316 String spec = "Iteration {" + 317 " Selection {" + 318 " Sequence {" + 319 " EventTask target3 {}" + 320 " TextInput target4 {}" + 321 " }" + 322 " Sequence {" + 323 " TextInput target5 {}" + 77 " Selection sel1 {" + 78 " Sequence seq3 {" + 79 " EventTask target5 {}" + 324 80 " EventTask target6 {}" + 325 81 " }" + 326 82 " }" + 327 83 "}"; 328 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 329 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SELECTION).endsWith(TEXT_INPUT).build(); 330 // When 331 boolean patternContained = pattern.containedIn(taskTree); 332 // Then 333 assertThat(patternContained).isTrue(); 334 } 335 336 @Test 337 public void selection_ends_with_negative_1() { 338 // Given 339 String spec = "Selection {" + 340 " DragAndDrop () {}" + 341 " MouseClick () {}" + 342 "}"; 343 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 344 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SELECTION).endsWith(TEXT_INPUT).build(); 345 // When 346 boolean patternContained = pattern.containedIn(taskTree); 347 // Then 348 assertThat(patternContained).isFalse(); 349 } 350 351 @Test 352 public void selection_ends_with_negative_2() { 353 // Given 354 String spec = "Iteration {" + 355 " Selection {" + 356 " Sequence {" + 357 " TextInput target3 {}" + 358 " EventTask target4 {}" + 359 " }" + 360 " Sequence {" + 361 " TextInput target5 {}" + 362 " EventTask target6 {}" + 363 " }" + 364 " }" + 365 "}"; 366 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 367 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SELECTION).endsWith(TEXT_INPUT).build(); 84 ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec); 85 UsagePattern pattern = new UsagePatternBuilder().concernedNode(SEQUENCE).endsWith(TEXT_INPUT).build(); 368 86 // When 369 87 boolean patternContained = pattern.containedIn(taskTree); -
trunk/autoquest-core-usability-evaluation-test/src/main/java/de/ugoe/cs/autoquest/usability/rules/patterns/visitors/endswith/EndsWithPatternTest.java
r1152 r1171 24 24 import org.junit.Test; 25 25 26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask Tree;26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; 27 27 import de.ugoe.cs.autoquest.usability.rules.patterns.UsagePattern; 28 28 import de.ugoe.cs.autoquest.usability.rules.patterns.UsagePatternBuilder; 29 import de.ugoe.cs.autoquest.usability.testutil.GenerateTask TreeUtil;29 import de.ugoe.cs.autoquest.usability.testutil.GenerateTaskModelUtil; 30 30 31 31 /** … … 39 39 40 40 @Test 41 public void s equence_starts_with_positive_1() {41 public void starts_with_pattern_positive() { 42 42 // Given 43 String spec = "Sequence {" + 44 " EventTask target2 {}" + 45 " EventTask target3 {}" + 46 " Selection {" + 47 " Sequence {" + 48 " TextInput target4 {}" + 49 " MouseClick target2 {}" + 43 String spec = "UserSession {" + 44 " Sequence seq1 {" + 45 " EventTask target2 {}" + 46 " EventTask target3 {}" + 47 " Selection sel1 {" + 48 " Sequence seq2 {" + 49 " TextInput target4 {}" + 50 " MouseClick target2 {}" + 51 " }" + 50 52 " }" + 51 " Sequence {" + 52 " TextInput target4 {}" + 53 " EventTask target2 {}" + 53 " Selection sel1 {" + 54 " Sequence seq3 {" + 55 " TextInput target4 {}" + 56 " EventTask target2 {}" + 57 " }" + 54 58 " }" + 55 59 " }" + 56 60 "}"; 57 ITask Tree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec);61 ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec); 58 62 UsagePatternBuilder patternBuilder = new UsagePatternBuilder(); 59 63 UsagePattern endsWithPattern = patternBuilder.concernedNode(SELECTION).startsWith(TEXT_INPUT).endsWith(MOUSE_CLICK).build(); … … 66 70 67 71 @Test 68 public void s equence_starts_with_positive_2() {72 public void starts_with_pattern_negative() { 69 73 // Given 70 String spec = "Selection {" + 71 " EventTask target1 {}" + 72 " Sequence {" + 73 " Iteration {" + 74 " Sequence {" + 75 " TextInput target4 {}" + 76 " MouseClick target2 {}" + 77 " TextInput target4 {}" + 74 String spec = "UserSession {" + 75 " Selection sel1 {" + 76 " Sequence seq1 {" + 77 " EventTask target1 {}" + 78 " EventTask target2 {}" + 79 " }" + 80 " }" + 81 " Selection sel1 {" + 82 " Iteration it1 {" + 83 " Sequence seq2 {" + 84 " MouseClick target5 {}" + 85 " EventTask target4 {}" + 86 " EventTask target2 {}" + 78 87 " }" + 79 88 " }" + 80 89 " }" + 81 "}"; 82 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 83 UsagePatternBuilder patternBuilder = new UsagePatternBuilder(); 84 UsagePattern endsWithPattern = patternBuilder.concernedNode(ITERATION).startsWith(TEXT_INPUT).contains(MOUSE_CLICK).build(); 85 UsagePattern pattern = patternBuilder.concernedNode(SEQUENCE).endsWith(endsWithPattern).build(); 86 // When 87 boolean patternContained = pattern.containedIn(taskTree); 88 // Then 89 assertThat(patternContained).isTrue(); 90 } 91 92 @Test 93 public void sequence_starts_with_positive_3() { 94 // Given 95 String spec = "Sequence {" + 96 " Optional {" + 97 " Sequence {" + 98 " EventTask target4 {}" + 99 " EventTask target3 {}" + 100 " }" + 101 " }" + 102 " EventTask target1 {}" + 103 " EventTask target2 {}" + 104 " EventTask target3 {}" + 105 " EventTask target4 {}" + 106 " EventTask target6 {}" + 107 " EventTask target7 {}" + 108 " Sequence {" + 109 " MouseClick target5 {}" + 110 " TextInput target4 {}" + 111 " MouseClick target2 {}" + 112 " }" + 113 "}"; 114 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 115 UsagePatternBuilder patternBuilder = new UsagePatternBuilder(); 116 UsagePattern startsWithPattern = patternBuilder.concernedNode(SEQUENCE).startsWith(MOUSE_CLICK).endsWith(MOUSE_CLICK).build(); 117 UsagePattern pattern = patternBuilder.concernedNode(SEQUENCE).startsWith(startsWithPattern).build(); 118 // When 119 boolean patternContained = pattern.containedIn(taskTree); 120 // Then 121 assertThat(patternContained).isTrue(); 122 } 123 124 @Test 125 public void sequence_starts_with_negative_1() { 126 // Given 127 String spec = "Sequence {" + 128 " MouseClick () {}" + 129 "}"; 130 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec); 131 UsagePatternBuilder patternBuilder = new UsagePatternBuilder(); 132 UsagePattern endsWithPattern = patternBuilder.concernedNode(SELECTION).startsWith(MOUSE_CLICK).endsWith(MOUSE_CLICK).build(); 133 UsagePattern pattern = patternBuilder.concernedNode(SEQUENCE).endsWith(endsWithPattern).build(); 134 // When 135 boolean patternContained = pattern.containedIn(taskTree); 136 // Then 137 assertThat(patternContained).isFalse(); 138 } 139 140 @Test 141 public void sequence_starts_with_negative_2() { 142 // Given 143 String spec = "Selection {" + 144 " Sequence {" + 145 " EventTask target1 {}" + 146 " EventTask target2 {}" + 147 " }" + 148 " Iteration {" + 149 " Sequence {" + 150 " MouseClick target5 {}" + 151 " EventTask target4 {}" + 152 " EventTask target2 {}" + 90 " Selection sel1 {" + 91 " Sequence seq3 {" + 92 " EventTask target5 {}" + 93 " EventTask target6 {}" + 153 94 " }" + 154 95 " }" + 155 " Sequence {" +156 " EventTask target5 {}" +157 " EventTask target6 {}" +158 " }" +159 96 "}"; 160 ITask Tree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec);97 ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec); 161 98 UsagePatternBuilder patternBuilder = new UsagePatternBuilder(); 162 99 UsagePattern endsWithPattern = patternBuilder.concernedNode(ITERATION).startsWith(MOUSE_CLICK).contains(TEXT_INPUT).build(); … … 168 105 } 169 106 170 @Test171 public void sequence_starts_with_negative_3() {172 // Given173 String spec = "Sequence {" +174 " Selection {" +175 " Sequence {" +176 " MouseClick target4 {}" +177 " EventTask target2 {}" +178 " }" +179 " Sequence {" +180 " TextInput target4 {}" +181 " TextInput target2 {}" +182 " }" +183 " }" +184 "}";185 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec);186 UsagePatternBuilder patternBuilder = new UsagePatternBuilder();187 UsagePattern endsWithPattern = patternBuilder.concernedNode(SEQUENCE).startsWith(MOUSE_CLICK).endsWith(TEXT_INPUT).build();188 UsagePattern pattern = patternBuilder.concernedNode(SEQUENCE).endsWith(endsWithPattern).build();189 // When190 boolean patternContained = pattern.containedIn(taskTree);191 // Then192 assertThat(patternContained).isFalse();193 }194 195 @Test196 public void iteration_starts_with_positive_1() {197 // Given198 String spec = "Iteration {" +199 " Sequence {" +200 " MouseClick () {}" +201 " TextInput () {}" +202 " }" +203 "}";204 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec);205 UsagePatternBuilder patternBuilder = new UsagePatternBuilder();206 UsagePattern endsWithPattern = patternBuilder.concernedNode(SEQUENCE).startsWith(MOUSE_CLICK).endsWith(TEXT_INPUT).build();207 UsagePattern pattern = patternBuilder.concernedNode(ITERATION).endsWith(endsWithPattern).build();208 // When209 boolean patternContained = pattern.containedIn(taskTree);210 // Then211 assertThat(patternContained).isTrue();212 }213 214 @Test215 public void iteration_starts_with_positive_2() {216 // Given217 String spec = "Iteration {" +218 " Selection {" +219 " Sequence {" +220 " MouseClick target4 {}" +221 " TextInput target2 {}" +222 " MouseClick target 4 {}" +223 " }" +224 " Sequence {" +225 " TextInput target4 {}" +226 " TextInput target2 {}" +227 " }" +228 " }" +229 "}";230 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec);231 UsagePatternBuilder patternBuilder = new UsagePatternBuilder();232 UsagePattern endsWithPattern = patternBuilder.concernedNode(SELECTION).startsWith(MOUSE_CLICK).contains(TEXT_INPUT).build();233 UsagePattern pattern = patternBuilder.concernedNode(ITERATION).endsWith(endsWithPattern).build();234 // When235 boolean patternContained = pattern.containedIn(taskTree);236 // Then237 assertThat(patternContained).isTrue();238 }239 240 @Test241 public void iteration_starts_with_positive_3() {242 // Given243 String spec = "Iteration {" +244 " Selection {" +245 " EventTask target1 {}" +246 " Sequence {" +247 " MouseClick target2 {}" +248 " MouseClick target3 {}" +249 " }" +250 " }" +251 "}";252 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec);253 UsagePatternBuilder patternBuilder = new UsagePatternBuilder();254 UsagePattern endsWithPattern = patternBuilder.concernedNode(SEQUENCE).startsWith(MOUSE_CLICK).endsWith(MOUSE_CLICK).build();255 UsagePattern pattern = patternBuilder.concernedNode(ITERATION).endsWith(endsWithPattern).build();256 // When257 boolean patternContained = pattern.containedIn(taskTree);258 // Then259 assertThat(patternContained).isTrue();260 }261 262 @Test263 public void iteration_starts_with_negative_1() {264 // Given265 String spec = "Iteration {" +266 " MouseClick () {}" +267 "}";268 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec);269 UsagePatternBuilder patternBuilder = new UsagePatternBuilder();270 UsagePattern endsWithPattern = patternBuilder.concernedNode(SEQUENCE).startsWith(MOUSE_CLICK).endsWith(MOUSE_CLICK).build();271 UsagePattern pattern = patternBuilder.concernedNode(ITERATION).endsWith(endsWithPattern).build();272 // When273 boolean patternContained = pattern.containedIn(taskTree);274 // Then275 assertThat(patternContained).isFalse();276 }277 278 @Test279 public void iteration_starts_with_negative_2() {280 // Given281 String spec = "Iteration {" +282 " Selection {" +283 " Sequence {" +284 " MouseClick target2 {}" +285 " MouseClick target3 {}" +286 " TextInput target4 {}" +287 " }" +288 " Optional {" +289 " EventTask target2 {}" +290 " }" +291 " }" +292 "}";293 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec);294 UsagePatternBuilder patternBuilder = new UsagePatternBuilder();295 UsagePattern endsWithPattern = patternBuilder.concernedNode(SELECTION).startsWith(MOUSE_CLICK).endsWith(MOUSE_CLICK).build();296 UsagePattern pattern = patternBuilder.concernedNode(ITERATION).endsWith(endsWithPattern).build();297 // When298 boolean patternContained = pattern.containedIn(taskTree);299 // Then300 assertThat(patternContained).isFalse();301 }302 303 @Test304 public void iteration_starts_with_negative_3() {305 // Given306 String spec = "Iteration {" +307 " Selection {" +308 " EventTask target1 {}" +309 " Sequence {" +310 " EventTask target2 {}" +311 " EventTask target3 {}" +312 " }" +313 " }" +314 "}";315 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec);316 UsagePatternBuilder patternBuilder = new UsagePatternBuilder();317 UsagePattern endsWithPattern = patternBuilder.concernedNode(SEQUENCE).startsWith(MOUSE_CLICK).endsWith(MOUSE_CLICK).build();318 UsagePattern pattern = patternBuilder.concernedNode(ITERATION).endsWith(endsWithPattern).build();319 // When320 boolean patternContained = pattern.containedIn(taskTree);321 // Then322 assertThat(patternContained).isFalse();323 }324 325 @Test326 public void selection_starts_with_positive_1() {327 // Given328 String spec = "Selection {" +329 " Sequence {" +330 " MouseClick target2 {}" +331 " MouseClick target3 {}" +332 " }" +333 " MouseClick () {}" +334 "}";335 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec);336 UsagePatternBuilder patternBuilder = new UsagePatternBuilder();337 UsagePattern endsWithPattern = patternBuilder.concernedNode(SEQUENCE).startsWith(MOUSE_CLICK).endsWith(MOUSE_CLICK).build();338 UsagePattern pattern = patternBuilder.concernedNode(SELECTION).endsWith(endsWithPattern).build();339 // When340 boolean patternContained = pattern.containedIn(taskTree);341 // Then342 assertThat(patternContained).isTrue();343 }344 345 @Test346 public void selection_starts_with_positive_2() {347 // Given348 String spec = "Sequence {" +349 " Optional {" +350 " Sequence {" +351 " EventTask target4 {}" +352 " EventTask target3 {}" +353 " }" +354 " }" +355 " EventTask target1 {}" +356 " EventTask target2 {}" +357 " EventTask target3 {}" +358 " EventTask target4 {}" +359 " Selection {" +360 " TextInput target5 {}" +361 " Selection {" +362 " MouseClick target4 {}" +363 " MouseClick target2 {}" +364 " }" +365 " }" +366 " EventTask target6 {}" +367 " EventTask target7 {}" +368 "}";369 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec);370 UsagePatternBuilder patternBuilder = new UsagePatternBuilder();371 UsagePattern endsWithPattern = patternBuilder.concernedNode(SELECTION).startsWith(MOUSE_CLICK).endsWith(MOUSE_CLICK).build();372 UsagePattern pattern = patternBuilder.concernedNode(SELECTION).endsWith(endsWithPattern).build();373 // When374 boolean patternContained = pattern.containedIn(taskTree);375 // Then376 assertThat(patternContained).isTrue();377 }378 379 @Test380 public void selection_starts_with_positive_3() {381 // Given382 String spec = "Iteration {" +383 " Selection {" +384 " Iteration {" +385 " Sequence {" +386 " TextInput target3 {}" +387 " MouseClick target4 {}" +388 " }" +389 " }" +390 " Sequence {" +391 " TextInput target5 {}" +392 " EventTask target6 {}" +393 " }" +394 " }" +395 "}";396 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec);397 UsagePatternBuilder patternBuilder = new UsagePatternBuilder();398 UsagePattern endsWithPattern = patternBuilder.concernedNode(ITERATION).startsWith(TEXT_INPUT).contains(MOUSE_CLICK).build();399 UsagePattern pattern = patternBuilder.concernedNode(SELECTION).endsWith(endsWithPattern).build();400 // When401 boolean patternContained = pattern.containedIn(taskTree);402 // Then403 assertThat(patternContained).isTrue();404 }405 406 @Test407 public void selection_starts_with_negative_1() {408 // Given409 String spec = "Selection {" +410 " DragAndDrop () {}" +411 " MouseClick () {}" +412 "}";413 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec);414 UsagePatternBuilder patternBuilder = new UsagePatternBuilder();415 UsagePattern endsWithPattern = patternBuilder.concernedNode(SEQUENCE).startsWith(TEXT_INPUT).contains(MOUSE_CLICK).build();416 UsagePattern pattern = patternBuilder.concernedNode(SELECTION).endsWith(endsWithPattern).build();417 // When418 boolean patternContained = pattern.containedIn(taskTree);419 // Then420 assertThat(patternContained).isFalse();421 }422 423 @Test424 public void selection_starts_with_negative_2() {425 // Given426 String spec = "Iteration {" +427 " Selection {" +428 " Iteration {" +429 " Sequence {"+430 " TextInput target3 {}" +431 " TextInput target4 {}" +432 " }" +433 " }" +434 " Iteration {" +435 " Sequence {"+436 " MouseClick target5 {}" +437 " TextInput target6 {}" +438 " }" +439 " }" +440 " }" +441 "}";442 ITaskTree taskTree = GenerateTaskTreeUtil.getTaskTreeFromSpec(spec);443 UsagePatternBuilder patternBuilder = new UsagePatternBuilder();444 UsagePattern endsWithPattern = patternBuilder.concernedNode(ITERATION).startsWith(TEXT_INPUT).endsWith(MOUSE_CLICK).build();445 UsagePattern pattern = patternBuilder.concernedNode(SELECTION).endsWith(endsWithPattern).build();446 // When447 boolean patternContained = pattern.containedIn(taskTree);448 // Then449 assertThat(patternContained).isFalse();450 }451 452 107 }
Note: See TracChangeset
for help on using the changeset viewer.