1 | package de.uka.ipd.sdq.tcfmoop.tests; |
2 | |
3 | import static org.junit.Assert.*; |
4 | |
5 | import org.junit.Before; |
6 | import org.junit.Test; |
7 | |
8 | import de.uka.ipd.sdq.tcfmoop.outputtree.Node; |
9 | import de.uka.ipd.sdq.tcfmoop.outputtree.Tree; |
10 | import de.uka.ipd.sdq.tcfmoop.outputtree.Node.NodeType; |
11 | |
12 | /** |
13 | * @author Atanas Dimitrov |
14 | * |
15 | */ |
16 | public class OutputTests { |
17 | Tree outputTree; |
18 | |
19 | /** |
20 | * @throws java.lang.Exception |
21 | */ |
22 | @Before |
23 | public void setUp() throws Exception { |
24 | outputTree = new Tree("Root", NodeType.NON_SPECIFIC); |
25 | } |
26 | |
27 | |
28 | @Test |
29 | public void testParentAndChildren() { |
30 | assertFalse(outputTree.hasChildren()); |
31 | |
32 | assertNull(outputTree.getParent()); |
33 | |
34 | Node child1 = outputTree.addChild("Child 1", NodeType.NON_SPECIFIC); |
35 | |
36 | assertNotNull(child1); |
37 | |
38 | assertTrue(outputTree.hasChildren()); |
39 | |
40 | assertTrue(outputTree.getChildren().size() == 1); |
41 | |
42 | assertTrue(child1.getParent() == outputTree); |
43 | |
44 | outputTree.clearChildren(); |
45 | |
46 | assertFalse(outputTree.hasChildren()); |
47 | } |
48 | |
49 | @Test |
50 | public void testUpdateValue() { |
51 | |
52 | assertTrue(outputTree.getValue().equals("Root")); |
53 | |
54 | outputTree.updateValue("UpdatedRoot"); |
55 | |
56 | assertTrue(outputTree.getValue().equals("UpdatedRoot")); |
57 | |
58 | } |
59 | |
60 | @Test |
61 | public void testIsRoot() { |
62 | |
63 | assertTrue(outputTree.isRoot()); |
64 | |
65 | Node child1 = outputTree.addChild("Child 1", NodeType.NON_SPECIFIC); |
66 | |
67 | assertFalse(child1.isRoot()); |
68 | |
69 | } |
70 | |
71 | } |