SolutionModifierHandler implements Handler { public void addAll(SolutionModifierHandler solutionModifier) { List<SortCondition> lst = solutionModifier.query.getOrderBy(); if (lst != null) { for (SortCondition sc : lst) { query.addOrderBy(sc); } } query.getGroupBy().addAll(solutionModifier.query.getGroupBy()); query.getHavingExprs().addAll(solutionModifier.query.getHavingExprs()); query.setLimit(solutionModifier.query.getLimit()); query.setOffset(solutionModifier.query.getOffset()); } 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 testAddAll() throws ParseException { SolutionModifierHandler solutionModifier2 = new SolutionModifierHandler(new Query()); solutionModifier2.addOrderBy(Var.alloc("orderBy")); solutionModifier2.addGroupBy(Var.alloc("groupBy")); solutionModifier2.addHaving("?having<10"); solutionModifier2.setLimit(500); solutionModifier2.setOffset(200); solutionModifier.addAll(solutionModifier2); String[] s = byLine(query.toString()); assertContainsRegex(GROUP_BY + var("groupBy"), s); assertContainsRegex(HAVING + OPEN_PAREN + var("having") + OPT_SPACE + LT + OPT_SPACE + "10" + CLOSE_PAREN, s); assertContainsRegex(ORDER_BY + var("orderBy"), s); assertContainsRegex(LIMIT + "500", s); assertContainsRegex(OFFSET + "200", s); }