source: trunk/autoquest-core-tasktrees-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/nodeequality/SelectionComparisonRuleTest.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: 4.4 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.tasktrees.nodeequality.NodeEquality;
22import de.ugoe.cs.autoquest.tasktrees.nodeequality.NodeEqualityRuleManager;
23import de.ugoe.cs.autoquest.tasktrees.nodeequality.SelectionComparisonRule;
24import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection;
25import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence;
26import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeBuilder;
27import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode;
28import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNodeFactory;
29import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeBuilder;
30import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeNode;
31import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeNodeFactory;
32
33/**
34 * @author Patrick Harms
35 */
36public class SelectionComparisonRuleTest {
37
38    /**
39     *
40     */
41    @Test
42    public void test() {
43        NodeEqualityRuleManager manager = new NodeEqualityRuleManager();
44        manager.init();
45       
46        ITaskTreeNodeFactory treeNodeFactory = new TaskTreeNodeFactory();
47        ITaskTreeBuilder treeBuilder = new TaskTreeBuilder();
48       
49        SelectionComparisonRule rule = new SelectionComparisonRule(manager);
50       
51        ITaskTreeNode task1 = new TaskTreeNode("task1");
52        ITaskTreeNode task2 = new TaskTreeNode("task2");
53       
54        assertNull(rule.compare(task1, task2));
55       
56        ISelection selection1 = treeNodeFactory.createNewSelection();
57        assertEquals(NodeEquality.IDENTICAL, rule.compare(selection1, selection1));
58
59        ISelection selection2 = treeNodeFactory.createNewSelection();
60       
61        assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection1, selection2));
62        assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection2, selection1));
63       
64        treeBuilder.addChild(selection1, task1);
65       
66        assertEquals(NodeEquality.UNEQUAL, rule.compare(selection1, selection2));
67        assertEquals(NodeEquality.UNEQUAL, rule.compare(selection2, selection1));
68       
69        treeBuilder.addChild(selection2, task1);
70       
71        assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection1, selection2));
72        assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection2, selection1));
73       
74        treeBuilder.addChild(selection1, task2);
75       
76        assertEquals(NodeEquality.UNEQUAL, rule.compare(selection1, selection2));
77        assertEquals(NodeEquality.UNEQUAL, rule.compare(selection2, selection1));
78       
79        treeBuilder.addChild(selection2, task2);
80       
81        assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection1, selection2));
82        assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection2, selection1));
83       
84        ISelection selection3 = treeNodeFactory.createNewSelection();
85        treeBuilder.addChild(selection3, task2);
86        treeBuilder.addChild(selection3, task1);
87       
88        assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection1, selection3));
89        assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection3, selection1));
90       
91        assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection2, selection3));
92        assertEquals(NodeEquality.LEXICALLY_EQUAL, rule.compare(selection3, selection2));
93
94        ISequence sequence = treeNodeFactory.createNewSequence();
95        assertNull(rule.compare(selection1, sequence));
96        assertNull(rule.compare(sequence, selection1));
97        assertNull(rule.compare(selection2, sequence));
98        assertNull(rule.compare(sequence, selection2));
99        assertNull(rule.compare(selection3, sequence));
100        assertNull(rule.compare(sequence, selection3));
101    }
102
103}
Note: See TracBrowser for help on using the repository browser.