public void testGetType() throws Exception { sumNode.addChildNode(new SupportExprNode(Integer.class)); SupportExprNodeFactory.validate3Stream(sumNode); assertEquals(Integer.class, sumNode.getType()); sumNode = new ExprSumNode(false, false); sumNode.addChildNode(new SupportExprNode(Float.class)); SupportExprNodeFactory.validate3Stream(sumNode); assertEquals(Float.class, sumNode.getType()); sumNode = new ExprSumNode(false, false); sumNode.addChildNode(new SupportExprNode(Short.class)); SupportExprNodeFactory.validate3Stream(sumNode); assertEquals(Integer.class, sumNode.getType()); }
public void testValidate() { // Must have exactly 1 subnodes try { sumNode.validate(ExprValidationContextFactory.makeEmpty()); fail(); } catch (ExprValidationException ex) { // Expected } // Must have only number-type subnodes sumNode.addChildNode(new SupportExprNode(String.class)); sumNode.addChildNode(new SupportExprNode(Integer.class)); try { sumNode.validate(ExprValidationContextFactory.makeEmpty()); fail(); } catch (ExprValidationException ex) { // Expected } }
public void testToExpressionString() throws Exception { // Build sum(4-2) ExprMathNode arithNodeChild = new ExprMathNode(MathArithTypeEnum.SUBTRACT, false, false); arithNodeChild.addChildNode(new SupportExprNode(4)); arithNodeChild.addChildNode(new SupportExprNode(2)); sumNode = new ExprSumNode(false, false); sumNode.addChildNode(arithNodeChild); assertEquals("sum((4-2))", sumNode.toExpressionString()); }
private ExprSumNode makeNode(Object value, Class type) throws Exception { ExprSumNode sumNode = new ExprSumNode(false, false); sumNode.addChildNode(new SupportExprNode(value, type)); SupportExprNodeFactory.validate3Stream(sumNode); return sumNode; }