1 |
|
package org.kuali.student.common.messagebuilder.booleanmessage.ast; |
2 |
|
|
3 |
|
import org.antlr.runtime.Token; |
4 |
|
import org.antlr.runtime.tree.CommonTreeAdaptor; |
5 |
|
import org.junit.Assert; |
6 |
|
import org.junit.Test; |
7 |
|
import org.kuali.student.common.messagebuilder.booleanmessage.ast.BooleanNode; |
8 |
|
import org.kuali.student.common.messagebuilder.booleanmessage.ast.parsers.BooleanFunctionParser; |
9 |
|
|
|
|
| 0% |
Uncovered Elements: 22 (22) |
Complexity: 1 |
Complexity Density: 0.05 |
|
10 |
|
public class BooleanNodeTest { |
11 |
|
|
12 |
|
private final static CommonTreeAdaptor adapter = new CommonTreeAdaptor(); |
13 |
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 1 |
Complexity Density: 0.05 |
4
-
|
|
14 |
0
|
@Test... |
15 |
|
public void testBooleanNode() throws Exception { |
16 |
0
|
Token and = adapter.createToken(BooleanFunctionParser.AND, "*"); |
17 |
0
|
Token a = adapter.createToken(BooleanFunctionParser.ALPHA, "A"); |
18 |
0
|
Token b = adapter.createToken(BooleanFunctionParser.ALPHA, "B"); |
19 |
|
|
20 |
|
|
21 |
0
|
BooleanNode andNode = new BooleanNode(and); |
22 |
|
|
23 |
0
|
BooleanNode aNode = new BooleanNode(a); |
24 |
0
|
aNode.setParent(andNode); |
25 |
0
|
aNode.setValue(Boolean.TRUE); |
26 |
0
|
aNode.setLanguage("en"); |
27 |
0
|
aNode.setNodeMessage("MATH101"); |
28 |
|
|
29 |
0
|
BooleanNode bNode = new BooleanNode(b); |
30 |
0
|
bNode.setParent(andNode); |
31 |
0
|
bNode.setValue(Boolean.FALSE); |
32 |
0
|
bNode.setNodeMessage("MATH201"); |
33 |
|
|
34 |
0
|
andNode.addChild(aNode); |
35 |
0
|
andNode.addChild(bNode); |
36 |
|
|
37 |
0
|
Assert.assertEquals("en", aNode.getLanguage()); |
38 |
0
|
Assert.assertEquals("MATH101", aNode.getNodeMessage()); |
39 |
0
|
Assert.assertEquals(Boolean.TRUE, aNode.getValue()); |
40 |
0
|
Assert.assertSame(andNode, aNode.getParent()); |
41 |
0
|
Assert.assertSame(aNode, andNode.getLeftNode()); |
42 |
0
|
Assert.assertSame(bNode, andNode.getRightNode()); |
43 |
|
} |
44 |
|
} |