source: trunk/autoquest-core-usability-evaluation-test/src/main/java/de/ugoe/cs/autoquest/usability/evaluation/rule/evaluator/TextInputRatioEvaluatorTest.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.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.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 TextInputRatioEvaluatorTest 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_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 =
73            "Sequence {" + "  Interaction {}" + "  TextInput (a) {}" + "  Interaction {}"
74                + "  Interaction {}" + "  TextInput (c) {}" + "  Interaction {}"
75                + "  Interaction {}" + "  Interaction {}" + "}";
76        ITaskTree taskTree = createTaskTree(spec);
77        // When
78        Optional<UsabilityDefect> recommendation =
79            new TextInputRatioEvaluator(this.ruleUnderTest, taskTree).evaluationResult();
80        // Then
81        assertThat(recommendation).is(absent());
82    }
83
84    @Test
85    public void should_return_recommendation_with_info_severity_level() {
86        // Given
87        String spec =
88            "Sequence {" + "  Interaction {}" + "  TextInput (a) {}" + "  Interaction {}"
89                + "  Interaction {}" + "  TextInput (c) {}" + "}";
90        ITaskTree taskTree = createTaskTree(spec);
91        // When
92        Optional<UsabilityDefect> recommendation =
93            new TextInputRatioEvaluator(this.ruleUnderTest, taskTree).evaluationResult();
94        // Then
95        assertThat(recommendation).is(present()).has(infoRecommendationSeverityLevel());
96    }
97
98    @Test
99    public void should_return_recommendation_with_low_severity_level() {
100        // Given
101        String spec =
102            "Sequence {" + "  Interaction {}" + "  TextInput (a) {}" + "  TextInput (b) {}"
103                + "  Interaction {}" + "  TextInput (c) {}" + "}";
104        ITaskTree taskTree = createTaskTree(spec);
105        // When
106        Optional<UsabilityDefect> recommendation =
107            new TextInputRatioEvaluator(this.ruleUnderTest, taskTree).evaluationResult();
108        // Then
109        assertThat(recommendation).is(present()).has(lowRecommendationSeverityLevel());
110    }
111
112    @Test
113    public void should_return_recommendation_with_medium_severity_level() {
114        // Given
115        String spec =
116            "Sequence {" + "  TextInput (a) {}" + "  TextInput (b) {}" + "  Interaction {}"
117                + "  TextInput (c) {}" + "}";
118        ITaskTree taskTree = createTaskTree(spec);
119        // When
120        Optional<UsabilityDefect> recommendation =
121            new TextInputRatioEvaluator(this.ruleUnderTest, taskTree).evaluationResult();
122        // Then
123        assertThat(recommendation).is(present()).has(mediumRecommendationSeverityLevel());
124    }
125
126    @Test
127    public void should_return_recommendation_with_high_severity_level() {
128        // Given
129        String spec = "TextInput (bla) {}";
130        ITaskTree taskTree = createTaskTree(spec);
131        // When
132        Optional<UsabilityDefect> recommendation =
133            new TextInputRatioEvaluator(this.ruleUnderTest, taskTree).evaluationResult();
134        // Then
135        assertThat(recommendation).is(present()).has(highRecommendationSeverityLevel());
136    }
137}
Note: See TracBrowser for help on using the repository browser.