SolutionModifierHandler implements Handler { public void addHaving(String expression) throws ParseException { String havingClause = "HAVING (" + expression + " )"; SPARQLParser11 parser = new SPARQLParser11(new ByteArrayInputStream( havingClause.getBytes())); parser.setQuery(query); parser.HavingClause(); } 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 testAddHavingString() throws ParseException { solutionModifier.addHaving("?having<10"); assertContainsRegex(HAVING + OPEN_PAREN + var("having") + OPT_SPACE + LT + 10 + CLOSE_PAREN, query.toString()); solutionModifier.addHaving("?having2"); assertContainsRegex( HAVING + OPEN_PAREN + var("having") + OPT_SPACE + LT + 10 + CLOSE_PAREN + OPT_SPACE + var("having2"), query.toString()); }
@Test public void testAddHavingVar() throws ParseException { solutionModifier.addHaving(Var.alloc("foo")); assertContainsRegex(HAVING + var("foo"), query.toString()); solutionModifier.addHaving("?having2"); assertContainsRegex(HAVING + var("foo") + SPACE + var("having2"), query.toString()); }
@Test public void testAddHavingExpr() throws ParseException { solutionModifier.addHaving(new E_Random()); assertContainsRegex(HAVING + "rand" + OPEN_PAREN + CLOSE_PAREN, query.toString()); solutionModifier.addHaving("?having2"); assertContainsRegex(HAVING + "rand" + OPEN_PAREN + CLOSE_PAREN + SPACE + var("having2"), query.toString()); }