source: trunk/autoquest-core-usability-evaluation-test/src/main/java/de/ugoe/cs/autoquest/usability/rules/patterns/visitors/endswith/EndsWithPatternTest.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.8 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.endswith;
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 EndsWithPatternTest {
39
40    @Test
41    public void ends_with_pattern_positive() {
42        // Given
43        String spec = "UserSession {" +
44                              "  Sequence seq1 {" +
45                      "    EventTask target2 {}" +
46                      "    EventTask target3 {}" +
47                      "    Selection sel1 {" +
48                      "      Sequence seq2 {" +
49                      "        TextInput target4 {}" +
50                      "        MouseClick target5 {}" +
51                      "      }" +
52                      "    }" +
53                      "    Selection sel1 {" +
54                      "      Sequence seq3 {" +
55                      "        TextInput target4 {}" +
56                      "        EventTask target3 {}" +
57                      "      }" +
58                      "    }" +
59                      "  }" +
60                      "}";
61        ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
62        InteractionPatternBuilder patternBuilder = new InteractionPatternBuilder();
63        InteractionPattern endsWithPattern = patternBuilder.concernedNode(SELECTION).startsWith(TEXT_INPUT).endsWith(MOUSE_CLICK).build();
64        InteractionPattern pattern = patternBuilder.concernedNode(SEQUENCE).endsWith(endsWithPattern).build();
65        // When
66        boolean patternContained = pattern.containedIn(taskTree);
67        // Then
68        assertThat(patternContained).isTrue();
69    }
70   
71    @Test
72    public void ends_with_pattern_negative() {
73        // Given
74        String spec = "UserSession {" +
75                              "  Sequence seg0 {" +
76                              "    Selection sel1 {" +
77                      "      Sequence seq1 {" +
78                      "        EventTask target1 {}" +
79                      "        EventTask target2 {}" +
80                      "      }" +
81                      "    }" +
82                      "    Selection sel1 {" +
83                      "      Iteration it1 {" +
84                      "        Sequence seq2 {" +
85                      "          MouseClick target5 {}" +
86                      "          EventTask target4 {}" +
87                      "          EventTask target2 {}" +
88                      "        }" +
89                      "      }" +
90                      "    }" +
91                      "    Selection sel1 {" +
92                      "      Sequence seq3 {" +
93                      "        EventTask target5 {}" +
94                      "        EventTask target6 {}" +
95                      "      }" +
96                      "    }" +
97                      "  }" +
98                      "}";
99        ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
100        InteractionPatternBuilder patternBuilder = new InteractionPatternBuilder();
101        InteractionPattern endsWithPattern = patternBuilder.concernedNode(ITERATION).startsWith(MOUSE_CLICK).contains(TEXT_INPUT).build();
102        InteractionPattern pattern = patternBuilder.concernedNode(SEQUENCE).endsWith(endsWithPattern).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.