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

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

Renamed getRulesetForUsabilityEvaluation method to evaluationRules

  • Property svn:mime-type set to text/plain
File size: 6.1 KB
Line 
1
2package de.ugoe.cs.autoquest.usability.evaluation.rule.evaluator;
3
4import static de.ugoe.cs.autoquest.usability.evaluation.rule.set.RulesetFactory.textInputUsabiliyRuleset;
5import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.absent;
6import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.highRecommendationSeverityLevel;
7import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.infoRecommendationSeverityLevel;
8import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.lowRecommendationSeverityLevel;
9import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.mediumRecommendationSeverityLevel;
10import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.present;
11import static org.fest.assertions.api.Assertions.assertThat;
12
13import java.util.EnumSet;
14
15import org.junit.After;
16import org.junit.Before;
17import org.junit.Test;
18
19import com.google.common.base.Optional;
20import com.google.common.base.Predicate;
21import com.google.common.collect.Iterables;
22
23import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTree;
24import de.ugoe.cs.autoquest.usability.evaluation.result.UsabilityDefect;
25import de.ugoe.cs.autoquest.usability.evaluation.rule.set.UsabilityRule;
26import de.ugoe.cs.autoquest.usability.tasktree.filter.FilterStatisticCache;
27
28public class TextInputEntryRepetitionsEvaluatorTest extends AbstractUsabilityEvaluationTC {
29
30    private UsabilityRule ruleUnderTest;
31
32    @Before
33    public void initRuleUnderTest() {
34        EnumSet<? extends UsabilityRule> ruleset =
35            textInputUsabiliyRuleset().evaluationRules();
36        this.ruleUnderTest = Iterables.find(ruleset, new Predicate<UsabilityRule>() {
37
38            public boolean apply(UsabilityRule usabilityRule) {
39                return usabilityRule.ruleIdentifier().equals("TEXT_FIELD_INPUT_REPETITIONS");
40            }
41
42        });
43    }
44
45    @After
46    public void clearFilterStatisticCache() {
47        FilterStatisticCache.instance().clear();
48    }
49
50    @Test
51    public void should_return_no_recommendation() {
52        // Given
53        String spec = "Sequence {" + "  TextInput () {}" + "}";
54        ITaskTree taskTree = createTaskTree(spec);
55        // When
56        Optional<UsabilityDefect> recommendation =
57            new TextInputEntryRepetitionsEvaluator(this.ruleUnderTest, taskTree).evaluationResult();
58        // Then
59        assertThat(recommendation).is(absent());
60    }
61
62    @Test
63    public void should_return_recommendation_with_info_severity_level() {
64        // Given
65        String spec =
66            "Sequence {" + "  TextInput (a b c) {}" + "  Sequence {" + "    TextInput (a) {}"
67                + "    TextInput (d) {}" + "    TextInput (e) {}" + "  }" + "}";
68        ITaskTree taskTree = createTaskTree(spec);
69        // When
70        Optional<UsabilityDefect> recommendation =
71            new TextInputEntryRepetitionsEvaluator(this.ruleUnderTest, taskTree).evaluationResult();
72        // Then
73        assertThat(recommendation).is(present()).has(infoRecommendationSeverityLevel());
74    }
75
76    @Test
77    public void should_return_recommendation_with_low_severity_level() {
78        // Given
79        String spec =
80            "Sequence {" + "  TextInput (a b c) {}" + "  Sequence {" + "    TextInput (a) {}"
81                + "    TextInput (b) {}" + "    TextInput (c) {}" + "  }" + "}";
82        ITaskTree taskTree = createTaskTree(spec);
83        // When
84        Optional<UsabilityDefect> recommendation =
85            new TextInputEntryRepetitionsEvaluator(this.ruleUnderTest, taskTree).evaluationResult();
86        // Then
87        assertThat(recommendation).is(present()).has(lowRecommendationSeverityLevel());    }
88
89    @Test
90    public void should_return_recommendation_with_medium_severity_level() {
91        // Given
92        String spec =
93            "Sequence {" + "  TextInput (a b c d e f g h i j k l m) {}" + "  Sequence {"
94                + "    TextInput (a) {}" + "    TextInput (b) {}" + "    TextInput (c) {}"
95                + "    TextInput (d) {}" + "  }" + "  Iteration {" + "    TextInput (e) {}" + "  }"
96                + "  TextInput (a) {}" + "  Selection {" + "    TextInput (b) {}"
97                + "    TextInput (c) {}" + "    TextInput (d) {}" + "    TextInput (e) {}" + "  }"
98                + "  Sequence {" + "    TextInput (a) {}" + "    Sequence {"
99                + "      TextInput (b) {}" + "      TextInput (c) {}" + "      TextInput (d) {}"
100                + "      TextInput (e) {}" + "    }" + "  }" + "  TextInput (f) {}" + "}";
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(mediumRecommendationSeverityLevel());
107    }
108
109    @Test
110    public void should_return_recommendation_with_high_severity_level() {
111        // Given
112        String spec =
113            "Sequence {" + "  TextInput (a b c) {}" + "  Sequence {" + "    TextInput (a) {}"
114                + "    TextInput (b) {}" + "    TextInput (c) {}" + "    TextInput (a) {}" + "  }"
115                + "  Iteration {" + "    TextInput (a) {}" + "  }" + "  TextInput (a) {}"
116                + "  Selection {" + "    TextInput (b c) {}" + "    TextInput (a) {}"
117                + "    TextInput (a c) {}" + "    TextInput (b a) {}" + "  }" + "  Sequence {"
118                + "    TextInput (b c) {}" + "    Sequence {" + "      TextInput (d a c) {}"
119                + "      TextInput (b b b a) {}" + "      TextInput (a a c c) {}"
120                + "      TextInput (b b a) {}" + "    }" + "  }" + "  TextInput (d) {}" + "}";
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(highRecommendationSeverityLevel());
127    }
128}
Note: See TracBrowser for help on using the repository browser.