use of org.openrdf.model.impl.ValueFactoryImpl in project incubator-rya by apache.
the class StatementPatternMatcherTest method doesNotMatchPredicate.
@Test
public void doesNotMatchPredicate() throws Exception {
// Create the matcher against a pattern that matches a specific predicate.
final StatementPatternMatcher matcher = new StatementPatternMatcher(getSp("SELECT * WHERE {" + "?s <urn:talksTo> ?o ." + "}"));
// Create a statement that does not match the pattern.
final ValueFactory vf = new ValueFactoryImpl();
final Statement statement = vf.createStatement(vf.createURI("urn:Charlie"), vf.createURI("urn:knows"), vf.createURI("urn:Bob"), vf.createURI("urn:testGraph"));
// Show the statement did not match.
final Optional<BindingSet> bs = matcher.match(statement);
assertFalse(bs.isPresent());
}
use of org.openrdf.model.impl.ValueFactoryImpl in project incubator-rya by apache.
the class StatementPatternMatcherTest method doesNotMatchContext.
@Test
public void doesNotMatchContext() throws Exception {
// Create a matcher against a pattern that matches a specific context.
final StatementPatternMatcher matcher = new StatementPatternMatcher(getSp("SELECT * WHERE {" + "GRAPH <urn:testGraph> {" + "?s ?p ?o ." + "}" + "}"));
// Create a statement that does not match the pattern.
final ValueFactory vf = new ValueFactoryImpl();
final Statement statement = vf.createStatement(vf.createURI("urn:Alice"), vf.createURI("urn:talksTo"), vf.createURI("urn:Bob"), vf.createURI("urn:wrong"));
// Show the statement did not match.
final Optional<BindingSet> bs = matcher.match(statement);
assertFalse(bs.isPresent());
}
use of org.openrdf.model.impl.ValueFactoryImpl in project incubator-rya by apache.
the class StatementPatternMatcherTest method variableContext.
@Test
public void variableContext() throws Exception {
// Create a matcher against a pattern that matches a variable context.
final StatementPatternMatcher matcher = new StatementPatternMatcher(getSp("SELECT * WHERE {" + "GRAPH ?c {" + "?s ?p ?o ." + "}" + "}"));
// Create a statement that matches the pattern.
final ValueFactory vf = new ValueFactoryImpl();
final Statement statement = vf.createStatement(vf.createURI("urn:Alice"), vf.createURI("urn:talksTo"), vf.createURI("urn:Bob"), vf.createURI("urn:testGraph"));
// Create the expected resulting Binding Set.
final QueryBindingSet expected = new QueryBindingSet();
expected.addBinding("s", vf.createURI("urn:Alice"));
expected.addBinding("p", vf.createURI("urn:talksTo"));
expected.addBinding("o", vf.createURI("urn:Bob"));
expected.addBinding("c", vf.createURI("urn:testGraph"));
// Show the expected Binding Set matches the resulting Binding Set.
final Optional<BindingSet> bs = matcher.match(statement);
assertEquals(expected, bs.get());
}
use of org.openrdf.model.impl.ValueFactoryImpl in project incubator-rya by apache.
the class StatementPatternMatcherTest method variableContext_contextFreeStatement.
@Test
public void variableContext_contextFreeStatement() throws Exception {
// Create a matcher against a pattern that matches a variable context.
final StatementPatternMatcher matcher = new StatementPatternMatcher(getSp("SELECT * WHERE {" + "GRAPH ?c {" + "?s ?p ?o ." + "}" + "}"));
// Create a statement that does not have a context value.
final ValueFactory vf = new ValueFactoryImpl();
final Statement statement = vf.createStatement(vf.createURI("urn:Alice"), vf.createURI("urn:talksTo"), vf.createURI("urn:Bob"));
// Show the statement did not match.
final Optional<BindingSet> bs = matcher.match(statement);
assertFalse(bs.isPresent());
}
use of org.openrdf.model.impl.ValueFactoryImpl in project incubator-rya by apache.
the class StatementPatternMatcherTest method doesNotMatchObject.
@Test
public void doesNotMatchObject() throws Exception {
// Create the matcher against a pattern that matches a specific object.
final StatementPatternMatcher matcher = new StatementPatternMatcher(getSp("SELECT * WHERE {" + "?s ?p <urn:Bob> ." + "}"));
// Create a statement that does not match the pattern.
final ValueFactory vf = new ValueFactoryImpl();
final Statement statement = vf.createStatement(vf.createURI("urn:Charlie"), vf.createURI("urn:knows"), vf.createURI("urn:Alice"), vf.createURI("urn:testGraph"));
// Show the statement did not match.
final Optional<BindingSet> bs = matcher.match(statement);
assertFalse(bs.isPresent());
}
Aggregations