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 |
|
---|
15 | package de.ugoe.cs.autoquest.usability.rules.metrics;
|
---|
16 |
|
---|
17 | import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.absent;
|
---|
18 | import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.highRecommendationSeverityLevel;
|
---|
19 | import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.infoRecommendationSeverityLevel;
|
---|
20 | import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.lowRecommendationSeverityLevel;
|
---|
21 | import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.mediumRecommendationSeverityLevel;
|
---|
22 | import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.present;
|
---|
23 | import static org.fest.assertions.api.Assertions.assertThat;
|
---|
24 |
|
---|
25 | import org.junit.Test;
|
---|
26 |
|
---|
27 | import com.google.common.base.Optional;
|
---|
28 |
|
---|
29 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel;
|
---|
30 | import de.ugoe.cs.autoquest.usability.result.UsabilityProblemDescription;
|
---|
31 | import de.ugoe.cs.autoquest.usability.testutil.GenerateTaskModelUtil;
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * <p>
|
---|
35 | * TODO comment
|
---|
36 | * </p>
|
---|
37 | *
|
---|
38 | * @author Alexander Deicke
|
---|
39 | */
|
---|
40 | public class NoLetterOrDigitTextInputsEvaluatorTest {
|
---|
41 |
|
---|
42 | @Test
|
---|
43 | public void should_return_no_recommendation() {
|
---|
44 | // Given
|
---|
45 | String spec = "UserSession {" +
|
---|
46 | " Sequence seq1 {" +
|
---|
47 | " TextInput t1 {}" +
|
---|
48 | " }" +
|
---|
49 | "}";
|
---|
50 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
51 | // When
|
---|
52 | Optional<UsabilityProblemDescription> recommendation = new NoLetterOrDigitRatioMetric(taskTree).calculate();
|
---|
53 | // Then
|
---|
54 | assertThat(recommendation).is(absent());
|
---|
55 | }
|
---|
56 |
|
---|
57 | @Test
|
---|
58 | public void should_return_recommendation_with_info_severity_level() {
|
---|
59 | // Given
|
---|
60 | String spec = "UserSession {" +
|
---|
61 | " Sequence seq1 {" +
|
---|
62 | " TextInput t1 (1234567890123456789012345678901234567890123456789_01234567890" +
|
---|
63 | " 12345678901234567890123456789012345) {ggdgdg11}" +
|
---|
64 | " }" +
|
---|
65 | "}";
|
---|
66 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
67 | // When
|
---|
68 | Optional<UsabilityProblemDescription> recommendation = new NoLetterOrDigitRatioMetric(taskTree).calculate();
|
---|
69 | // Then
|
---|
70 | assertThat(recommendation).is(present()).has(infoRecommendationSeverityLevel());
|
---|
71 | }
|
---|
72 |
|
---|
73 | @Test
|
---|
74 | public void should_return_recommendation_with_low_severity_level() {
|
---|
75 | // Given
|
---|
76 | String spec = "UserSession {" +
|
---|
77 | " Sequence seq1 {" +
|
---|
78 | " TextInput t1 (123456789012345678901234567890_123456789012345) {}" +
|
---|
79 | " }" +
|
---|
80 | "}";
|
---|
81 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
82 | // When
|
---|
83 | Optional<UsabilityProblemDescription> recommendation = new NoLetterOrDigitRatioMetric(taskTree).calculate();
|
---|
84 | // Then
|
---|
85 | assertThat(recommendation).is(present()).has(lowRecommendationSeverityLevel());
|
---|
86 | }
|
---|
87 |
|
---|
88 | @Test
|
---|
89 | public void should_return_recommendation_with_medium_severity_level() {
|
---|
90 | // Given
|
---|
91 | String spec = "UserSession {" +
|
---|
92 | " Sequence seq1 {" +
|
---|
93 | " TextInput t1 (12345_6789012345) {}" +
|
---|
94 | " }" +
|
---|
95 | "}";
|
---|
96 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
97 | // When
|
---|
98 | Optional<UsabilityProblemDescription> recommendation = new NoLetterOrDigitRatioMetric(taskTree).calculate();
|
---|
99 | // Then
|
---|
100 | assertThat(recommendation).is(present()).has(mediumRecommendationSeverityLevel());
|
---|
101 | }
|
---|
102 |
|
---|
103 | @Test
|
---|
104 | public void should_return_recommendation_with_high_severity_level() {
|
---|
105 | // Given
|
---|
106 | String spec = "UserSession {" +
|
---|
107 | " Sequence seq1 {" +
|
---|
108 | " TextInput t1 (_a_b_c_) {}" +
|
---|
109 | " }" +
|
---|
110 | "}";
|
---|
111 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
112 | // When
|
---|
113 | Optional<UsabilityProblemDescription> recommendation = new NoLetterOrDigitRatioMetric(taskTree).calculate();
|
---|
114 | // Then
|
---|
115 | assertThat(recommendation).is(present()).has(highRecommendationSeverityLevel());
|
---|
116 | }
|
---|
117 | }
|
---|