use of org.apache.rya.api.function.projection.RandomUUIDFactory in project incubator-rya by apache.
the class TemporalFilterIT method showEqualsWorks.
@Test
public void showEqualsWorks() throws Exception {
// Enumerate some topics that will be re-used
final String ryaInstance = UUID.randomUUID().toString();
final UUID queryId = UUID.randomUUID();
final String statementsTopic = KafkaTopics.statementsTopic(ryaInstance);
final String resultsTopic = KafkaTopics.queryResultsTopic(ryaInstance, queryId);
// Get the RDF model objects that will be used to build the query.
final String sparql = "PREFIX time: <http://www.w3.org/2006/time/> \n" + "PREFIX tempf: <" + TemporalURIs.NAMESPACE + ">\n" + "SELECT * \n" + "WHERE { \n" + " <urn:time> time:atTime ?date .\n" + " FILTER(tempf:equals(?date, \"" + TIME.toString() + "\")) " + "}";
// Setup a topology.
final TopologyBuilder builder = new TopologyFactory().build(sparql, statementsTopic, resultsTopic, new RandomUUIDFactory());
// Create the statements that will be input into the query.
final ValueFactory vf = new ValueFactoryImpl();
final List<VisibilityStatement> statements = getStatements();
// Make the expected results.
final Set<VisibilityBindingSet> expected = new HashSet<>();
final MapBindingSet bs = new MapBindingSet();
bs.addBinding("date", vf.createLiteral(TIME.toString()));
expected.add(new VisibilityBindingSet(bs, "a"));
// Run the test.
RyaStreamsTestUtil.runStreamProcessingTest(kafka, statementsTopic, resultsTopic, builder, statements, expected, VisibilityBindingSetDeserializer.class);
}
use of org.apache.rya.api.function.projection.RandomUUIDFactory in project incubator-rya by apache.
the class StatementPatternProcessorIT method multiplePatterns_multipleStatements.
@Test
public void multiplePatterns_multipleStatements() throws Exception {
// Enumerate some topics that will be re-used
final String ryaInstance = UUID.randomUUID().toString();
final UUID queryId = UUID.randomUUID();
final String statementsTopic = KafkaTopics.statementsTopic(ryaInstance);
final String resultsTopic = KafkaTopics.queryResultsTopic(ryaInstance, queryId);
// Setup a topology.
final String query = "SELECT * WHERE { " + "?person <urn:talksTo> ?otherPerson ." + "?person ?action <urn:Bob>" + "}";
final TopologyFactory factory = new TopologyFactory();
final TopologyBuilder builder = factory.build(query, statementsTopic, resultsTopic, new RandomUUIDFactory());
// Create some statements where some generates SP results and others do not.
final ValueFactory vf = new ValueFactoryImpl();
final List<VisibilityStatement> statements = new ArrayList<>();
statements.add(new VisibilityStatement(vf.createStatement(vf.createURI("urn:Alice"), vf.createURI("urn:talksTo"), vf.createURI("urn:Bob")), "a"));
statements.add(new VisibilityStatement(vf.createStatement(vf.createURI("urn:Alice"), vf.createURI("urn:talksTo"), vf.createURI("urn:Charlie")), "a|b"));
statements.add(new VisibilityStatement(vf.createStatement(vf.createURI("urn:Charlie"), vf.createURI("urn:walksWith"), vf.createURI("urn:Bob")), "b"));
// Show the correct binding set results from the job.
final Set<VisibilityBindingSet> expected = new HashSet<>();
QueryBindingSet bs = new QueryBindingSet();
bs = new QueryBindingSet();
bs.addBinding("person", vf.createURI("urn:Alice"));
bs.addBinding("action", vf.createURI("urn:talksTo"));
bs.addBinding("otherPerson", vf.createURI("urn:Charlie"));
expected.add(new VisibilityBindingSet(bs, "a&(a|b)"));
bs = new QueryBindingSet();
bs.addBinding("person", vf.createURI("urn:Alice"));
bs.addBinding("action", vf.createURI("urn:talksTo"));
bs.addBinding("otherPerson", vf.createURI("urn:Bob"));
expected.add(new VisibilityBindingSet(bs, "a"));
// Run the test.
RyaStreamsTestUtil.runStreamProcessingTest(kafka, statementsTopic, resultsTopic, builder, statements, expected, VisibilityBindingSetDeserializer.class);
}
use of org.apache.rya.api.function.projection.RandomUUIDFactory in project incubator-rya by apache.
the class StatementPatternProcessorIT method singlePattern_singleStatement.
@Test
public void singlePattern_singleStatement() throws Exception {
// Enumerate some topics that will be re-used
final String ryaInstance = UUID.randomUUID().toString();
final UUID queryId = UUID.randomUUID();
final String statementsTopic = KafkaTopics.statementsTopic(ryaInstance);
final String resultsTopic = KafkaTopics.queryResultsTopic(ryaInstance, queryId);
// Setup a topology.
final String query = "SELECT * WHERE { ?person <urn:talksTo> ?otherPerson }";
final TopologyFactory factory = new TopologyFactory();
final TopologyBuilder builder = factory.build(query, statementsTopic, resultsTopic, new RandomUUIDFactory());
// Create a statement that generate an SP result.
final ValueFactory vf = new ValueFactoryImpl();
final List<VisibilityStatement> statements = new ArrayList<>();
statements.add(new VisibilityStatement(vf.createStatement(vf.createURI("urn:Alice"), vf.createURI("urn:talksTo"), vf.createURI("urn:Bob")), "a"));
// Show the correct binding set results from the job.
final Set<VisibilityBindingSet> expected = new HashSet<>();
final QueryBindingSet bs = new QueryBindingSet();
bs.addBinding("person", vf.createURI("urn:Alice"));
bs.addBinding("otherPerson", vf.createURI("urn:Bob"));
expected.add(new VisibilityBindingSet(bs, "a"));
// Run the test.
RyaStreamsTestUtil.runStreamProcessingTest(kafka, statementsTopic, resultsTopic, builder, statements, expected, VisibilityBindingSetDeserializer.class);
}
use of org.apache.rya.api.function.projection.RandomUUIDFactory in project incubator-rya by apache.
the class StatementPatternProcessorIT method multiplePatterns_singleStatement.
@Test
public void multiplePatterns_singleStatement() throws Exception {
// Enumerate some topics that will be re-used
final String ryaInstance = UUID.randomUUID().toString();
final UUID queryId = UUID.randomUUID();
final String statementsTopic = KafkaTopics.statementsTopic(ryaInstance);
final String resultsTopic = KafkaTopics.queryResultsTopic(ryaInstance, queryId);
// Setup a topology.
final String query = "SELECT * WHERE { " + "?person <urn:talksTo> ?otherPerson . " + "?person ?action <urn:Bob>" + "}";
final TopologyFactory factory = new TopologyFactory();
final TopologyBuilder builder = factory.build(query, statementsTopic, resultsTopic, new RandomUUIDFactory());
// Create some statements where some generates SP results and others do not.
final ValueFactory vf = new ValueFactoryImpl();
final List<VisibilityStatement> statements = new ArrayList<>();
statements.add(new VisibilityStatement(vf.createStatement(vf.createURI("urn:Alice"), vf.createURI("urn:talksTo"), vf.createURI("urn:Bob")), "a"));
// Show the correct binding set results from the job.
final Set<VisibilityBindingSet> expected = new HashSet<>();
final QueryBindingSet bs = new QueryBindingSet();
bs.addBinding("person", vf.createURI("urn:Alice"));
bs.addBinding("action", vf.createURI("urn:talksTo"));
bs.addBinding("otherPerson", vf.createURI("urn:Bob"));
expected.add(new VisibilityBindingSet(bs, "a"));
// Run the test.
RyaStreamsTestUtil.runStreamProcessingTest(kafka, statementsTopic, resultsTopic, builder, statements, expected, VisibilityBindingSetDeserializer.class);
}
Aggregations