source: trunk/autoquest-core-usability-evaluation-test/src/main/java/de/ugoe/cs/autoquest/usability/evaluation/rule/evaluator/NoLetterOrDigitTextInputsEvaluatorTest.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: 5.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.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 NoLetterOrDigitTextInputsEvaluatorTest 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_NO_LETTER_OR_DIGIT_RATIO");
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 NoLetterOrDigitTextInputsEvaluator(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 {"
86                + "  TextInput (1234567890123456789012345678901234567890123456789_01234567890"
87                + "12345678901234567890123456789012345) {}" + "}";
88        ITaskTree taskTree = createTaskTree(spec);
89        // When
90        Optional<UsabilityDefect> recommendation =
91            new NoLetterOrDigitTextInputsEvaluator(this.ruleUnderTest, taskTree).evaluationResult();
92        // Then
93        assertThat(recommendation).is(present()).has(infoRecommendationSeverityLevel());
94    }
95
96    @Test
97    public void should_return_recommendation_with_low_severity_level() {
98        // Given
99        String spec =
100            "Sequence {" + "  TextInput (123456789012345678901234567890_123456789012345) {}" + "}";
101        ITaskTree taskTree = createTaskTree(spec);
102        // When
103        Optional<UsabilityDefect> recommendation =
104            new NoLetterOrDigitTextInputsEvaluator(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 = "Sequence {" + "  TextInput (12345_6789012345) {}" + "}";
113        ITaskTree taskTree = createTaskTree(spec);
114        // When
115        Optional<UsabilityDefect> recommendation =
116            new NoLetterOrDigitTextInputsEvaluator(this.ruleUnderTest, taskTree).evaluationResult();
117        // Then
118        assertThat(recommendation).is(present()).has(mediumRecommendationSeverityLevel());
119    }
120
121    @Test
122    public void should_return_recommendation_with_high_severity_level() {
123        // Given
124        String spec = "Sequence {" + "  TextInput (_a_b_c_) {}" + "}";
125        ITaskTree taskTree = createTaskTree(spec);
126        // When
127        Optional<UsabilityDefect> recommendation =
128            new NoLetterOrDigitTextInputsEvaluator(this.ruleUnderTest, taskTree).evaluationResult();
129        // Then
130        assertThat(recommendation).is(present()).has(highRecommendationSeverityLevel());
131    }
132}
Note: See TracBrowser for help on using the repository browser.