source: trunk/autoquest-plugin-usability2/src/main/java/de/ugoe/cs/autoquest/plugin/usability2/rules/patterns/TestProblem.java @ 1326

Last change on this file since 1326 was 1326, checked in by khartmann, 10 years ago

Moved alexanders code into a new plugin project.
First commit of my experimental code (needs a lot of cleanup).

File size: 3.7 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.plugin.usability2.rules.patterns;
16
17import com.google.common.base.Optional;
18
19import de.ugoe.cs.autoquest.usability.EvaluationMethodCaller;
20import de.ugoe.cs.autoquest.usability.result.UsabilityProblemDescription;
21import de.ugoe.cs.autoquest.usability.result.UsabilityProblemDescriptionResolver;
22import de.ugoe.cs.autoquest.usability.rules.UsabilityRule;
23import de.ugoe.cs.autoquest.usability.rules.UsabilityUsageProblem;
24import de.ugoe.cs.autoquest.plugin.usability2.statistics.Histogramm;
25import de.ugoe.cs.autoquest.plugin.usability2.tools.TaskUtilities;
26import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration;
27import de.ugoe.cs.autoquest.tasktrees.treeifc.IIterationInstance;
28import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask;
29import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance;
30import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel;
31
32/**
33 * <p>
34 * Test Rule to see if new pattern method may be used for problem checking
35 * </p>
36 *
37 * @author Konni Hartmann
38 */
39public class TestProblem extends UsabilityRule implements UsabilityUsageProblem {
40
41    /**
42     * <p>
43     * TODO: comment
44     * </p>
45     *
46     * @param taskTree
47     */
48    public TestProblem(ITaskModel taskModel) {
49        super(taskModel);
50        this.name = "PatternProblem";
51        this.defect = new UsabilityProblemDescriptionResolver().descriptionFor("PatternProblem");
52        initUsagePattern();
53    }
54
55    /**
56     * <p>
57     * TODO: comment
58     * </p>
59     *
60     */
61    private void initUsagePattern() {}
62
63    /*
64     * (non-Javadoc)
65     *
66     * @see de.ugoe.cs.autoquest.usability.rules.UsabilityRule#check()
67     */
68    @Override
69    public Optional<UsabilityProblemDescription> check() {
70        Optional<UsabilityProblemDescription> present = Optional.absent();
71
72        System.out.println("--");
73        System.out.println("TEST-RUN:");
74
75        for (ITask task : TaskUtilities.findRootTasks(taskModel.getTasks())) {
76
77            if (task instanceof IIteration) {
78
79                Histogramm hist = new Histogramm();
80                for (ITaskInstance instance : task.getInstances()) {
81
82                    if (instance instanceof IIterationInstance) {
83                        int cnt = ((IIterationInstance) instance).getChildren().size();
84                        hist.add(cnt);
85                    }
86                }
87
88                int total = hist.count();
89                int rTotal = hist.removeLessThan(1).count(-1);
90                System.out.printf("%s [%d | %d]\n", task.getDescription(), total, rTotal);
91
92            }
93        }
94
95        System.out.println("Finished TEST");
96        return present;
97    }
98
99    /*
100     * (non-Javadoc)
101     *
102     * @see
103     * de.ugoe.cs.autoquest.usability.rules.UsabilityRule#callEvaluationMetho(de.ugoe.cs.autoquest
104     * .usability.EvaluationMethodCaller)
105     */
106    @Override
107    public Optional<UsabilityProblemDescription> callEvaluationMethod(EvaluationMethodCaller evaluationMethodCaller)
108    {
109        return evaluationMethodCaller.check(this);
110    }
111}
Note: See TracBrowser for help on using the repository browser.