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.tasktrees.taskequality; |
---|
16 | |
---|
17 | import static org.junit.Assert.*; |
---|
18 | |
---|
19 | import org.junit.Test; |
---|
20 | |
---|
21 | import de.ugoe.cs.autoquest.eventcore.IEventTarget; |
---|
22 | import de.ugoe.cs.autoquest.eventcore.IEventType; |
---|
23 | import de.ugoe.cs.autoquest.eventcore.StringEventType; |
---|
24 | import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskAndSelectionComparisonRule; |
---|
25 | import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality; |
---|
26 | import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEqualityRuleManager; |
---|
27 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; |
---|
28 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; |
---|
29 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; |
---|
30 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory; |
---|
31 | import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskBuilder; |
---|
32 | import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskFactory; |
---|
33 | import de.ugoe.cs.autoquest.test.DummyGUIElement; |
---|
34 | |
---|
35 | /** |
---|
36 | * @author Patrick Harms |
---|
37 | */ |
---|
38 | public class TaskAndSelectionComparisonRuleTest { |
---|
39 | |
---|
40 | /** |
---|
41 | * |
---|
42 | */ |
---|
43 | @Test |
---|
44 | public void test() { |
---|
45 | TaskEqualityRuleManager manager = new TaskEqualityRuleManager(); |
---|
46 | manager.init(); |
---|
47 | |
---|
48 | ITaskFactory taskFactory = new TaskFactory(); |
---|
49 | ITaskBuilder treeBuilder = new TaskBuilder(); |
---|
50 | |
---|
51 | TaskAndSelectionComparisonRule rule = new TaskAndSelectionComparisonRule(manager); |
---|
52 | |
---|
53 | IEventType eventType1 = new StringEventType("eventType1"); |
---|
54 | IEventTarget eventTarget1 = new DummyGUIElement("elem1"); |
---|
55 | ITask task1 = taskFactory.createNewEventTask(eventType1, eventTarget1); |
---|
56 | |
---|
57 | assertNull(rule.compare(task1, task1)); |
---|
58 | |
---|
59 | ISelection selection1 = taskFactory.createNewSelection(); |
---|
60 | assertNull(rule.compare(selection1, selection1)); |
---|
61 | assertNull(rule.compare(task1, selection1)); |
---|
62 | assertNull(rule.compare(selection1, task1)); |
---|
63 | |
---|
64 | treeBuilder.addChild(selection1, task1); |
---|
65 | |
---|
66 | assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(selection1, task1)); |
---|
67 | assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(task1, selection1)); |
---|
68 | |
---|
69 | selection1 = taskFactory.createNewSelection(); |
---|
70 | ISelection selection2 = taskFactory.createNewSelection(); |
---|
71 | treeBuilder.addChild(selection2, task1); |
---|
72 | treeBuilder.addChild(selection1, selection2); |
---|
73 | |
---|
74 | assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(selection1, task1)); |
---|
75 | assertEquals(TaskEquality.LEXICALLY_EQUAL, rule.compare(task1, selection1)); |
---|
76 | } |
---|
77 | |
---|
78 | } |
---|