[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 |
|
---|
| 29 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTree;
|
---|
[1141] | 30 | import de.ugoe.cs.autoquest.usability.result.UsabilityDefect;
|
---|
| 31 | import de.ugoe.cs.autoquest.usability.rules.metrics.NoLetterOrDigitRatioMetric;
|
---|
[1030] | 32 |
|
---|
[1040] | 33 | /**
|
---|
| 34 | * <p>
|
---|
| 35 | * TODO comment
|
---|
| 36 | * </p>
|
---|
| 37 | *
|
---|
| 38 | * @author Alexander Deicke
|
---|
| 39 | */
|
---|
[1030] | 40 | public class NoLetterOrDigitTextInputsEvaluatorTest extends AbstractUsabilityEvaluationTC {
|
---|
| 41 |
|
---|
| 42 | @Test
|
---|
| 43 | public void should_return_no_recommendation() {
|
---|
| 44 | // Given
|
---|
[1141] | 45 | String spec = "Sequence {" +
|
---|
| 46 | " TextInput () {}" +
|
---|
| 47 | "}";
|
---|
[1030] | 48 | ITaskTree taskTree = createTaskTree(spec);
|
---|
| 49 | // When
|
---|
[1151] | 50 | Optional<UsabilityDefect> recommendation = new NoLetterOrDigitRatioMetric(taskTree).calculate();
|
---|
[1030] | 51 | // Then
|
---|
| 52 | assertThat(recommendation).is(absent());
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | @Test
|
---|
| 56 | public void should_return_recommendation_with_info_severity_level() {
|
---|
| 57 | // Given
|
---|
| 58 | String spec =
|
---|
[1141] | 59 | "Sequence {" +
|
---|
| 60 | " TextInput (1234567890123456789012345678901234567890123456789_01234567890" +
|
---|
| 61 | "12345678901234567890123456789012345) {}" +
|
---|
| 62 | "}";
|
---|
[1030] | 63 | ITaskTree taskTree = createTaskTree(spec);
|
---|
| 64 | // When
|
---|
[1151] | 65 | Optional<UsabilityDefect> recommendation = new NoLetterOrDigitRatioMetric(taskTree).calculate();
|
---|
[1030] | 66 | // Then
|
---|
| 67 | assertThat(recommendation).is(present()).has(infoRecommendationSeverityLevel());
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | @Test
|
---|
| 71 | public void should_return_recommendation_with_low_severity_level() {
|
---|
| 72 | // Given
|
---|
| 73 | String spec =
|
---|
[1141] | 74 | "Sequence {" +
|
---|
| 75 | " TextInput (123456789012345678901234567890_123456789012345) {}" +
|
---|
| 76 | "}";
|
---|
[1030] | 77 | ITaskTree taskTree = createTaskTree(spec);
|
---|
| 78 | // When
|
---|
[1151] | 79 | Optional<UsabilityDefect> recommendation = new NoLetterOrDigitRatioMetric(taskTree).calculate();
|
---|
[1030] | 80 | // Then
|
---|
| 81 | assertThat(recommendation).is(present()).has(lowRecommendationSeverityLevel());
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | @Test
|
---|
| 85 | public void should_return_recommendation_with_medium_severity_level() {
|
---|
| 86 | // Given
|
---|
[1141] | 87 | String spec = "Sequence {" +
|
---|
| 88 | " TextInput (12345_6789012345) {}" +
|
---|
| 89 | "}";
|
---|
[1030] | 90 | ITaskTree taskTree = createTaskTree(spec);
|
---|
| 91 | // When
|
---|
[1151] | 92 | Optional<UsabilityDefect> recommendation = new NoLetterOrDigitRatioMetric(taskTree).calculate();
|
---|
[1030] | 93 | // Then
|
---|
| 94 | assertThat(recommendation).is(present()).has(mediumRecommendationSeverityLevel());
|
---|
| 95 | }
|
---|
| 96 |
|
---|
| 97 | @Test
|
---|
| 98 | public void should_return_recommendation_with_high_severity_level() {
|
---|
| 99 | // Given
|
---|
[1141] | 100 | String spec = "Sequence {" +
|
---|
| 101 | " TextInput (_a_b_c_) {}" +
|
---|
| 102 | "}";
|
---|
[1030] | 103 | ITaskTree taskTree = createTaskTree(spec);
|
---|
| 104 | // When
|
---|
[1151] | 105 | Optional<UsabilityDefect> recommendation = new NoLetterOrDigitRatioMetric(taskTree).calculate();
|
---|
[1030] | 106 | // Then
|
---|
| 107 | assertThat(recommendation).is(present()).has(highRecommendationSeverityLevel());
|
---|
| 108 | }
|
---|
| 109 | }
|
---|