source: trunk/autoquest-core-usability/src/main/java/de/ugoe/cs/autoquest/usability/EventCoverageRatioRule.java

Last change on this file was 1918, checked in by pharms, 9 years ago
  • extension with further smell detections
  • may not fully work. But Hudson is more happy because compile errors should be gone
File size: 2.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;
16
17import java.util.HashMap;
18import java.util.Map;
19
20import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence;
21import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask;
22import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel;
23import de.ugoe.cs.autoquest.tasktrees.treeifc.TaskMetric;
24
25/**
26 * TODO comment
27 *
28 * @version $Revision: $ $Date: 16.07.2012$
29 * @author 2012, last modified by $Author: pharms$
30 */
31public class EventCoverageRatioRule implements UsabilityEvaluationRule {
32
33    /*
34     * (non-Javadoc)
35     *
36     * @see de.ugoe.cs.usability.UsabilityEvaluationRule#evaluate(TaskTree)
37     */
38    @Override
39    public UsabilityEvaluationResult evaluate(ITaskModel taskModel) {
40        UsabilityEvaluationResult results = new UsabilityEvaluationResult(taskModel);
41
42        checkForImportantTasks(results, taskModel);
43
44        return results;
45    }
46
47    /**
48     *
49     */
50    private void checkForImportantTasks(UsabilityEvaluationResult results, ITaskModel taskModel) {
51        for (ITask task : taskModel.getTasks()) {
52            // only sequences are important
53            if (task instanceof ISequence) {
54                ISequence sequence = (ISequence) task;
55                int ratio = taskModel.getTaskInfo(sequence).getMeasureValue
56                    (TaskMetric.EVENT_COVERAGE_RATIO);
57
58                UsabilitySmellIntensity severity =
59                    UsabilitySmellIntensity.getIntensity(ratio, sequence, taskModel);
60
61                if (severity != null) {
62                    Map<String, Object> parameters = new HashMap<String, Object>();
63                    parameters.put("task", sequence);
64                    parameters.put("ratio", (ratio / 10));
65
66                    results.addSmell(sequence, severity,
67                                     UsabilitySmellDescription.HIGH_EVENT_COVERAGE, parameters);
68                }
69            }
70        }
71    }
72}
Note: See TracBrowser for help on using the repository browser.