Java Code Examples for org.eclipse.rdf4j.query.algebra.Projection#visit()
The following examples show how to use
org.eclipse.rdf4j.query.algebra.Projection#visit() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReflexivePropertyVisitorTest.java From rya with Apache License 2.0 | 6 votes |
@Test public void testReflexiveProperty() throws Exception { // Define a reflexive property final InferenceEngine inferenceEngine = mock(InferenceEngine.class); when(inferenceEngine.isReflexiveProperty(HAS_FAMILY)).thenReturn(true); // Construct a query, then visit it final StatementPattern sp = new StatementPattern(new Var("s", ALICE), new Var("p", HAS_FAMILY), new Var("o")); final Projection query = new Projection(sp, new ProjectionElemList(new ProjectionElem("o", "member"))); query.visit(new ReflexivePropertyVisitor(conf, inferenceEngine)); // Expected structure after rewriting SP(:Alice :hasFamilyMember ?member): // // Union( // originalSP(:Alice :hasFamilyMember ?member), // ZeroLengthPath(:Alice, ?member) // ) Assert.assertTrue(query.getArg() instanceof Union); final TupleExpr left = ((Union) query.getArg()).getLeftArg(); final TupleExpr right = ((Union) query.getArg()).getRightArg(); Assert.assertEquals(sp, left); Assert.assertTrue(right instanceof ZeroLengthPath); Assert.assertEquals(sp.getSubjectVar(), ((ZeroLengthPath) right).getSubjectVar()); Assert.assertEquals(sp.getObjectVar(), ((ZeroLengthPath) right).getObjectVar()); }
Example 2
Source File: ReflexivePropertyVisitorTest.java From rya with Apache License 2.0 | 6 votes |
@Test public void testReflexivePropertyDisabled() throws Exception { // Disable inference final RdfCloudTripleStoreConfiguration disabledConf = conf.clone(); disabledConf.setInferReflexiveProperty(false); // Define a reflexive property final InferenceEngine inferenceEngine = mock(InferenceEngine.class); when(inferenceEngine.isReflexiveProperty(HAS_FAMILY)).thenReturn(true); // Construct a query, then make a copy and visit the copy final Projection query = new Projection( new StatementPattern(new Var("s", ALICE), new Var("p", HAS_FAMILY), new Var("o")), new ProjectionElemList(new ProjectionElem("s", "subject"))); final Projection modifiedQuery = query.clone(); modifiedQuery.visit(new ReflexivePropertyVisitor(disabledConf, inferenceEngine)); // There should be no difference Assert.assertEquals(query, modifiedQuery); }
Example 3
Source File: SomeValuesFromVisitorTest.java From rya with Apache License 2.0 | 6 votes |
@Test public void testSomeValuesFromDisabled() throws Exception { // Disable someValuesOf inference final AccumuloRdfConfiguration disabledConf = conf.clone(); disabledConf.setInferSomeValuesFrom(false); // Configure a mock instance engine with an ontology: final InferenceEngine inferenceEngine = mock(InferenceEngine.class); Map<Resource, Set<IRI>> personSVF = new HashMap<>(); personSVF.put(gradCourse, Sets.newHashSet(takesCourse)); personSVF.put(course, Sets.newHashSet(takesCourse)); personSVF.put(department, Sets.newHashSet(headOf)); personSVF.put(organization, Sets.newHashSet(worksFor, headOf)); when(inferenceEngine.getSomeValuesFromByRestrictionType(person)).thenReturn(personSVF); // Query for a specific type visit -- should not change StatementPattern originalSP = new StatementPattern(new Var("s"), new Var("p", RDF.TYPE), new Var("o", person)); final Projection originalQuery = new Projection(originalSP, new ProjectionElemList(new ProjectionElem("s", "subject"))); final Projection modifiedQuery = originalQuery.clone(); modifiedQuery.visit(new SomeValuesFromVisitor(disabledConf, inferenceEngine)); Assert.assertEquals(originalQuery, modifiedQuery); }
Example 4
Source File: HasSelfVisitorTest.java From rya with Apache License 2.0 | 6 votes |
@Test public void testTypePattern() throws Exception { final InferenceEngine inferenceEngine = mock(InferenceEngine.class); final Set<IRI> narcissistProps = new HashSet<>(); narcissistProps.add(love); when(inferenceEngine.getHasSelfImplyingType(narcissist)).thenReturn(narcissistProps); final Var subj = new Var("s"); final Var obj = new Var("o", narcissist); obj.setConstant(true); final Var pred = new Var("p", RDF.TYPE); pred.setConstant(true); final Projection query = new Projection(new StatementPattern(subj, pred, obj), new ProjectionElemList(new ProjectionElem("s", "subject"))); query.visit(new HasSelfVisitor(conf, inferenceEngine)); Assert.assertTrue(query.getArg() instanceof Union); final Union union = (Union) query.getArg(); Assert.assertTrue(union.getRightArg() instanceof StatementPattern); Assert.assertTrue(union.getLeftArg() instanceof StatementPattern); final StatementPattern expectedLeft = new StatementPattern(subj, pred, obj); final StatementPattern expectedRight = new StatementPattern(subj, new Var("urn:love", love), subj); Assert.assertEquals(expectedLeft, union.getLeftArg()); Assert.assertEquals(expectedRight, union.getRightArg()); }
Example 5
Source File: OneOfVisitorTest.java From rya with Apache License 2.0 | 6 votes |
@Test public void testOneOfDisabled() throws Exception { // Configure a mock instance engine with an ontology: final InferenceEngine inferenceEngine = mock(InferenceEngine.class); when(inferenceEngine.isEnumeratedType(SUITS)).thenReturn(true); when(inferenceEngine.getEnumeration(SUITS)).thenReturn(CARD_SUIT_ENUMERATION); when(inferenceEngine.isEnumeratedType(RANKS)).thenReturn(true); when(inferenceEngine.getEnumeration(RANKS)).thenReturn(CARD_RANK_ENUMERATION); // Query for a Suits and rewrite using the visitor: final Projection query = new Projection( new StatementPattern(new Var("s"), new Var("p", RDF.TYPE), new Var("o", SUITS)), new ProjectionElemList(new ProjectionElem("s", "subject"))); final AccumuloRdfConfiguration disabledConf = conf.clone(); disabledConf.setInferOneOf(false); query.visit(new OneOfVisitor(disabledConf, inferenceEngine)); // Expected structure: the original statement: assertTrue(query.getArg() instanceof StatementPattern); final StatementPattern actualCardSuitSp = (StatementPattern) query.getArg(); final StatementPattern expectedCardSuitSp = new StatementPattern(new Var("s"), new Var("p", RDF.TYPE), new Var("o", SUITS)); assertEquals(expectedCardSuitSp, actualCardSuitSp); }
Example 6
Source File: ConstructConsequentVisitorTest.java From rya with Apache License 2.0 | 6 votes |
@Test public void testConcreteSP() { Extension extension = new Extension(new SingletonSet(), new ExtensionElem(new ValueConstant(FOAF.PERSON), "x"), new ExtensionElem(new ValueConstant(RDF.TYPE), "y"), new ExtensionElem(new ValueConstant(OWL.CLASS), "z")); Projection projection = new Projection(extension, new ProjectionElemList( new ProjectionElem("x", "subject"), new ProjectionElem("y", "predicate"), new ProjectionElem("z", "object"))); ConstructConsequentVisitor visitor = new ConstructConsequentVisitor(); projection.visit(visitor); Set<StatementPattern> expected = Sets.newHashSet( new StatementPattern(s(FOAF.PERSON), p(RDF.TYPE), o(OWL.CLASS))); Assert.assertEquals(expected, visitor.getConsequents()); }
Example 7
Source File: HasSelfVisitorTest.java From rya with Apache License 2.0 | 5 votes |
@Test public void testPropertyPattern_constantSubj() throws Exception { final InferenceEngine inferenceEngine = mock(InferenceEngine.class); final Set<Resource> loveTypes = new HashSet<>(); loveTypes.add(narcissist); when(inferenceEngine.getHasSelfImplyingProperty(love)).thenReturn(loveTypes); final Var subj = new Var("s", self); subj.setConstant(true); final Var obj = new Var("o"); final Var pred = new Var("p", love); pred.setConstant(true); final Projection query = new Projection(new StatementPattern(subj, pred, obj), new ProjectionElemList(new ProjectionElem("s", "subject"))); query.visit(new HasSelfVisitor(conf, inferenceEngine)); Assert.assertTrue(query.getArg() instanceof Union); final Union union = (Union) query.getArg(); Assert.assertTrue(union.getRightArg() instanceof StatementPattern); Assert.assertTrue(union.getLeftArg() instanceof Extension); final StatementPattern expectedRight = new StatementPattern(subj, pred, obj); final Extension expectedLeft = new Extension( new StatementPattern(subj, new Var(RDF.TYPE.stringValue(), RDF.TYPE), new Var("urn:Narcissist", narcissist)), new ExtensionElem(subj, "o")); Assert.assertEquals(expectedLeft, union.getLeftArg()); Assert.assertEquals(expectedRight, union.getRightArg()); }
Example 8
Source File: HasSelfVisitorTest.java From rya with Apache License 2.0 | 5 votes |
@Test public void testPropertyPattern_constantObj() throws Exception { final InferenceEngine inferenceEngine = mock(InferenceEngine.class); final Set<Resource> loveTypes = new HashSet<>(); loveTypes.add(narcissist); when(inferenceEngine.getHasSelfImplyingProperty(love)).thenReturn(loveTypes); final Var subj = new Var("s"); final Var obj = new Var("o", self); obj.setConstant(true); final Var pred = new Var("p", love); pred.setConstant(true); final Projection query = new Projection(new StatementPattern(subj, pred, obj), new ProjectionElemList(new ProjectionElem("s", "subject"))); query.visit(new HasSelfVisitor(conf, inferenceEngine)); Assert.assertTrue(query.getArg() instanceof Union); final Union union = (Union) query.getArg(); Assert.assertTrue(union.getRightArg() instanceof StatementPattern); Assert.assertTrue(union.getLeftArg() instanceof Extension); final StatementPattern expectedRight = new StatementPattern(subj, pred, obj); final Extension expectedLeft = new Extension( new StatementPattern(obj, new Var(RDF.TYPE.stringValue(), RDF.TYPE), new Var("urn:Narcissist", narcissist)), new ExtensionElem(obj, "s")); Assert.assertEquals(expectedLeft, union.getLeftArg()); Assert.assertEquals(expectedRight, union.getRightArg()); }
Example 9
Source File: OneOfVisitorTest.java From rya with Apache License 2.0 | 5 votes |
@Test public void testOneOf() throws Exception { // Configure a mock instance engine with an ontology: final InferenceEngine inferenceEngine = mock(InferenceEngine.class); when(inferenceEngine.isEnumeratedType(SUITS)).thenReturn(true); when(inferenceEngine.getEnumeration(SUITS)).thenReturn(CARD_SUIT_ENUMERATION); when(inferenceEngine.isEnumeratedType(RANKS)).thenReturn(true); when(inferenceEngine.getEnumeration(RANKS)).thenReturn(CARD_RANK_ENUMERATION); // Query for a Suits and rewrite using the visitor: final Projection query = new Projection( new StatementPattern(new Var("s"), new Var("p", RDF.TYPE), new Var("o", SUITS)), new ProjectionElemList(new ProjectionElem("s", "subject"))); query.visit(new OneOfVisitor(conf, inferenceEngine)); // Expected structure: BindingSetAssignment containing the enumeration: // BindingSetAssignment(CLUBS, DIAMONDS, HEARTS, SPADES) // Collect the arguments to the BindingSetAssignment: assertTrue(query.getArg() instanceof BindingSetAssignment); final BindingSetAssignment bsa = (BindingSetAssignment) query.getArg(); final Iterable<BindingSet> iterable = bsa.getBindingSets(); final Iterator<BindingSet> iter = iterable.iterator(); assertBindingSet(iter, CARD_SUIT_ENUMERATION.iterator()); // Query for a Ranks and rewrite using the visitor: final Projection query2 = new Projection( new StatementPattern(new Var("s"), new Var("p", RDF.TYPE), new Var("o", RANKS)), new ProjectionElemList(new ProjectionElem("s", "subject"))); query2.visit(new OneOfVisitor(conf, inferenceEngine)); // Expected structure: BindingSetAssignment containing the enumeration: // BindingSetAssignment(ACE, 2, 3, 4, 5, 6, 7, 8, 9, 10, JACK, QUEEN, KING) // Collect the arguments to the BindingSetAssignment: assertTrue(query2.getArg() instanceof BindingSetAssignment); final BindingSetAssignment bsa2 = (BindingSetAssignment) query2.getArg(); final Iterable<BindingSet> iterable2 = bsa2.getBindingSets(); final Iterator<BindingSet> iter2 = iterable2.iterator(); assertBindingSet(iter2, CARD_RANK_ENUMERATION.iterator()); }
Example 10
Source File: ConstructConsequentVisitorTest.java From rya with Apache License 2.0 | 5 votes |
@Test public void testGenericSP() { Extension extension = new Extension(new SingletonSet(), new ExtensionElem(new Var("z"), "z")); Projection projection = new Projection(extension, new ProjectionElemList( new ProjectionElem("x", "subject"), new ProjectionElem("y", "predicate"), new ProjectionElem("z", "object"))); ConstructConsequentVisitor visitor = new ConstructConsequentVisitor(); projection.visit(visitor); Set<StatementPattern> expected = Sets.newHashSet( new StatementPattern(s(null), p(null), o(null))); Assert.assertEquals(expected, visitor.getConsequents()); }
Example 11
Source File: ConstructConsequentVisitorTest.java From rya with Apache License 2.0 | 5 votes |
@Test public void testMissingVariables() { Extension extension = new Extension(new SingletonSet(), new ExtensionElem(new ValueConstant(FOAF.PERSON), "x"), new ExtensionElem(new ValueConstant(RDF.TYPE), "y")); Projection projection = new Projection(extension, new ProjectionElemList( new ProjectionElem("x", "s"), new ProjectionElem("y", "predicate"), new ProjectionElem("z", "object"))); ConstructConsequentVisitor visitor = new ConstructConsequentVisitor(); projection.visit(visitor); Set<StatementPattern> expected = Sets.newHashSet( new StatementPattern(s(null), p(RDF.TYPE), o(null))); Assert.assertEquals(expected, visitor.getConsequents()); }
Example 12
Source File: ConstructConsequentVisitorTest.java From rya with Apache License 2.0 | 5 votes |
@Test public void testNoExtension() { StatementPattern sp = new StatementPattern(new Var("x"), new Var("y"), new Var("z")); Projection projection = new Projection(sp, new ProjectionElemList( new ProjectionElem("x", "subject"), new ProjectionElem("y", "predicate"), new ProjectionElem("z", "object"))); ConstructConsequentVisitor visitor = new ConstructConsequentVisitor(); projection.visit(visitor); Set<StatementPattern> expected = Sets.newHashSet( new StatementPattern(s(null), p(null), o(null))); Assert.assertEquals(expected, visitor.getConsequents()); }
Example 13
Source File: ConstructConsequentVisitorTest.java From rya with Apache License 2.0 | 5 votes |
@Test public void testBNode() { Extension extension = new Extension(new SingletonSet(), new ExtensionElem(new Var("x"), "x"), new ExtensionElem(new BNodeGenerator(), "z")); Projection projection = new Projection(extension, new ProjectionElemList( new ProjectionElem("x", "subject"), new ProjectionElem("y", "predicate"), new ProjectionElem("z", "object"))); ConstructConsequentVisitor visitor = new ConstructConsequentVisitor(); projection.visit(visitor); Set<StatementPattern> expected = Sets.newHashSet( new StatementPattern(s(null), p(null), anon(o(null)))); Assert.assertEquals(expected, visitor.getConsequents()); }
Example 14
Source File: IntersectionOfVisitorTest.java From rya with Apache License 2.0 | 4 votes |
@Test public void testIntersectionOfDisabled() throws Exception { // Configure a mock instance engine with an ontology: final InferenceEngine inferenceEngine = mock(InferenceEngine.class); final Map<Resource, List<Set<Resource>>> intersections = new HashMap<>(); final List<Set<Resource>> motherIntersections = Arrays.asList( Sets.newHashSet(ANIMAL, FEMALE, PARENT), Sets.newHashSet(FEMALE, LEADER, NUN) ); final List<Set<Resource>> fatherIntersections = Arrays.asList( Sets.newHashSet(MAN, PARENT) ); intersections.put(MOTHER, motherIntersections); when(inferenceEngine.getIntersectionsImplying(MOTHER)).thenReturn(motherIntersections); when(inferenceEngine.getIntersectionsImplying(FATHER)).thenReturn(fatherIntersections); // Query for a specific type and rewrite using the visitor: final Projection query = new Projection( new StatementPattern(new Var("s"), new Var("p", RDF.TYPE), new Var("o", MOTHER)), new ProjectionElemList(new ProjectionElem("s", "subject"))); final AccumuloRdfConfiguration disabledConf = conf.clone(); disabledConf.setInferIntersectionOf(false); query.visit(new IntersectionOfVisitor(disabledConf, inferenceEngine)); // Expected structure: the original statement: assertTrue(query.getArg() instanceof StatementPattern); final StatementPattern actualMotherSp = (StatementPattern) query.getArg(); final StatementPattern expectedMotherSp = new StatementPattern(new Var("s"), new Var("p", RDF.TYPE), new Var("o", MOTHER)); assertEquals(expectedMotherSp, actualMotherSp); // Query for a specific type and rewrite using the visitor: final Projection query2 = new Projection( new StatementPattern(new Var("s"), new Var("p", RDF.TYPE), new Var("o", FATHER)), new ProjectionElemList(new ProjectionElem("s", "subject"))); query2.visit(new IntersectionOfVisitor(disabledConf, inferenceEngine)); // Expected structure: the original statement: assertTrue(query2.getArg() instanceof StatementPattern); final StatementPattern actualFatherSp = (StatementPattern) query2.getArg(); final StatementPattern expectedFatherSp = new StatementPattern(new Var("s"), new Var("p", RDF.TYPE), new Var("o", FATHER)); assertEquals(expectedFatherSp, actualFatherSp); }
Example 15
Source File: DomainRangeVisitorTest.java From rya with Apache License 2.0 | 4 votes |
@Test public void testRewriteTypePattern() throws Exception { final InferenceEngine inferenceEngine = mock(InferenceEngine.class); final Set<IRI> domainPredicates = new HashSet<>(); final Set<IRI> rangePredicates = new HashSet<>(); domainPredicates.add(advisor); domainPredicates.add(takesCourse); rangePredicates.add(advisor); when(inferenceEngine.getPropertiesWithDomain(person)).thenReturn(domainPredicates); when(inferenceEngine.getPropertiesWithRange(person)).thenReturn(rangePredicates); final Var subjVar = new Var("s"); final StatementPattern originalSP = new StatementPattern(subjVar, new Var("p", RDF.TYPE), new Var("o", person)); final Projection query = new Projection(originalSP, new ProjectionElemList(new ProjectionElem("s", "subject"))); query.visit(new DomainRangeVisitor(conf, inferenceEngine)); // Resulting tree should consist of Unions of: // 1. The original StatementPattern // 2. A join checking for domain inference // 3. A join checking for range inference boolean containsOriginal = false; boolean containsDomain = false; boolean containsRange = false; final Stack<TupleExpr> nodes = new Stack<>(); nodes.push(query.getArg()); while (!nodes.isEmpty()) { final TupleExpr currentNode = nodes.pop(); if (currentNode instanceof Union) { nodes.push(((Union) currentNode).getLeftArg()); nodes.push(((Union) currentNode).getRightArg()); } else if (currentNode instanceof StatementPattern) { Assert.assertFalse(containsOriginal); Assert.assertEquals(originalSP, currentNode); containsOriginal = true; } else if (currentNode instanceof Join) { final TupleExpr left = ((Join) currentNode).getLeftArg(); final TupleExpr right = ((Join) currentNode).getRightArg(); Assert.assertTrue("Left-hand side should enumerate domain/range predicates", left instanceof FixedStatementPattern); Assert.assertTrue("Right-hand side should be a non-expandable SP matching triples satisfying domain/range", right instanceof DoNotExpandSP); final FixedStatementPattern fsp = (FixedStatementPattern) left; final StatementPattern sp = (StatementPattern) right; // fsp should be <predicate var, domain/range, original type var> boolean isDomain = RDFS.DOMAIN.equals(fsp.getPredicateVar().getValue()); boolean isRange = RDFS.RANGE.equals(fsp.getPredicateVar().getValue()); Assert.assertTrue(isDomain || isRange); Assert.assertEquals(originalSP.getObjectVar(), fsp.getObjectVar()); // sp should have same predicate var Assert.assertEquals(fsp.getSubjectVar(), sp.getPredicateVar()); // collect predicates that are enumerated in the FixedStatementPattern final Set<Resource> queryPredicates = new HashSet<>(); for (Statement statement : fsp.statements) { queryPredicates.add(statement.getSubject()); } if (isDomain) { Assert.assertFalse(containsDomain); // sp should be <original subject var, predicate var, unbound object var> for domain Assert.assertEquals(originalSP.getSubjectVar(), sp.getSubjectVar()); Assert.assertFalse(sp.getObjectVar().hasValue()); // verify predicates Assert.assertEquals(2, fsp.statements.size()); Assert.assertEquals(domainPredicates, queryPredicates); Assert.assertTrue(queryPredicates.contains(advisor)); Assert.assertTrue(queryPredicates.contains(takesCourse)); containsDomain = true; } else { Assert.assertFalse(containsRange); // sp should be <unbound subject var, predicate var, original subject var> for range Assert.assertFalse(sp.getSubjectVar().hasValue()); Assert.assertEquals(originalSP.getSubjectVar(), sp.getObjectVar()); // verify predicates Assert.assertEquals(1, fsp.statements.size()); Assert.assertEquals(rangePredicates, queryPredicates); Assert.assertTrue(queryPredicates.contains(advisor)); containsRange = true; } } else { Assert.fail("Expected nested Unions of Joins and StatementPatterns, found: " + currentNode.toString()); } } Assert.assertTrue(containsOriginal && containsDomain && containsRange); }
Example 16
Source File: SomeValuesFromVisitorTest.java From rya with Apache License 2.0 | 4 votes |
@Test public void testSomeValuesFrom() throws Exception { // Configure a mock instance engine with an ontology: final InferenceEngine inferenceEngine = mock(InferenceEngine.class); Map<Resource, Set<IRI>> personSVF = new HashMap<>(); personSVF.put(gradCourse, Sets.newHashSet(takesCourse)); personSVF.put(course, Sets.newHashSet(takesCourse)); personSVF.put(department, Sets.newHashSet(headOf)); personSVF.put(organization, Sets.newHashSet(worksFor, headOf)); when(inferenceEngine.getSomeValuesFromByRestrictionType(person)).thenReturn(personSVF); // Query for a specific type and rewrite using the visitor: StatementPattern originalSP = new StatementPattern(new Var("s"), new Var("p", RDF.TYPE), new Var("o", person)); final Projection query = new Projection(originalSP, new ProjectionElemList(new ProjectionElem("s", "subject"))); query.visit(new SomeValuesFromVisitor(conf, inferenceEngine)); // Expected structure: a union of two elements: one is equal to the original statement // pattern, and the other one joins a list of predicate/value type combinations // with another join querying for any nodes who are the subject of a triple with that // predicate and with an object of that type. // // Union( // SP(?node a :impliedType), // Join( // FSP(<?property someValuesFrom ?valueType> { // takesCourse/Course; // takesCourse/GraduateCourse; // headOf/Department; // headOf/Organization; // worksFor/Organization; // }), // Join( // SP(_:object a ?valueType), // SP(?node ?property _:object) // ) // ) Assert.assertTrue(query.getArg() instanceof Union); TupleExpr left = ((Union) query.getArg()).getLeftArg(); TupleExpr right = ((Union) query.getArg()).getRightArg(); Assert.assertEquals(originalSP, left); Assert.assertTrue(right instanceof Join); final Join join = (Join) right; Assert.assertTrue(join.getLeftArg() instanceof FixedStatementPattern); Assert.assertTrue(join.getRightArg() instanceof Join); FixedStatementPattern fsp = (FixedStatementPattern) join.getLeftArg(); left = ((Join) join.getRightArg()).getLeftArg(); right = ((Join) join.getRightArg()).getRightArg(); Assert.assertTrue(left instanceof StatementPattern); Assert.assertTrue(right instanceof StatementPattern); // Verify expected predicate/type pairs Assert.assertTrue(fsp.statements.contains(new NullableStatementImpl(takesCourse, OWL.SOMEVALUESFROM, course))); Assert.assertTrue(fsp.statements.contains(new NullableStatementImpl(takesCourse, OWL.SOMEVALUESFROM, gradCourse))); Assert.assertTrue(fsp.statements.contains(new NullableStatementImpl(headOf, OWL.SOMEVALUESFROM, department))); Assert.assertTrue(fsp.statements.contains(new NullableStatementImpl(headOf, OWL.SOMEVALUESFROM, organization))); Assert.assertTrue(fsp.statements.contains(new NullableStatementImpl(worksFor, OWL.SOMEVALUESFROM, organization))); Assert.assertEquals(5, fsp.statements.size()); // Verify pattern for matching instances of each pair: a Join of <_:x rdf:type ?t> and // <?s ?p _:x> where p and t are the predicate/type pair and s is the original subject // variable. StatementPattern leftSP = (StatementPattern) left; StatementPattern rightSP = (StatementPattern) right; Assert.assertEquals(rightSP.getObjectVar(), leftSP.getSubjectVar()); Assert.assertEquals(RDF.TYPE, leftSP.getPredicateVar().getValue()); Assert.assertEquals(fsp.getObjectVar(), leftSP.getObjectVar()); Assert.assertEquals(originalSP.getSubjectVar(), rightSP.getSubjectVar()); Assert.assertEquals(fsp.getSubjectVar(), rightSP.getPredicateVar()); }