[1040] | 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.
|
---|
[1030] | 14 |
|
---|
[1141] | 15 | package de.ugoe.cs.autoquest.usability.rules.metrics;
|
---|
[1030] | 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 |
|
---|
[1171] | 29 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel;
|
---|
[1141] | 30 | import de.ugoe.cs.autoquest.usability.result.UsabilityDefect;
|
---|
[1171] | 31 | import de.ugoe.cs.autoquest.usability.testutil.GenerateTaskModelUtil;
|
---|
[1030] | 32 |
|
---|
[1040] | 33 | /**
|
---|
| 34 | * <p>
|
---|
| 35 | * TODO comment
|
---|
| 36 | * </p>
|
---|
| 37 | *
|
---|
| 38 | * @author Alexander Deicke
|
---|
| 39 | */
|
---|
[1171] | 40 | public class NoLetterOrDigitTextInputsEvaluatorTest {
|
---|
[1030] | 41 |
|
---|
| 42 | @Test
|
---|
| 43 | public void should_return_no_recommendation() {
|
---|
| 44 | // Given
|
---|
[1201] | 45 | String spec = "UserSession {" +
|
---|
| 46 | " Sequence seq1 {" +
|
---|
| 47 | " TextInput t1 {}" +
|
---|
| 48 | " }" +
|
---|
[1141] | 49 | "}";
|
---|
[1171] | 50 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1030] | 51 | // When
|
---|
[1151] | 52 | Optional<UsabilityDefect> recommendation = new NoLetterOrDigitRatioMetric(taskTree).calculate();
|
---|
[1030] | 53 | // Then
|
---|
| 54 | assertThat(recommendation).is(absent());
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | @Test
|
---|
| 58 | public void should_return_recommendation_with_info_severity_level() {
|
---|
| 59 | // Given
|
---|
[1201] | 60 | String spec = "UserSession {" +
|
---|
| 61 | " Sequence seq1 {" +
|
---|
| 62 | " TextInput t1 (1234567890123456789012345678901234567890123456789_01234567890" +
|
---|
| 63 | " 12345678901234567890123456789012345) {ggdgdg11}" +
|
---|
| 64 | " }" +
|
---|
| 65 | "}";
|
---|
[1171] | 66 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1030] | 67 | // When
|
---|
[1151] | 68 | Optional<UsabilityDefect> recommendation = new NoLetterOrDigitRatioMetric(taskTree).calculate();
|
---|
[1030] | 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
|
---|
[1201] | 76 | String spec = "UserSession {" +
|
---|
| 77 | " Sequence seq1 {" +
|
---|
| 78 | " TextInput t1 (123456789012345678901234567890_123456789012345) {}" +
|
---|
| 79 | " }" +
|
---|
| 80 | "}";
|
---|
[1171] | 81 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1030] | 82 | // When
|
---|
[1151] | 83 | Optional<UsabilityDefect> recommendation = new NoLetterOrDigitRatioMetric(taskTree).calculate();
|
---|
[1030] | 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
|
---|
[1201] | 91 | String spec = "UserSession {" +
|
---|
| 92 | " Sequence seq1 {" +
|
---|
| 93 | " TextInput t1 (12345_6789012345) {}" +
|
---|
| 94 | " }" +
|
---|
[1141] | 95 | "}";
|
---|
[1171] | 96 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1030] | 97 | // When
|
---|
[1151] | 98 | Optional<UsabilityDefect> recommendation = new NoLetterOrDigitRatioMetric(taskTree).calculate();
|
---|
[1030] | 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
|
---|
[1201] | 106 | String spec = "UserSession {" +
|
---|
| 107 | " Sequence seq1 {" +
|
---|
| 108 | " TextInput t1 (_a_b_c_) {}" +
|
---|
| 109 | " }" +
|
---|
[1141] | 110 | "}";
|
---|
[1171] | 111 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1030] | 112 | // When
|
---|
[1151] | 113 | Optional<UsabilityDefect> recommendation = new NoLetterOrDigitRatioMetric(taskTree).calculate();
|
---|
[1030] | 114 | // Then
|
---|
| 115 | assertThat(recommendation).is(present()).has(highRecommendationSeverityLevel());
|
---|
| 116 | }
|
---|
| 117 | }
|
---|