source: trunk/autoquest-core-usability-evaluation-test/src/main/java/de/ugoe/cs/autoquest/usability/rules/patterns/visitors/startswith/StartsAndEndsWithPatternTest.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: 4.6 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.ITERATION;
20import static de.ugoe.cs.autoquest.usability.tasktree.filters.TaskTypeFilter.SELECTION;
21import static de.ugoe.cs.autoquest.usability.tasktree.filters.TaskTypeFilter.SEQUENCE;
22import static org.fest.assertions.api.Assertions.assertThat;
23
24import org.junit.Test;
25
26import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel;
27import de.ugoe.cs.autoquest.usability.rules.patterns.InteractionPattern;
28import de.ugoe.cs.autoquest.usability.rules.patterns.InteractionPatternBuilder;
29import de.ugoe.cs.autoquest.usability.testutil.GenerateTaskModelUtil;
30
31/**
32 * <p>
33 * TODO comment
34 * </p>
35 *
36 * @author Alexander Deicke
37 */
38public class StartsAndEndsWithPatternTest {
39
40    @Test
41    public void starts_and_ends_with_pattern_positive() {
42        // Given
43        String spec = "UserSession {" +
44                              "  Sequence seq1 {" +
45                      "    Iteration iter1 {" +
46                      "      MouseClick t1 {}" +
47                      "    }" +
48                      "  }" +
49                      "  TextInput () {}" +
50                      "  Selection sel1 {" +
51                      "    MouseClick t2 {}" +
52                      "  }" +
53                      "  Selection sel1 {" +
54                      "    Sequence seq3 {" +
55                      "      TextInput t3 {}" +
56                      "      MouseClick t1 {}" +
57                      "    }" +
58                      "  }" +
59                      "}";
60        ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
61        InteractionPatternBuilder patternBuilder = new InteractionPatternBuilder();
62        InteractionPattern startsWithPattern = patternBuilder.concernedNode(ITERATION).contains(MOUSE_CLICK).build();
63        InteractionPattern endsWithPattern = patternBuilder.concernedNode(SELECTION).startsWith(TEXT_INPUT).endsWith(MOUSE_CLICK).build();
64        InteractionPattern pattern = patternBuilder.concernedNode(SEQUENCE).startsWith(startsWithPattern).endsWith(endsWithPattern).build();
65        // When
66        boolean patternContained = pattern.containedIn(taskTree);
67        // Then
68        assertThat(patternContained).isTrue();
69    }
70   
71    @Test
72    public void starts_and_ends_with_pattern_negative() {
73        // Given
74        String spec = "UserSession {" +
75                              "  Sequence seq1 {" +
76                      "    Iteration iter1 {" +
77                      "      MouseClick t1 {}" +
78                      "    }" +
79                      "    TextInput t2 {}" +
80                      "    Selection sel1 {" +
81                      "      MouseClick t3 {}" +
82                      "    }" +
83                      "    Selection sel1 {" +
84                      "      Sequence seq2 {" +
85                      "        TextInput t3 {}" +
86                      "        MouseClick t1 {}" +
87                      "      }" +
88                      "    }" +
89                      "  }" +
90                      "}";
91        ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
92        InteractionPatternBuilder patternBuilder = new InteractionPatternBuilder();
93        InteractionPattern startsWithPattern = patternBuilder.concernedNode(ITERATION).contains(MOUSE_CLICK).build();
94        InteractionPattern endsWithPattern = patternBuilder.concernedNode(SELECTION).startsWith(TEXT_INPUT).endsWith(MOUSE_CLICK).build();
95        InteractionPattern pattern = patternBuilder.concernedNode(ITERATION).startsWith(endsWithPattern).endsWith(startsWithPattern).build();
96        // When
97        boolean patternContained = pattern.containedIn(taskTree);
98        // Then
99        assertThat(patternContained).isFalse();
100    }
101   
102}
Note: See TracBrowser for help on using the repository browser.