use of org.apache.rya.indexing.entity.update.mongo.MongoEntityIndexer in project incubator-rya by apache.
the class MongoEntityIndexIT method sparqlQuery_Test.
@Test
public void sparqlQuery_Test() throws Exception {
final Sail sail = RyaSailFactory.getInstance(conf);
SailRepositoryConnection conn = new SailRepository(sail).getConnection();
conn.begin();
try (MongoEntityIndexer indexer = new MongoEntityIndexer()) {
indexer.setConf(conf);
indexer.init();
setupTypes(indexer);
addStatements(conn);
final String query = "SELECT * WHERE { " + "<urn:strawberry> <" + RDF.TYPE + "> <urn:icecream> ." + "<urn:strawberry> <urn:brand> ?brand . " + "<urn:strawberry> <urn:flavor> ?flavor . " + "}";
final TupleQueryResult rez = conn.prepareTupleQuery(QueryLanguage.SPARQL, query).evaluate();
final Set<BindingSet> results = new HashSet<>();
while (rez.hasNext()) {
final BindingSet bs = rez.next();
results.add(bs);
}
final MapBindingSet expected = new MapBindingSet();
expected.addBinding("flavor", ValueFactoryImpl.getInstance().createLiteral("Strawberry"));
expected.addBinding("brand", ValueFactoryImpl.getInstance().createLiteral("Awesome Icecream"));
assertEquals(1, results.size());
assertEquals(expected, results.iterator().next());
} finally {
conn.close();
}
}
use of org.apache.rya.indexing.entity.update.mongo.MongoEntityIndexer in project incubator-rya by apache.
the class MongoEntityIndexIT method ensureInEntityStore_Test.
@Test
public void ensureInEntityStore_Test() throws Exception {
final Sail sail = RyaSailFactory.getInstance(conf);
SailRepositoryConnection conn = new SailRepository(sail).getConnection();
conn.begin();
try (MongoEntityIndexer indexer = new MongoEntityIndexer()) {
indexer.setConf(conf);
indexer.init();
setupTypes(indexer);
addStatements(conn);
final EntityStorage entities = indexer.getEntityStorage();
final RyaURI subject = new RyaURI("urn:alice");
final Optional<Entity> alice = entities.get(subject);
assertTrue(alice.isPresent());
} finally {
conn.close();
}
}
use of org.apache.rya.indexing.entity.update.mongo.MongoEntityIndexer in project incubator-rya by apache.
the class MongoEntityIndexIT method partialQuery_Test.
@Test
public void partialQuery_Test() throws Exception {
final Sail sail = RyaSailFactory.getInstance(conf);
SailRepositoryConnection conn = new SailRepository(sail).getConnection();
conn.begin();
try (MongoEntityIndexer indexer = new MongoEntityIndexer()) {
indexer.setConf(conf);
indexer.init();
setupTypes(indexer);
addStatements(conn);
conn.commit();
final String query = "SELECT * WHERE { " + "<urn:george> <" + RDF.TYPE + "> <urn:person> ." + "<urn:george> <urn:name> ?name . " + "<urn:george> <urn:eye> ?eye . " + "}";
final TupleQueryResult rez = conn.prepareTupleQuery(QueryLanguage.SPARQL, query).evaluate();
final Set<BindingSet> results = new HashSet<>();
while (rez.hasNext()) {
final BindingSet bs = rez.next();
System.out.println(bs);
results.add(bs);
}
final ValueFactory vf = ValueFactoryImpl.getInstance();
final MapBindingSet expected = new MapBindingSet();
// expected.addBinding("name", vf.createURI("http://www.w3.org/2001/SMLSchema#string", "George"));
expected.addBinding("name", vf.createLiteral("George"));
expected.addBinding("eye", vf.createLiteral("blue"));
assertEquals(1, results.size());
assertEquals(expected, results.iterator().next());
} finally {
conn.close();
}
}
Aggregations