source: trunk/autoquest-core-usability-evaluation-test/src/main/java/de/ugoe/cs/autoquest/usability/rules/metrics/TextInputEntryRepetitionsEvaluatorTest.java @ 1201

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

Fixed tests.

  • Property svn:mime-type set to text/plain
File size: 7.4 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.metrics;
16
17import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.absent;
18import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.highRecommendationSeverityLevel;
19import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.infoRecommendationSeverityLevel;
20import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.lowRecommendationSeverityLevel;
21import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.mediumRecommendationSeverityLevel;
22import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.present;
23import static org.fest.assertions.api.Assertions.assertThat;
24
25import org.junit.Test;
26
27import com.google.common.base.Optional;
28
29import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel;
30import de.ugoe.cs.autoquest.usability.result.UsabilityDefect;
31import de.ugoe.cs.autoquest.usability.testutil.GenerateTaskModelUtil;
32
33/**
34 * <p>
35 * TODO comment
36 * </p>
37 *
38 * @author Alexander Deicke
39 */
40public class TextInputEntryRepetitionsEvaluatorTest {
41
42    @Test
43    public void should_return_no_recommendation() {
44        // Given
45        String spec = "UserSession {" +
46                              "  Sequence seq1 {" +
47                              "    TextInput t1 () {}" +
48                              "  }" +
49                              "}";
50        ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
51        // When
52        Optional<UsabilityDefect> recommendation = new TextInputEntryRepetitionsMetric(taskTree).calculate();
53        // Then
54        assertThat(recommendation).is(absent());
55    }
56
57    @Test
58    public void should_return_recommendation_with_info_severity_level() {
59        // Given
60        String spec = "UserSession {" +
61                                  "  Sequence seq1 {" +
62                              "    TextInput t1 (a b c) {}" +
63                                  "    Sequence seq2 {" +
64                              "      TextInput t2 (a) {}" +
65                                  "      TextInput t3 (d) {}" +
66                              "      TextInput t4 (e) {}" +
67                                  "    }" +
68                                  "  }" +
69                              "}";
70        ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
71        // When
72        Optional<UsabilityDefect> recommendation = new TextInputEntryRepetitionsMetric(taskTree).calculate();
73        // Then
74        assertThat(recommendation).is(present()).has(infoRecommendationSeverityLevel());
75    }
76
77    @Test
78    public void should_return_recommendation_with_low_severity_level() {
79        // Given
80        String spec = "UserSession {" +
81                                  "  Sequence seq1 {" +
82                                  "    TextInput t1 (a b c) {}" +
83                                  "    Sequence seq3 {" +
84                                  "      TextInput t2 (a) {}" +
85                                  "      TextInput t3 (b) {}" +
86                                  "      TextInput t4 (c) {}" +
87                                  "    }" +
88                                  "  }" +
89                                  "}";
90        ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
91        // When
92        Optional<UsabilityDefect> recommendation = new TextInputEntryRepetitionsMetric(taskTree).calculate();
93        // Then
94        assertThat(recommendation).is(present()).has(lowRecommendationSeverityLevel());
95    }
96
97    @Test
98    public void should_return_recommendation_with_medium_severity_level() {
99        // Given
100        String spec = "UserSession {" +
101                              "  Sequence seq1 {" +
102                                  "    TextInput t1 (a b c d e f g h i j k l m) {}" +
103                              "    Sequence seq2 {" +
104                                  "      TextInput t2 (a) {}" +
105                              "      TextInput t3 (b) {}" +
106                                  "      TextInput t4 (c) {}" +
107                              "      TextInput t5 (d) {}" +
108                                  "    }" +
109                              "    Iteration iter1 {" +
110                                  "      TextInput t6 (e) {}" +
111                              "    }" +
112                                  "    TextInput t7 (a) {}" +
113                              "    Selection sel1 {" +
114                                  "      TextInput t8 (b) {}" +
115                                  "    }" +
116                              "    Selection sel1 {" +
117                                  "      TextInput t8 (c) {}" +
118                                  "    }" +
119                              "    Selection sel1 {" +
120                                  "      TextInput t8 (d) {}" +
121                                  "    }" +
122                              "    Selection sel1 {" +
123                                  "      TextInput t8 (e) {}" +
124                                  "    }" +
125                              "    Sequence seq3 {" +
126                                  "      TextInput t9 (a) {}" +
127                              "      Sequence seq4 {" +
128                                  "        TextInput t10 (b) {}" +
129                              "        TextInput t11 (c) {}" +
130                                  "        TextInput t12 (d) {}" +
131                              "        TextInput t13 (e) {}" +
132                                  "      }" +
133                              "    }" +
134                                  "    TextInput t14 (a) {}" +
135                                  "  }" +
136                              "}";
137        ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
138        // When
139        Optional<UsabilityDefect> recommendation = new TextInputEntryRepetitionsMetric(taskTree).calculate();
140        // Then
141        assertThat(recommendation).is(present()).has(mediumRecommendationSeverityLevel());
142    }
143
144    @Test
145    public void should_return_recommendation_with_high_severity_level() {
146        // Given
147        String spec = "UserSession {" +
148                                      "  Sequence seq1 {" +
149                                          "    TextInput t1 (a b c) {}" +
150                                      "    Sequence seq2 {" +
151                                          "      TextInput t2 (a) {}" +
152                                      "      TextInput t3 (b) {}" +
153                                          "      TextInput t4 (c) {}" +
154                                      "      TextInput t5 (a) {}" +
155                                          "    }" +
156                                      "    Iteration iter1 {" +
157                                          "      TextInput t6 (a) {}" +
158                                      "    }" +
159                                          "    TextInput t7 (a) {}" +
160                                      "    Selection sel1 {" +
161                                          "      TextInput t8 (b c) {}" +
162                                          "    }" +
163                                      "    Selection sel1 {" +
164                                          "      TextInput t8 (a) {}" +
165                                          "    }" +
166                                      "    Selection sel1 {" +
167                                          "      TextInput t8 (a c) {}" +
168                                          "    }" +
169                                      "    Selection sel1 {" +
170                                          "      TextInput t8 (b a) {}" +
171                                          "    }" +
172                                      "    Sequence seq3 {" +
173                                          "      TextInput t9 (b c) {}" +
174                                      "      Sequence seq4 {" +
175                                          "        TextInput t10 (d a c) {}" +
176                                      "        TextInput t11 (b b b a) {}" +
177                                          "        TextInput t12 (a a c c) {}" +
178                                      "        TextInput t13 (b b a) {}" +
179                                          "      }" +
180                                      "    }" +
181                                          "    TextInput t14 (a) {}" +
182                                          "  }" +
183                                      "}";
184        ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
185        // When
186        Optional<UsabilityDefect> recommendation = new TextInputEntryRepetitionsMetric(taskTree).calculate();
187        // Then
188        assertThat(recommendation).is(present()).has(highRecommendationSeverityLevel());
189    }
190}
Note: See TracBrowser for help on using the repository browser.