SolutionModifierHandler implements Handler { public void addGroupBy(Expr expr) { query.addGroupBy(expr); } SolutionModifierHandler(Query query); void addAll(SolutionModifierHandler solutionModifier); void addOrderBy(SortCondition condition); void addOrderBy(Expr expr); void addOrderBy(Expr expr, Order order); void addOrderBy(Var var); void addOrderBy(Var var, Order order); void addGroupBy(Expr expr); void addGroupBy(Var var); void addGroupBy(Var var, Expr expr); void addHaving(String expression); void addHaving(Var var); void addHaving(Expr expr); void setLimit(int limit); void setOffset(int offset); @Override void setVars(Map<Var, Node> values); @Override void build();  }
@Test public void testAddGroupByVar() { solutionModifier.addGroupBy(Var.alloc("groupBy")); String[] s = byLine(query.toString()); assertContainsRegex(GROUP_BY + var("groupBy"), s); solutionModifier.addGroupBy(Var.alloc("groupBy2")); s = byLine(query.toString()); assertContainsRegex(GROUP_BY + var("groupBy") + SPACE + var("groupBy2"), s); }
@Test public void testAddGroupByExpr() { solutionModifier.addGroupBy(new E_Random()); String[] s = byLine(query.toString()); assertContainsRegex(GROUP_BY + "rand" + OPEN_PAREN + CLOSE_PAREN, s); solutionModifier.addGroupBy(Var.alloc("groupBy2")); s = byLine(query.toString()); assertContainsRegex(GROUP_BY + "rand" + OPEN_PAREN + CLOSE_PAREN + SPACE + var("groupBy2"), s); }
@Test public void testAddGroupByVarAndExpr() { solutionModifier.addGroupBy(Var.alloc("groupBy"), new E_Random()); String[] s = byLine(query.toString()); assertContainsRegex(GROUP_BY + OPEN_PAREN + "rand" + OPEN_PAREN + CLOSE_PAREN + SPACE + "AS" + SPACE + var("groupBy") + CLOSE_PAREN, s); solutionModifier.addGroupBy(Var.alloc("groupBy2")); s = byLine(query.toString()); assertContainsRegex(GROUP_BY + OPEN_PAREN + "rand" + OPEN_PAREN + CLOSE_PAREN + SPACE + "AS" + SPACE + var("groupBy") + CLOSE_PAREN + SPACE + var("groupBy2"), s); }