Search in sources :

Example 81 with ExpressionEvaluator

use of org.seasar.doma.internal.expr.ExpressionEvaluator in project doma by domaframework.

the class MethodOperatorNodeTest method testOneParameter.

@Test
public void testOneParameter() {
    MethodOperatorNode node = new MethodOperatorNode(location, ".equals", "equals");
    node.setTargetObjectNode(new VariableNode(location, "hoge"));
    CommaOperatorNode commaOperatorNode = new CommaOperatorNode(location, ",");
    commaOperatorNode.addNode(new LiteralNode(location, "\"aaa\"", "aaa", String.class));
    node.setParametersNode(commaOperatorNode);
    ExpressionEvaluator evaluator = new ExpressionEvaluator();
    evaluator.add("hoge", new Value(String.class, "aaa"));
    EvaluationResult evaluationResult = evaluator.evaluate(node);
    assertTrue(evaluationResult.getBooleanValue());
}
Also used : Value(org.seasar.doma.internal.expr.Value) ExpressionEvaluator(org.seasar.doma.internal.expr.ExpressionEvaluator) EvaluationResult(org.seasar.doma.internal.expr.EvaluationResult) Test(org.junit.jupiter.api.Test)

Example 82 with ExpressionEvaluator

use of org.seasar.doma.internal.expr.ExpressionEvaluator in project doma by domaframework.

the class NotOperatorNodeTest method test_null.

@Test
public void test_null() {
    NotOperatorNode node = new NotOperatorNode(location, "!");
    node.setNode(nullLiteral);
    ExpressionEvaluator evaluator = new ExpressionEvaluator();
    EvaluationResult evaluationResult = evaluator.evaluate(node);
    assertTrue(evaluationResult.getBooleanValue());
}
Also used : ExpressionEvaluator(org.seasar.doma.internal.expr.ExpressionEvaluator) EvaluationResult(org.seasar.doma.internal.expr.EvaluationResult) Test(org.junit.jupiter.api.Test)

Example 83 with ExpressionEvaluator

use of org.seasar.doma.internal.expr.ExpressionEvaluator in project doma by domaframework.

the class NotOperatorNodeTest method test_true.

@Test
public void test_true() {
    NotOperatorNode node = new NotOperatorNode(location, "!");
    node.setNode(trueLiteral);
    ExpressionEvaluator evaluator = new ExpressionEvaluator();
    EvaluationResult evaluationResult = evaluator.evaluate(node);
    assertFalse(evaluationResult.getBooleanValue());
}
Also used : ExpressionEvaluator(org.seasar.doma.internal.expr.ExpressionEvaluator) EvaluationResult(org.seasar.doma.internal.expr.EvaluationResult) Test(org.junit.jupiter.api.Test)

Aggregations

ExpressionEvaluator (org.seasar.doma.internal.expr.ExpressionEvaluator)83 Test (org.junit.jupiter.api.Test)77 Value (org.seasar.doma.internal.expr.Value)52 PreparedSql (org.seasar.doma.jdbc.PreparedSql)51 SqlNode (org.seasar.doma.jdbc.SqlNode)48 EvaluationResult (org.seasar.doma.internal.expr.EvaluationResult)18 BigDecimal (java.math.BigDecimal)14 List (java.util.List)14 ArrayList (java.util.ArrayList)12 JdbcException (org.seasar.doma.jdbc.JdbcException)10 NodePreparedSqlBuilder (org.seasar.doma.internal.jdbc.sql.NodePreparedSqlBuilder)8 AnonymousNode (org.seasar.doma.internal.jdbc.sql.node.AnonymousNode)6 FromClauseNode (org.seasar.doma.internal.jdbc.sql.node.FromClauseNode)6 SelectClauseNode (org.seasar.doma.internal.jdbc.sql.node.SelectClauseNode)6 SelectStatementNode (org.seasar.doma.internal.jdbc.sql.node.SelectStatementNode)6 WhereClauseNode (org.seasar.doma.internal.jdbc.sql.node.WhereClauseNode)6 WordNode (org.seasar.doma.internal.jdbc.sql.node.WordNode)6 EndNode (org.seasar.doma.internal.jdbc.sql.node.EndNode)5 IfBlockNode (org.seasar.doma.internal.jdbc.sql.node.IfBlockNode)5 IfNode (org.seasar.doma.internal.jdbc.sql.node.IfNode)5