source: trunk/autoquest-core-usability-evaluation-test/src/main/java/de/ugoe/cs/autoquest/usability/evaluation/rule/evaluator/TextInputEntryRepetitionsEvaluatorTest.java @ 1040

Last change on this file since 1040 was 1040, checked in by adeicke, 11 years ago
  • Removed lombok related annotations and util class
  • Added comments and formating due to match project defaults
  • Property svn:mime-type set to text/plain
File size: 6.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.evaluation.rule.evaluator;
16
17import static de.ugoe.cs.autoquest.usability.evaluation.rule.set.RulesetFactory.textInputUsabiliyRuleset;
18import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.absent;
19import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.highRecommendationSeverityLevel;
20import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.infoRecommendationSeverityLevel;
21import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.lowRecommendationSeverityLevel;
22import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.mediumRecommendationSeverityLevel;
23import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.present;
24import static org.fest.assertions.api.Assertions.assertThat;
25
26import java.util.EnumSet;
27
28import org.junit.After;
29import org.junit.Before;
30import org.junit.Test;
31
32import com.google.common.base.Optional;
33import com.google.common.base.Predicate;
34import com.google.common.collect.Iterables;
35
36import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTree;
37import de.ugoe.cs.autoquest.usability.evaluation.result.UsabilityDefect;
38import de.ugoe.cs.autoquest.usability.evaluation.rule.set.UsabilityRule;
39import de.ugoe.cs.autoquest.usability.tasktree.filter.FilterStatisticCache;
40
41/**
42 * <p>
43 * TODO comment
44 * </p>
45 *
46 * @author Alexander Deicke
47 */
48public class TextInputEntryRepetitionsEvaluatorTest extends AbstractUsabilityEvaluationTC {
49
50    private UsabilityRule ruleUnderTest;
51
52    @Before
53    public void initRuleUnderTest() {
54        EnumSet<? extends UsabilityRule> ruleset = textInputUsabiliyRuleset().evaluationRules();
55        this.ruleUnderTest = Iterables.find(ruleset, new Predicate<UsabilityRule>() {
56
57            public boolean apply(UsabilityRule usabilityRule) {
58                return usabilityRule.ruleIdentifier().equals("TEXT_FIELD_INPUT_REPETITIONS");
59            }
60
61        });
62    }
63
64    @After
65    public void clearFilterStatisticCache() {
66        FilterStatisticCache.instance().clear();
67    }
68
69    @Test
70    public void should_return_no_recommendation() {
71        // Given
72        String spec = "Sequence {" + "  TextInput () {}" + "}";
73        ITaskTree taskTree = createTaskTree(spec);
74        // When
75        Optional<UsabilityDefect> recommendation =
76            new TextInputEntryRepetitionsEvaluator(this.ruleUnderTest, taskTree).evaluationResult();
77        // Then
78        assertThat(recommendation).is(absent());
79    }
80
81    @Test
82    public void should_return_recommendation_with_info_severity_level() {
83        // Given
84        String spec =
85            "Sequence {" + "  TextInput (a b c) {}" + "  Sequence {" + "    TextInput (a) {}"
86                + "    TextInput (d) {}" + "    TextInput (e) {}" + "  }" + "}";
87        ITaskTree taskTree = createTaskTree(spec);
88        // When
89        Optional<UsabilityDefect> recommendation =
90            new TextInputEntryRepetitionsEvaluator(this.ruleUnderTest, taskTree).evaluationResult();
91        // Then
92        assertThat(recommendation).is(present()).has(infoRecommendationSeverityLevel());
93    }
94
95    @Test
96    public void should_return_recommendation_with_low_severity_level() {
97        // Given
98        String spec =
99            "Sequence {" + "  TextInput (a b c) {}" + "  Sequence {" + "    TextInput (a) {}"
100                + "    TextInput (b) {}" + "    TextInput (c) {}" + "  }" + "}";
101        ITaskTree taskTree = createTaskTree(spec);
102        // When
103        Optional<UsabilityDefect> recommendation =
104            new TextInputEntryRepetitionsEvaluator(this.ruleUnderTest, taskTree).evaluationResult();
105        // Then
106        assertThat(recommendation).is(present()).has(lowRecommendationSeverityLevel());
107    }
108
109    @Test
110    public void should_return_recommendation_with_medium_severity_level() {
111        // Given
112        String spec =
113            "Sequence {" + "  TextInput (a b c d e f g h i j k l m) {}" + "  Sequence {"
114                + "    TextInput (a) {}" + "    TextInput (b) {}" + "    TextInput (c) {}"
115                + "    TextInput (d) {}" + "  }" + "  Iteration {" + "    TextInput (e) {}" + "  }"
116                + "  TextInput (a) {}" + "  Selection {" + "    TextInput (b) {}"
117                + "    TextInput (c) {}" + "    TextInput (d) {}" + "    TextInput (e) {}" + "  }"
118                + "  Sequence {" + "    TextInput (a) {}" + "    Sequence {"
119                + "      TextInput (b) {}" + "      TextInput (c) {}" + "      TextInput (d) {}"
120                + "      TextInput (e) {}" + "    }" + "  }" + "  TextInput (f) {}" + "}";
121        ITaskTree taskTree = createTaskTree(spec);
122        // When
123        Optional<UsabilityDefect> recommendation =
124            new TextInputEntryRepetitionsEvaluator(this.ruleUnderTest, taskTree).evaluationResult();
125        // Then
126        assertThat(recommendation).is(present()).has(mediumRecommendationSeverityLevel());
127    }
128
129    @Test
130    public void should_return_recommendation_with_high_severity_level() {
131        // Given
132        String spec =
133            "Sequence {" + "  TextInput (a b c) {}" + "  Sequence {" + "    TextInput (a) {}"
134                + "    TextInput (b) {}" + "    TextInput (c) {}" + "    TextInput (a) {}" + "  }"
135                + "  Iteration {" + "    TextInput (a) {}" + "  }" + "  TextInput (a) {}"
136                + "  Selection {" + "    TextInput (b c) {}" + "    TextInput (a) {}"
137                + "    TextInput (a c) {}" + "    TextInput (b a) {}" + "  }" + "  Sequence {"
138                + "    TextInput (b c) {}" + "    Sequence {" + "      TextInput (d a c) {}"
139                + "      TextInput (b b b a) {}" + "      TextInput (a a c c) {}"
140                + "      TextInput (b b a) {}" + "    }" + "  }" + "  TextInput (d) {}" + "}";
141        ITaskTree taskTree = createTaskTree(spec);
142        // When
143        Optional<UsabilityDefect> recommendation =
144            new TextInputEntryRepetitionsEvaluator(this.ruleUnderTest, taskTree).evaluationResult();
145        // Then
146        assertThat(recommendation).is(present()).has(highRecommendationSeverityLevel());
147    }
148}
Note: See TracBrowser for help on using the repository browser.