1 |
|
---|
2 | package de.ugoe.cs.autoquest.usability.evaluation.rule.evaluator;
|
---|
3 |
|
---|
4 | import static de.ugoe.cs.autoquest.usability.evaluation.rule.set.RulesetFactory.textInputUsabiliyRuleset;
|
---|
5 | import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.absent;
|
---|
6 | import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.highRecommendationSeverityLevel;
|
---|
7 | import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.infoRecommendationSeverityLevel;
|
---|
8 | import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.lowRecommendationSeverityLevel;
|
---|
9 | import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.mediumRecommendationSeverityLevel;
|
---|
10 | import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.present;
|
---|
11 | import static org.fest.assertions.api.Assertions.assertThat;
|
---|
12 |
|
---|
13 | import java.util.EnumSet;
|
---|
14 |
|
---|
15 | import org.junit.After;
|
---|
16 | import org.junit.Before;
|
---|
17 | import org.junit.Test;
|
---|
18 |
|
---|
19 | import com.google.common.base.Optional;
|
---|
20 | import com.google.common.base.Predicate;
|
---|
21 | import com.google.common.collect.Iterables;
|
---|
22 |
|
---|
23 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTree;
|
---|
24 | import de.ugoe.cs.autoquest.usability.evaluation.result.UsabilityDefect;
|
---|
25 | import de.ugoe.cs.autoquest.usability.evaluation.rule.set.UsabilityRule;
|
---|
26 | import de.ugoe.cs.autoquest.usability.tasktree.filter.FilterStatisticCache;
|
---|
27 |
|
---|
28 | public class NoLetterOrDigitTextInputsEvaluatorTest extends AbstractUsabilityEvaluationTC {
|
---|
29 |
|
---|
30 | private UsabilityRule ruleUnderTest;
|
---|
31 |
|
---|
32 | @Before
|
---|
33 | public void initRuleUnderTest() {
|
---|
34 | EnumSet<? extends UsabilityRule> ruleset =
|
---|
35 | textInputUsabiliyRuleset().getRulesetForUsabilityEvaluation();
|
---|
36 | this.ruleUnderTest = Iterables.find(ruleset, new Predicate<UsabilityRule>() {
|
---|
37 |
|
---|
38 | public boolean apply(UsabilityRule usabilityRule) {
|
---|
39 | return usabilityRule.ruleIdentifier().equals("TEXT_FIELD_NO_LETTER_OR_DIGIT_RATIO");
|
---|
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 NoLetterOrDigitTextInputsEvaluator(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 {"
|
---|
67 | + " TextInput (1234567890123456789012345678901234567890123456789_01234567890"
|
---|
68 | + "12345678901234567890123456789012345) {}" + "}";
|
---|
69 | ITaskTree taskTree = createTaskTree(spec);
|
---|
70 | // When
|
---|
71 | Optional<UsabilityDefect> recommendation =
|
---|
72 | new NoLetterOrDigitTextInputsEvaluator(this.ruleUnderTest, taskTree).evaluationResult();
|
---|
73 | // Then
|
---|
74 | assertThat(recommendation).is(present()).has(infoRecommendationSeverityLevel());
|
---|
75 | }
|
---|
76 |
|
---|
77 | @Test
|
---|
78 | public void should_return_recommendation_with_low_severity_level() {
|
---|
79 | // Given
|
---|
80 | String spec =
|
---|
81 | "Sequence {" + " TextInput (123456789012345678901234567890_123456789012345) {}" + "}";
|
---|
82 | ITaskTree taskTree = createTaskTree(spec);
|
---|
83 | // When
|
---|
84 | Optional<UsabilityDefect> recommendation =
|
---|
85 | new NoLetterOrDigitTextInputsEvaluator(this.ruleUnderTest, taskTree).evaluationResult();
|
---|
86 | // Then
|
---|
87 | assertThat(recommendation).is(present()).has(lowRecommendationSeverityLevel());
|
---|
88 | }
|
---|
89 |
|
---|
90 | @Test
|
---|
91 | public void should_return_recommendation_with_medium_severity_level() {
|
---|
92 | // Given
|
---|
93 | String spec = "Sequence {" + " TextInput (12345_6789012345) {}" + "}";
|
---|
94 | ITaskTree taskTree = createTaskTree(spec);
|
---|
95 | // When
|
---|
96 | Optional<UsabilityDefect> recommendation =
|
---|
97 | new NoLetterOrDigitTextInputsEvaluator(this.ruleUnderTest, taskTree).evaluationResult();
|
---|
98 | // Then
|
---|
99 | assertThat(recommendation).is(present()).has(mediumRecommendationSeverityLevel());
|
---|
100 | }
|
---|
101 |
|
---|
102 | @Test
|
---|
103 | public void should_return_recommendation_with_high_severity_level() {
|
---|
104 | // Given
|
---|
105 | String spec = "Sequence {" + " TextInput (_a_b_c_) {}" + "}";
|
---|
106 | ITaskTree taskTree = createTaskTree(spec);
|
---|
107 | // When
|
---|
108 | Optional<UsabilityDefect> recommendation =
|
---|
109 | new NoLetterOrDigitTextInputsEvaluator(this.ruleUnderTest, taskTree).evaluationResult();
|
---|
110 | // Then
|
---|
111 | assertThat(recommendation).is(present()).has(highRecommendationSeverityLevel());
|
---|
112 | }
|
---|
113 | }
|
---|