[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 TextInputEntryRepetitionsEvaluatorTest {
|
---|
[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 | " }" +
|
---|
| 49 | "}";
|
---|
[1171] | 50 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1030] | 51 | // When
|
---|
[1151] | 52 | Optional<UsabilityDefect> recommendation = new TextInputEntryRepetitionsMetric(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 (a b c) {}" +
|
---|
| 63 | " Sequence seq2 {" +
|
---|
| 64 | " TextInput t2 (a) {}" +
|
---|
| 65 | " TextInput t3 (d) {}" +
|
---|
| 66 | " TextInput t4 (e) {}" +
|
---|
| 67 | " }" +
|
---|
| 68 | " }" +
|
---|
| 69 | "}";
|
---|
[1171] | 70 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1030] | 71 | // When
|
---|
[1151] | 72 | Optional<UsabilityDefect> recommendation = new TextInputEntryRepetitionsMetric(taskTree).calculate();
|
---|
[1030] | 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
|
---|
[1201] | 80 | String spec = "UserSession {" +
|
---|
| 81 | " Sequence seq1 {" +
|
---|
| 82 | " TextInput t1 (a b c) {}" +
|
---|
| 83 | " Sequence seq3 {" +
|
---|
| 84 | " TextInput t2 (a) {}" +
|
---|
| 85 | " TextInput t3 (b) {}" +
|
---|
| 86 | " TextInput t4 (c) {}" +
|
---|
| 87 | " }" +
|
---|
| 88 | " }" +
|
---|
| 89 | "}";
|
---|
[1171] | 90 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1030] | 91 | // When
|
---|
[1151] | 92 | Optional<UsabilityDefect> recommendation = new TextInputEntryRepetitionsMetric(taskTree).calculate();
|
---|
[1030] | 93 | // Then
|
---|
[1040] | 94 | assertThat(recommendation).is(present()).has(lowRecommendationSeverityLevel());
|
---|
| 95 | }
|
---|
[1030] | 96 |
|
---|
| 97 | @Test
|
---|
| 98 | public void should_return_recommendation_with_medium_severity_level() {
|
---|
| 99 | // Given
|
---|
[1201] | 100 | String spec = "UserSession {" +
|
---|
| 101 | " Sequence seq1 {" +
|
---|
| 102 | " TextInput t1 (a b c d e f g h i j k l m) {}" +
|
---|
| 103 | " Sequence seq2 {" +
|
---|
| 104 | " TextInput t2 (a) {}" +
|
---|
| 105 | " TextInput t3 (b) {}" +
|
---|
| 106 | " TextInput t4 (c) {}" +
|
---|
| 107 | " TextInput t5 (d) {}" +
|
---|
| 108 | " }" +
|
---|
| 109 | " Iteration iter1 {" +
|
---|
| 110 | " TextInput t6 (e) {}" +
|
---|
| 111 | " }" +
|
---|
| 112 | " TextInput t7 (a) {}" +
|
---|
| 113 | " Selection sel1 {" +
|
---|
| 114 | " TextInput t8 (b) {}" +
|
---|
| 115 | " }" +
|
---|
| 116 | " Selection sel1 {" +
|
---|
| 117 | " TextInput t8 (c) {}" +
|
---|
| 118 | " }" +
|
---|
| 119 | " Selection sel1 {" +
|
---|
| 120 | " TextInput t8 (d) {}" +
|
---|
| 121 | " }" +
|
---|
| 122 | " Selection sel1 {" +
|
---|
| 123 | " TextInput t8 (e) {}" +
|
---|
| 124 | " }" +
|
---|
| 125 | " Sequence seq3 {" +
|
---|
| 126 | " TextInput t9 (a) {}" +
|
---|
| 127 | " Sequence seq4 {" +
|
---|
| 128 | " TextInput t10 (b) {}" +
|
---|
| 129 | " TextInput t11 (c) {}" +
|
---|
| 130 | " TextInput t12 (d) {}" +
|
---|
| 131 | " TextInput t13 (e) {}" +
|
---|
| 132 | " }" +
|
---|
| 133 | " }" +
|
---|
| 134 | " TextInput t14 (a) {}" +
|
---|
| 135 | " }" +
|
---|
| 136 | "}";
|
---|
[1171] | 137 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1030] | 138 | // When
|
---|
[1151] | 139 | Optional<UsabilityDefect> recommendation = new TextInputEntryRepetitionsMetric(taskTree).calculate();
|
---|
[1030] | 140 | // Then
|
---|
| 141 | assertThat(recommendation).is(present()).has(mediumRecommendationSeverityLevel());
|
---|
| 142 | }
|
---|
| 143 |
|
---|
| 144 | @Test
|
---|
| 145 | public void should_return_recommendation_with_high_severity_level() {
|
---|
| 146 | // Given
|
---|
[1201] | 147 | String spec = "UserSession {" +
|
---|
| 148 | " Sequence seq1 {" +
|
---|
| 149 | " TextInput t1 (a b c) {}" +
|
---|
| 150 | " Sequence seq2 {" +
|
---|
| 151 | " TextInput t2 (a) {}" +
|
---|
| 152 | " TextInput t3 (b) {}" +
|
---|
| 153 | " TextInput t4 (c) {}" +
|
---|
| 154 | " TextInput t5 (a) {}" +
|
---|
| 155 | " }" +
|
---|
| 156 | " Iteration iter1 {" +
|
---|
| 157 | " TextInput t6 (a) {}" +
|
---|
| 158 | " }" +
|
---|
| 159 | " TextInput t7 (a) {}" +
|
---|
| 160 | " Selection sel1 {" +
|
---|
| 161 | " TextInput t8 (b c) {}" +
|
---|
| 162 | " }" +
|
---|
| 163 | " Selection sel1 {" +
|
---|
| 164 | " TextInput t8 (a) {}" +
|
---|
| 165 | " }" +
|
---|
| 166 | " Selection sel1 {" +
|
---|
| 167 | " TextInput t8 (a c) {}" +
|
---|
| 168 | " }" +
|
---|
| 169 | " Selection sel1 {" +
|
---|
| 170 | " TextInput t8 (b a) {}" +
|
---|
| 171 | " }" +
|
---|
| 172 | " Sequence seq3 {" +
|
---|
| 173 | " TextInput t9 (b c) {}" +
|
---|
| 174 | " Sequence seq4 {" +
|
---|
| 175 | " TextInput t10 (d a c) {}" +
|
---|
| 176 | " TextInput t11 (b b b a) {}" +
|
---|
| 177 | " TextInput t12 (a a c c) {}" +
|
---|
| 178 | " TextInput t13 (b b a) {}" +
|
---|
| 179 | " }" +
|
---|
| 180 | " }" +
|
---|
| 181 | " TextInput t14 (a) {}" +
|
---|
| 182 | " }" +
|
---|
| 183 | "}";
|
---|
[1171] | 184 | ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
|
---|
[1030] | 185 | // When
|
---|
[1151] | 186 | Optional<UsabilityDefect> recommendation = new TextInputEntryRepetitionsMetric(taskTree).calculate();
|
---|
[1030] | 187 | // Then
|
---|
| 188 | assertThat(recommendation).is(present()).has(highRecommendationSeverityLevel());
|
---|
| 189 | }
|
---|
| 190 | }
|
---|