コード例 #1
0
  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());
  }
コード例 #2
0
  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
    }
  }
コード例 #3
0
  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());
  }
コード例 #4
0
 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;
 }
コード例 #5
0
 public void testEqualsNode() throws Exception {
   assertTrue(sumNode.equalsNode(sumNode));
   assertFalse(sumNode.equalsNode(new ExprOrNode()));
 }