source: trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/nodeequality/EventTaskComparisonRuleTest.java @ 927

Last change on this file since 927 was 927, checked in by sherbold, 12 years ago
  • added copyright under the Apache License, Version 2.0
File size: 3.3 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.tasktrees.nodeequality;
16
17import static org.junit.Assert.*;
18
19import org.junit.Test;
20
21import de.ugoe.cs.autoquest.eventcore.IEventTarget;
22import de.ugoe.cs.autoquest.eventcore.IEventType;
23import de.ugoe.cs.autoquest.eventcore.StringEventType;
24import de.ugoe.cs.autoquest.tasktrees.nodeequality.EventTaskComparisonRule;
25import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeEquality;
26import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection;
27import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode;
28import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNodeFactory;
29import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeNodeFactory;
30import de.ugoe.cs.autoquest.test.DummyGUIElement;
31
32/**
33 * @author Patrick Harms
34 */
35public class EventTaskComparisonRuleTest {
36
37    /**
38     *
39     */
40    @Test
41    public void test() {
42        ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory();
43       
44        EventTaskComparisonRule rule = new EventTaskComparisonRule();
45       
46        // test the identity check
47        IEventType eventType1 = new StringEventType("eventType1");
48        IEventTarget eventTarget1 = new DummyGUIElement("elem1");
49        ITaskTreeNode task1 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1);
50       
51        assertEquals(NodeEquality.IDENTICAL, rule.compare(task1, task1));
52
53        ITaskTreeNode task2 = treeNodeFactory.createNewEventTask(eventType1, eventTarget1);
54       
55        assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(task1, task2));
56        assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(task2, task1));
57       
58        IEventType eventType2 = new StringEventType("eventType2");
59        task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget1);
60
61        assertEquals(NodeEquality.UNEQUAL, rule.compare(task1, task2));
62        assertEquals(NodeEquality.UNEQUAL, rule.compare(task2, task1));
63       
64        IEventTarget eventTarget2 = new DummyGUIElement("elem2");
65        task2 = treeNodeFactory.createNewEventTask(eventType1, eventTarget2);
66       
67        assertEquals(NodeEquality.UNEQUAL, rule.compare(task1, task2));
68        assertEquals(NodeEquality.UNEQUAL, rule.compare(task2, task1));
69       
70        task2 = treeNodeFactory.createNewEventTask(eventType2, eventTarget2);
71       
72        assertEquals(NodeEquality.UNEQUAL, rule.compare(task1, task2));
73        assertEquals(NodeEquality.UNEQUAL, rule.compare(task2, task1));
74
75        ISelection selection = treeNodeFactory.createNewSelection();
76        assertNull(rule.compare(task1, selection));
77        assertNull(rule.compare(selection, task1));
78        assertNull(rule.compare(task2, selection));
79        assertNull(rule.compare(selection, task2));
80    }
81
82}
Note: See TracBrowser for help on using the repository browser.