use of org.apache.jena.permissions.query.rewriter.SecuredFunction in project jena by apache.
the class OpRewriterTest method testBGP.
@Test
public void testBGP() {
SecurityEvaluator securityEvaluator = new MockSecurityEvaluator(true, true, true, true, true, true);
rewriter = new OpRewriter(securityEvaluator, "http://example.com/dummy");
rewriter.visit(new OpBGP(BasicPattern.wrap(Arrays.asList(triples))));
Op op = rewriter.getResult();
Assert.assertTrue("Should have been an OpFilter", op instanceof OpFilter);
OpFilter filter = (OpFilter) op;
ExprList eLst = filter.getExprs();
Assert.assertEquals(1, eLst.size());
Assert.assertTrue("Should have been a SecuredFunction", eLst.get(0) instanceof SecuredFunction);
op = filter.getSubOp();
Assert.assertTrue("Should have been a OpBGP", op instanceof OpBGP);
BasicPattern basicPattern = ((OpBGP) op).getPattern();
Assert.assertEquals(3, basicPattern.size());
Triple t = basicPattern.get(0);
Assert.assertEquals(NodeFactory.createVariable("foo"), t.getSubject());
Assert.assertEquals(RDF.type.asNode(), t.getPredicate());
Assert.assertEquals(NodeFactory.createURI("http://example.com/class"), t.getObject());
t = basicPattern.get(1);
Assert.assertEquals(NodeFactory.createVariable("foo"), t.getSubject());
Assert.assertTrue("Should have been blank", t.getPredicate().isBlank());
Assert.assertEquals(NodeFactory.createVariable("bar"), t.getObject());
t = basicPattern.get(2);
Assert.assertEquals(NodeFactory.createVariable("bar"), t.getSubject());
Assert.assertTrue("Should have been blank", t.getPredicate().isBlank());
Assert.assertEquals(NodeFactory.createVariable("baz"), t.getObject());
}
Aggregations