Query q = QueryParser.getInstance().parse(queryStrBuf.toString());
Assert.assertTrue(SelectQuery.class.isAssignableFrom(q.getClass()));
SelectQuery selectQuery = (SelectQuery) q;
Assert.assertTrue(selectQuery.getSelection().size() == 2);
Set<Variable> vars = new HashSet<Variable>(2);
Variable var1 = new Variable(variable1);
Variable var2 = new Variable(variable2);
vars.add(var1);
vars.add(var2);
Assert.assertTrue(selectQuery.getSelection().containsAll(vars));
GroupGraphPattern ggp = selectQuery.getQueryPattern();
List<Expression> constraints = ggp.getFilter();
Assert.assertTrue(UnaryOperation.class.isAssignableFrom(constraints
.get(0).getClass()));
UnaryOperation uop = (UnaryOperation) constraints.get(0);
Assert.assertTrue(uop.getOperatorString().equals("!"));
Assert.assertTrue(BuiltInCall.class.isAssignableFrom(uop.getOperand()
.getClass()));
BuiltInCall bic = (BuiltInCall) uop.getOperand();
Assert.assertTrue(bic.getName().equals("BOUND"));
Variable var3 = new Variable(variable3);
Assert.assertTrue(bic.getArguements().get(0).equals(var3));
GraphPattern gp = (GraphPattern) ggp.getGraphPatterns().toArray()[0];
Assert.assertTrue(OptionalGraphPattern.class.isAssignableFrom(gp.getClass()));
OptionalGraphPattern ogp = (OptionalGraphPattern) gp;