source: trunk/autoquest-core-usability-evaluation-test/src/main/java/de/ugoe/cs/autoquest/usability/rules/patterns/visitors/startswith/StartsWithPatternContainsPatternAndEndsWithEventTest.java @ 1205

Last change on this file since 1205 was 1205, checked in by adeicke, 11 years ago

Fixing taskmodel specs and apply renaming refactoring (UsagePattern? -> InteractionPattern?).

  • Property svn:mime-type set to text/plain
File size: 5.1 KB
Line 
1//   Copyright 2012 Georg-August-Universität Göttingen, Germany
2//
3//   Licensed under the Apache License, Version 2.0 (the "License");
4//   you may not use this file except in compliance with the License.
5//   You may obtain a copy of the License at
6//
7//       http://www.apache.org/licenses/LICENSE-2.0
8//
9//   Unless required by applicable law or agreed to in writing, software
10//   distributed under the License is distributed on an "AS IS" BASIS,
11//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//   See the License for the specific language governing permissions and
13//   limitations under the License.
14
15package de.ugoe.cs.autoquest.usability.rules.patterns.visitors.startswith;
16
17import static de.ugoe.cs.autoquest.usability.tasktree.filters.EventTypeFilter.MOUSE_CLICK;
18import static de.ugoe.cs.autoquest.usability.tasktree.filters.EventTypeFilter.TEXT_INPUT;
19import static de.ugoe.cs.autoquest.usability.tasktree.filters.TaskTypeFilter.SELECTION;
20import static de.ugoe.cs.autoquest.usability.tasktree.filters.TaskTypeFilter.SEQUENCE;
21import static org.fest.assertions.api.Assertions.assertThat;
22
23import org.junit.Test;
24
25import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel;
26import de.ugoe.cs.autoquest.usability.rules.patterns.InteractionPattern;
27import de.ugoe.cs.autoquest.usability.rules.patterns.InteractionPatternBuilder;
28import de.ugoe.cs.autoquest.usability.testutil.GenerateTaskModelUtil;
29
30/**
31 * <p>
32 * TODO comment
33 * </p>
34 *
35 * @author Alexander Deicke
36 */
37public class StartsWithPatternContainsPatternAndEndsWithEventTest {
38
39    @Test
40    public void starts_with_pattern_contains_pattern_and_ends_with_event_positive() {
41        // Given
42        String spec = "UserSession {" +
43                              "  Sequence seq1 {" +
44                      "    Selection sel1 {" +
45                      "      Sequence seq2 {" +
46                      "        TextInput target4 {}" +
47                      "        MouseClick target1 {}" +
48                      "      }" +
49                      "    }" +
50                      "    Selection sel1 {" +
51                      "      Sequence seq3 {" +
52                      "        TextInput target3 {}" +
53                      "        EventTask target5 {}" +
54                      "      }" +
55                      "    }" +
56                      "    Sequence seq4 {" +
57                      "      MouseClick target6 {}" +
58                      "      EventTask t5 {}" +
59                      "    }" +
60                      "    TextInput target7 {}" +
61                      "  }" +
62                      "}";
63        ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
64        InteractionPatternBuilder patternBuilder = new InteractionPatternBuilder();
65        InteractionPattern startsWithPattern = patternBuilder.concernedNode(SELECTION).startsWith(TEXT_INPUT).endsWith(MOUSE_CLICK).build();
66        InteractionPattern containsPattern = patternBuilder.concernedNode(SEQUENCE).startsWith(MOUSE_CLICK).build();
67        InteractionPattern pattern = patternBuilder.concernedNode(SEQUENCE).startsWith(startsWithPattern).contains(containsPattern).endsWith(TEXT_INPUT).build();
68        // When
69        boolean patternContained = pattern.containedIn(taskTree);
70        // Then
71        assertThat(patternContained).isTrue();
72    }
73   
74    @Test
75    public void starts_with_pattern_contains_pattern_and_ends_with_event_negative() {
76        // Given
77        String spec = "UserSession {" +
78                              "  Sequence seq1 {" +
79                      "    Selection sel1 {" +
80                      "      Sequence seq2 {" +
81                      "        TextInput target4 {}" +
82                      "        MouseClick target2 {}" +
83                      "      }" +
84                      "    }" +
85                      "    Selection sel1 {" +
86                      "      Sequence seq3 {" +
87                      "        TextInput target4 {}" +
88                      "        EventTask target2 {}" +
89                      "      }" +
90                      "    }" +
91                      "  }" +
92                      "  Sequence seq4 {" +
93                      "    TextInput target2 {}" +
94                      "    EventTask () {}" +
95                      "  }" +
96                      "  TextInput target3 {}" +
97                      "}";
98        ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
99        InteractionPatternBuilder patternBuilder = new InteractionPatternBuilder();
100        InteractionPattern startsWithPattern = patternBuilder.concernedNode(SELECTION).startsWith(TEXT_INPUT).endsWith(MOUSE_CLICK).build();
101        InteractionPattern containsPattern = patternBuilder.concernedNode(SEQUENCE).startsWith(MOUSE_CLICK).endsWith(TEXT_INPUT).build();
102        InteractionPattern pattern = patternBuilder.concernedNode(SEQUENCE).startsWith(startsWithPattern).contains(containsPattern).endsWith(TEXT_INPUT).build();
103        // When
104        boolean patternContained = pattern.containedIn(taskTree);
105        // Then
106        assertThat(patternContained).isFalse();
107    }
108   
109}
Note: See TracBrowser for help on using the repository browser.