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

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

Adapted test project to refactoring of evaluation project.

  • Property svn:mime-type set to text/plain
File size: 5.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.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.ITaskTree;
30import de.ugoe.cs.autoquest.usability.result.UsabilityDefect;
31import de.ugoe.cs.autoquest.usability.rules.metrics.TextInputEntryRepetitionsMetric;
32
33/**
34 * <p>
35 * TODO comment
36 * </p>
37 *
38 * @author Alexander Deicke
39 */
40public class TextInputEntryRepetitionsEvaluatorTest extends AbstractUsabilityEvaluationTC {
41
42    @Test
43    public void should_return_no_recommendation() {
44        // Given
45        String spec = "Sequence {" + "  TextInput () {}" + "}";
46        ITaskTree taskTree = createTaskTree(spec);
47        // When
48        Optional<UsabilityDefect> recommendation = new TextInputEntryRepetitionsMetric(taskTree).check();
49        // Then
50        assertThat(recommendation).is(absent());
51    }
52
53    @Test
54    public void should_return_recommendation_with_info_severity_level() {
55        // Given
56        String spec =
57            "Sequence {" + "  TextInput (a b c) {}" + "  Sequence {" + "    TextInput (a) {}"
58                + "    TextInput (d) {}" + "    TextInput (e) {}" + "  }" + "}";
59        ITaskTree taskTree = createTaskTree(spec);
60        // When
61        Optional<UsabilityDefect> recommendation = new TextInputEntryRepetitionsMetric(taskTree).check();
62        // Then
63        assertThat(recommendation).is(present()).has(infoRecommendationSeverityLevel());
64    }
65
66    @Test
67    public void should_return_recommendation_with_low_severity_level() {
68        // Given
69        String spec =
70            "Sequence {" + "  TextInput (a b c) {}" + "  Sequence {" + "    TextInput (a) {}"
71                + "    TextInput (b) {}" + "    TextInput (c) {}" + "  }" + "}";
72        ITaskTree taskTree = createTaskTree(spec);
73        // When
74        Optional<UsabilityDefect> recommendation = new TextInputEntryRepetitionsMetric(taskTree).check();
75        // Then
76        assertThat(recommendation).is(present()).has(lowRecommendationSeverityLevel());
77    }
78
79    @Test
80    public void should_return_recommendation_with_medium_severity_level() {
81        // Given
82        String spec =
83            "Sequence {" + "  TextInput (a b c d e f g h i j k l m) {}" + "  Sequence {"
84                + "    TextInput (a) {}" + "    TextInput (b) {}" + "    TextInput (c) {}"
85                + "    TextInput (d) {}" + "  }" + "  Iteration {" + "    TextInput (e) {}" + "  }"
86                + "  TextInput (a) {}" + "  Selection {" + "    TextInput (b) {}"
87                + "    TextInput (c) {}" + "    TextInput (d) {}" + "    TextInput (e) {}" + "  }"
88                + "  Sequence {" + "    TextInput (a) {}" + "    Sequence {"
89                + "      TextInput (b) {}" + "      TextInput (c) {}" + "      TextInput (d) {}"
90                + "      TextInput (e) {}" + "    }" + "  }" + "  TextInput (f) {}" + "}";
91        ITaskTree taskTree = createTaskTree(spec);
92        // When
93        Optional<UsabilityDefect> recommendation = new TextInputEntryRepetitionsMetric(taskTree).check();
94        // Then
95        assertThat(recommendation).is(present()).has(mediumRecommendationSeverityLevel());
96    }
97
98    @Test
99    public void should_return_recommendation_with_high_severity_level() {
100        // Given
101        String spec =
102            "Sequence {" + "  TextInput (a b c) {}" + "  Sequence {" + "    TextInput (a) {}"
103                + "    TextInput (b) {}" + "    TextInput (c) {}" + "    TextInput (a) {}" + "  }"
104                + "  Iteration {" + "    TextInput (a) {}" + "  }" + "  TextInput (a) {}"
105                + "  Selection {" + "    TextInput (b c) {}" + "    TextInput (a) {}"
106                + "    TextInput (a c) {}" + "    TextInput (b a) {}" + "  }" + "  Sequence {"
107                + "    TextInput (b c) {}" + "    Sequence {" + "      TextInput (d a c) {}"
108                + "      TextInput (b b b a) {}" + "      TextInput (a a c c) {}"
109                + "      TextInput (b b a) {}" + "    }" + "  }" + "  TextInput (d) {}" + "}";
110        ITaskTree taskTree = createTaskTree(spec);
111        // When
112        Optional<UsabilityDefect> recommendation = new TextInputEntryRepetitionsMetric(taskTree).check();
113        // Then
114        assertThat(recommendation).is(present()).has(highRecommendationSeverityLevel());
115    }
116}
Note: See TracBrowser for help on using the repository browser.