use of org.apache.jena.rdf.model.Property in project jena by apache.
the class ModelQuadHolderTest method anonymousTest.
@Test
public void anonymousTest() {
model = ModelFactory.createDefaultModel();
List<Triple> tLst = new ArrayList<Triple>();
Resource s = ResourceFactory.createResource("s");
Property p = ResourceFactory.createProperty("p");
Resource o = ResourceFactory.createResource("o");
tLst.add(new Triple(s.asNode(), p.asNode(), o.asNode()));
model.add(s, p, o);
Resource s2 = ResourceFactory.createResource("s2");
Property p2 = ResourceFactory.createProperty("p2");
Resource o2 = ResourceFactory.createResource("o2");
tLst.add(new Triple(s2.asNode(), p2.asNode(), o2.asNode()));
model.add(s2, p2, o2);
holder = new ModelQuadHolder(model);
List<Quad> lst = holder.getQuads().toList();
assertEquals(2, lst.size());
Quad q = new Quad(Quad.defaultGraphNodeGenerated, tLst.get(0));
assertTrue("missing " + q, lst.contains(q));
q = new Quad(Quad.defaultGraphNodeGenerated, tLst.get(1));
assertTrue("missing " + q, lst.contains(q));
}
use of org.apache.jena.rdf.model.Property in project jena by apache.
the class ModelQuadHolderTest method namedTest.
@Test
public void namedTest() {
model = ModelFactory.createDefaultModel();
Node g = NodeFactory.createURI("g");
List<Triple> tLst = new ArrayList<Triple>();
Resource s = ResourceFactory.createResource("s");
Property p = ResourceFactory.createProperty("p");
Resource o = ResourceFactory.createResource("o");
tLst.add(new Triple(s.asNode(), p.asNode(), o.asNode()));
model.add(s, p, o);
Resource s2 = ResourceFactory.createResource("s2");
Property p2 = ResourceFactory.createProperty("p2");
Resource o2 = ResourceFactory.createResource("o2");
tLst.add(new Triple(s2.asNode(), p2.asNode(), o2.asNode()));
model.add(s2, p2, o2);
holder = new ModelQuadHolder(g, model);
List<Quad> lst = holder.getQuads().toList();
assertEquals(2, lst.size());
Quad q = new Quad(g, tLst.get(0));
assertTrue("missing " + q, lst.contains(q));
q = new Quad(g, tLst.get(1));
assertTrue("missing " + q, lst.contains(q));
}
use of org.apache.jena.rdf.model.Property in project jena by apache.
the class TestOntTools method testShortestPath6.
public void testShortestPath6() {
Property p = m_model.createProperty(NS + "p");
Property q = m_model.createProperty(NS + "q");
// a - b - a by q
// tests loop detection
m_a.addProperty(q, m_b);
m_b.addProperty(q, m_a);
assertNull(OntTools.findShortestPath(m_model, m_a, m_c, new OntTools.PredicatesFilter(new Property[] { p, q })));
}
use of org.apache.jena.rdf.model.Property in project jena by apache.
the class TestOntTools method testShortestPath7.
public void testShortestPath7() {
Property p = m_model.createProperty(NS + "p");
Property q = m_model.createProperty(NS + "q");
// a - d - e - f by p and q
m_a.addProperty(p, m_d);
m_d.addProperty(q, m_e);
m_d.addProperty(q, m_b);
m_e.addProperty(p, m_f);
testPath(OntTools.findShortestPath(m_model, m_a, m_f, new OntTools.PredicatesFilter(new Property[] { p, q })), new Property[] { p, q, p });
}
use of org.apache.jena.rdf.model.Property in project jena by apache.
the class TestOntTools method testShortestPath0.
public void testShortestPath0() {
Property p = m_model.createProperty(NS + "p");
m_a.addProperty(p, m_b);
testPath(OntTools.findShortestPath(m_model, m_a, m_b, ANY), new Property[] { p });
}
Aggregations