use of org.apache.jena.sparql.core.Quad in project jena by apache.
the class TestDatasetGraphInMemoryBasic method orderingOfNodesFromFindIsCorrect.
@Test
public void orderingOfNodesFromFindIsCorrect() {
final DatasetGraph dsg = DatasetGraphFactory.createTxnMem();
final Node p = parseNode(":p");
final Triple triple = parseTriple("(:s :p :o)");
dsg.getDefaultGraph().add(triple);
final Iterator<Triple> iter = dsg.getDefaultGraph().find(null, p, null);
assertTrue(some(iter, triple::equals));
final Node p1 = parseNode(":p1");
final Quad quad = parseQuad("(:g1 :s1 :p1 :o1)");
dsg.add(quad);
final Iterator<Quad> iter2 = dsg.find(null, null, p1, null);
assertTrue(some(iter2, quad::equals));
Iter.print(err, iter2);
}
use of org.apache.jena.sparql.core.Quad in project jena by apache.
the class TestHexTable method checkConcreteQueries.
@Test
public void checkConcreteQueries() {
queryPatterns().filter(p -> !allWildcardQuery.equals(p)).map(TestHexTable::exampleFrom).forEach(testQuery -> {
final HexTable index = new HexTable();
index.begin(null);
index.add(testTuple());
final Node node = createBlankNode();
final Quad noiseQuad = Quad.create(node, node, node, node);
index.add(noiseQuad);
index.commit();
index.begin(null);
Set<Quad> contents = index.find(testQuery.getGraph(), testQuery.getSubject(), testQuery.getPredicate(), testQuery.getObject()).collect(toSet());
assertEquals(of(testTuple()), contents);
contents = index.find(null, ANY, null, ANY).collect(toSet());
assertEquals(of(testTuple(), noiseQuad), contents);
index.end();
});
}
use of org.apache.jena.sparql.core.Quad in project jena by apache.
the class AbstractDatasetGraphTests method quad_04.
@Test
public void quad_04() {
DatasetGraph dsg = emptyDataset();
assertNotNull(dsg);
Quad quad1 = SSE.parseQuad("(quad <g> <s> <p> <o1>)");
Quad quad2 = SSE.parseQuad("(quad <g> <s> <p> <o2>)");
dsg.add(quad1);
dsg.add(quad2);
Iterator<Quad> iter = dsg.find(NodeFactory.createURI("g"), NodeFactory.createURI("s"), null, null);
assertTrue(iter.hasNext());
Set<Quad> x = Iter.iter(iter).toSet();
assertEquals(2, x.size());
assertTrue(x.contains(quad1));
assertTrue(x.contains(quad2));
}
use of org.apache.jena.sparql.core.Quad in project jena by apache.
the class AbstractDatasetGraphFindPatterns method find_pattern_s.
@Test
public void find_pattern_s() {
DatasetGraph dsg = create(dataPattern);
List<Quad> quads1 = Iter.toList(dsg.find(null, node(":sx"), null, null));
List<Quad> quads2 = Arrays.asList(q_s, q_gs, q_sp, q_so, q_gsp, q_gso, q_spo, q_gspo);
BaseTest.assertEqualsUnordered("find(s)", quads1, quads2);
}
use of org.apache.jena.sparql.core.Quad in project jena by apache.
the class AbstractDatasetGraphFindPatterns method find_pattern_p.
@Test
public void find_pattern_p() {
DatasetGraph dsg = create(dataPattern);
List<Quad> quads1 = Iter.toList(dsg.find(null, null, node(":px"), null));
List<Quad> quads2 = Arrays.asList(q_p, q_gp, q_sp, q_po, q_gsp, q_gpo, q_spo, q_gspo);
BaseTest.assertEqualsUnordered("find(p)", quads1, quads2);
}
Aggregations