Search in sources :

Example 1 with DebugExpressionVisitor

use of org.immutables.criteria.expression.DebugExpressionVisitor in project immutables by immutables.

the class NestedTest method assertExpressional.

private static void assertExpressional(Criterion<?> crit, String... expectedLines) {
    final StringWriter out = new StringWriter();
    final Query query = Criterias.toQuery(crit);
    query.filter().ifPresent(f -> f.accept(new DebugExpressionVisitor<>(new PrintWriter(out))));
    final String expected = Arrays.stream(expectedLines).collect(Collectors.joining(System.lineSeparator()));
    Assertions.assertEquals(expected, out.toString().trim());
}
Also used : DebugExpressionVisitor(org.immutables.criteria.expression.DebugExpressionVisitor) StringWriter(java.io.StringWriter) Query(org.immutables.criteria.expression.Query) PrintWriter(java.io.PrintWriter)

Example 2 with DebugExpressionVisitor

use of org.immutables.criteria.expression.DebugExpressionVisitor in project immutables by immutables.

the class ExpressionAsStringTest method assertExpressional.

private static void assertExpressional(Criterion<?> crit, String... expectedLines) {
    final StringBuilder out = new StringBuilder();
    Query query = Criterias.toQuery(crit);
    query.filter().ifPresent(f -> f.accept(new DebugExpressionVisitor<>(out)));
    final String expected = Arrays.stream(expectedLines).collect(Collectors.joining(System.lineSeparator()));
    Assertions.assertEquals(expected, out.toString().trim());
}
Also used : DebugExpressionVisitor(org.immutables.criteria.expression.DebugExpressionVisitor) Query(org.immutables.criteria.expression.Query)

Example 3 with DebugExpressionVisitor

use of org.immutables.criteria.expression.DebugExpressionVisitor in project immutables by immutables.

the class AggregationExpressionTest method assertProjection.

private static void assertProjection(Aggregation<?> aggregation, String... expectedLines) {
    Expression expression = Matchers.toExpression(aggregation);
    String out = expression.accept(new DebugExpressionVisitor<>(new StringBuilder())).toString();
    final String expected = Arrays.stream(expectedLines).collect(Collectors.joining(System.lineSeparator()));
    Assertions.assertEquals(expected, out.trim());
}
Also used : DebugExpressionVisitor(org.immutables.criteria.expression.DebugExpressionVisitor) Expression(org.immutables.criteria.expression.Expression)

Aggregations

DebugExpressionVisitor (org.immutables.criteria.expression.DebugExpressionVisitor)3 Query (org.immutables.criteria.expression.Query)2 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 Expression (org.immutables.criteria.expression.Expression)1