1 |
|
package org.kuali.student.common.messagebuilder.booleanmessage.ast; |
2 |
|
|
3 |
|
import java.util.HashMap; |
4 |
|
import java.util.List; |
5 |
|
import java.util.Map; |
6 |
|
|
7 |
|
import org.junit.Assert; |
8 |
|
import org.junit.Before; |
9 |
|
import org.junit.Test; |
10 |
|
import org.kuali.student.common.messagebuilder.booleanmessage.BooleanMessage; |
11 |
|
import org.kuali.student.common.messagebuilder.booleanmessage.ast.BinaryMessageTree; |
12 |
|
import org.kuali.student.common.messagebuilder.booleanmessage.ast.BooleanMessageImpl; |
13 |
|
import org.kuali.student.common.messagebuilder.booleanmessage.ast.BooleanNode; |
14 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (27) |
Complexity: 5 |
Complexity Density: 0.23 |
|
15 |
|
public class BinaryMessageTreeTest { |
16 |
|
private Map<String,BooleanMessage> messageMap; |
17 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
18 |
4
|
@Before... |
19 |
|
public void setUp() throws Exception { |
20 |
4
|
messageMap = new HashMap<String, BooleanMessage>(); |
21 |
4
|
messageMap.put("A", new BooleanMessageImpl("A", true, "A is true")); |
22 |
4
|
messageMap.put("B", new BooleanMessageImpl("B", true, "B is true")); |
23 |
|
} |
24 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1
PASS
|
|
25 |
1
|
@Test... |
26 |
|
public void testGetRoot() throws Exception { |
27 |
1
|
BinaryMessageTree btree = new BinaryMessageTree("en", messageMap); |
28 |
1
|
BooleanNode rootNode = btree.buildTree("A*B"); |
29 |
|
|
30 |
1
|
Assert.assertSame(rootNode, btree.getRoot()); |
31 |
|
} |
32 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1
PASS
|
|
33 |
1
|
@Test... |
34 |
|
public void testBuildTree() throws Exception { |
35 |
1
|
BinaryMessageTree btree = new BinaryMessageTree("en", messageMap); |
36 |
1
|
BooleanNode rootNode = btree.buildTree("A*B"); |
37 |
|
|
38 |
1
|
Assert.assertEquals(2, rootNode.getChildren().size()); |
39 |
1
|
Assert.assertEquals("*", rootNode.getLabel()); |
40 |
1
|
Assert.assertEquals("A", rootNode.getLeftNode().getLabel()); |
41 |
1
|
Assert.assertEquals("B", rootNode.getRightNode().getLabel()); |
42 |
|
} |
43 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1
PASS
|
|
44 |
1
|
@Test... |
45 |
|
public void testTraverseTreePostOrder_GetAllNodes() throws Exception { |
46 |
1
|
BinaryMessageTree btree = new BinaryMessageTree("en", messageMap); |
47 |
1
|
BooleanNode rootNode = btree.buildTree("A*B"); |
48 |
1
|
btree.traverseTreePostOrder(rootNode, null); |
49 |
1
|
List<BooleanNode> nodeList = btree.getAllNodes(); |
50 |
|
|
51 |
1
|
Assert.assertEquals(3, nodeList.size()); |
52 |
|
} |
53 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1
PASS
|
|
54 |
1
|
@Test... |
55 |
|
public void testTraverseTreePostOrderDontSetNode_GetAllNodes2() throws Exception { |
56 |
1
|
BinaryMessageTree btree = new BinaryMessageTree(); |
57 |
1
|
BooleanNode rootNode = btree.buildTree("A*B"); |
58 |
1
|
btree.traverseTreePostOrderDontSetNode(rootNode, null); |
59 |
1
|
List<BooleanNode> nodeList = btree.getAllNodes(); |
60 |
|
|
61 |
1
|
Assert.assertEquals(3, nodeList.size()); |
62 |
|
} |
63 |
|
} |