source: trunk/autoquest-core-usability-evaluation-test/src/main/java/de/ugoe/cs/autoquest/usability/rules/metrics/TextInputRatioEvaluatorTest.java @ 1171

Last change on this file since 1171 was 1171, checked in by adeicke, 11 years ago

Fixed test cases.

  • Property svn:mime-type set to text/plain
File size: 4.5 KB
Line 
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
15package de.ugoe.cs.autoquest.usability.rules.metrics;
16
17import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.absent;
18import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.highRecommendationSeverityLevel;
19import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.infoRecommendationSeverityLevel;
20import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.lowRecommendationSeverityLevel;
21import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.mediumRecommendationSeverityLevel;
22import static de.ugoe.cs.autoquest.usability.testutil.FestConditionUtil.present;
23import static org.fest.assertions.api.Assertions.assertThat;
24
25import org.junit.Test;
26
27import com.google.common.base.Optional;
28
29import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel;
30import de.ugoe.cs.autoquest.usability.result.UsabilityDefect;
31import de.ugoe.cs.autoquest.usability.testutil.GenerateTaskModelUtil;
32
33/**
34 * <p>
35 * TODO comment
36 * </p>
37 *
38 * @author Alexander Deicke
39 */
40public class TextInputRatioEvaluatorTest {
41
42    @Test
43    public void should_return_no_recommendation() {
44        // Given
45        String spec =
46            "Sequence {" + "  Interaction {}" + "  TextInput (a) {}" + "  Interaction {}"
47                + "  Interaction {}" + "  TextInput (c) {}" + "  Interaction {}"
48                + "  Interaction {}" + "  Interaction {}" + "}";
49        ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
50        // When
51        Optional<UsabilityDefect> recommendation = new TextInputRatioMetric(taskTree).calculate();
52        // Then
53        assertThat(recommendation).is(absent());
54    }
55
56    @Test
57    public void should_return_recommendation_with_info_severity_level() {
58        // Given
59        String spec =
60            "Sequence {" + "  Interaction {}" + "  TextInput (a) {}" + "  Interaction {}"
61                + "  Interaction {}" + "  TextInput (c) {}" + "}";
62        ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
63        // When
64        Optional<UsabilityDefect> recommendation = new TextInputRatioMetric(taskTree).calculate();
65        // Then
66        assertThat(recommendation).is(present()).has(infoRecommendationSeverityLevel());
67    }
68
69    @Test
70    public void should_return_recommendation_with_low_severity_level() {
71        // Given
72        String spec =
73            "Sequence {" + "  Interaction {}" + "  TextInput (a) {}" + "  TextInput (b) {}"
74                + "  Interaction {}" + "  TextInput (c) {}" + "}";
75        ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
76        // When
77        Optional<UsabilityDefect> recommendation = new TextInputRatioMetric(taskTree).calculate();
78        // Then
79        assertThat(recommendation).is(present()).has(lowRecommendationSeverityLevel());
80    }
81
82    @Test
83    public void should_return_recommendation_with_medium_severity_level() {
84        // Given
85        String spec =
86            "Sequence {" + "  TextInput (a) {}" + "  TextInput (b) {}" + "  Interaction {}"
87                + "  TextInput (c) {}" + "}";
88        ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
89        // When
90        Optional<UsabilityDefect> recommendation = new TextInputRatioMetric(taskTree).calculate();
91        // Then
92        assertThat(recommendation).is(present()).has(mediumRecommendationSeverityLevel());
93    }
94
95    @Test
96    public void should_return_recommendation_with_high_severity_level() {
97        // Given
98        String spec = "TextInput (bla) {}";
99        ITaskModel taskTree = GenerateTaskModelUtil.getTaskModelFromSpec(spec);
100        // When
101        Optional<UsabilityDefect> recommendation = new TextInputRatioMetric(taskTree).calculate();
102        // Then
103        assertThat(recommendation).is(present()).has(highRecommendationSeverityLevel());
104    }
105}
Note: See TracBrowser for help on using the repository browser.