use of org.apache.jena.rdf.model.impl.ModelCom in project jena by apache.
the class TestContains method testModelComContainsSPcallsContainsSPO.
public void testModelComContainsSPcallsContainsSPO() {
final Graph g = Factory.createDefaultGraph();
final boolean[] wasCalled = { false };
// FIXME change to dynamic proxy
final Model m = new ModelCom(g) {
@Override
public boolean contains(final Resource s, final Property p, final RDFNode o) {
wasCalled[0] = true;
return super.contains(s, p, o);
}
};
Assert.assertFalse(m.contains(ModelHelper.resource("r"), ModelHelper.property("p")));
Assert.assertTrue("contains(S,P) should call contains(S,P,O)", wasCalled[0]);
}
use of org.apache.jena.rdf.model.impl.ModelCom in project jena by apache.
the class AbstractTestModel method testRemoveSPO.
/**
Test that remove(s, p, o) works, in the presence of inferencing graphs that
mean emptyness isn't available. This is why we go round the houses and
test that expected ~= initialContent + addedStuff - removed - initialContent.
*/
public void testRemoveSPO() {
ModelCom mc = (ModelCom) ModelFactory.createDefaultModel();
for (String[] aCase : cases) {
for (int j = 0; j < 3; j += 1) {
Model content = getModel();
Model baseContent = copy(content);
modelAdd(content, aCase[0]);
Triple remove = triple(aCase[1]);
Node s = remove.getSubject(), p = remove.getPredicate(), o = remove.getObject();
Resource S = (Resource) (s.equals(Node.ANY) ? null : mc.getRDFNode(s));
Property P = ((p.equals(Node.ANY) ? null : mc.getRDFNode(p).as(Property.class)));
RDFNode O = o.equals(Node.ANY) ? null : mc.getRDFNode(o);
Model expected = modelWithStatements(aCase[2]);
content.removeAll(S, P, O);
Model finalContent = copy(content).remove(baseContent);
assertIsoModels(aCase[1], expected, finalContent);
}
}
}
Aggregations