[1326] | 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 |
|
---|
| 15 | package de.ugoe.cs.autoquest.plugin.usability2.rules.patterns;
|
---|
| 16 |
|
---|
| 17 | import com.google.common.base.Optional;
|
---|
| 18 |
|
---|
| 19 | import de.ugoe.cs.autoquest.usability.EvaluationMethodCaller;
|
---|
| 20 | import de.ugoe.cs.autoquest.usability.result.UsabilityProblemDescription;
|
---|
| 21 | import de.ugoe.cs.autoquest.usability.result.UsabilityProblemDescriptionResolver;
|
---|
| 22 | import de.ugoe.cs.autoquest.usability.rules.UsabilityRule;
|
---|
| 23 | import de.ugoe.cs.autoquest.usability.rules.UsabilityUsageProblem;
|
---|
| 24 | import de.ugoe.cs.autoquest.plugin.usability2.statistics.Histogramm;
|
---|
| 25 | import de.ugoe.cs.autoquest.plugin.usability2.tools.TaskUtilities;
|
---|
| 26 | import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration;
|
---|
| 27 | import de.ugoe.cs.autoquest.tasktrees.treeifc.IIterationInstance;
|
---|
| 28 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask;
|
---|
| 29 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance;
|
---|
| 30 | import 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 | */
|
---|
| 39 | public 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 | }
|
---|