use of org.apache.jena.rdf.model.Statement in project jena by apache.
the class QueryTest method runTestAsk.
void runTestAsk(Query query, QueryExecution qe) throws Exception {
boolean result = qe.execAsk();
if (results != null) {
if (results.isBoolean()) {
boolean b = results.getBooleanResult();
assertEquals("ASK test results do not match", b, result);
} else {
Model resultsAsModel = results.getModel();
StmtIterator sIter = results.getModel().listStatements(null, RDF.type, ResultSetGraphVocab.ResultSet);
if (!sIter.hasNext())
throw new QueryTestException("Can't find the ASK result");
Statement s = sIter.nextStatement();
if (sIter.hasNext())
throw new QueryTestException("Too many result sets in ASK result");
Resource r = s.getSubject();
Property p = resultsAsModel.createProperty(ResultSetGraphVocab.getURI() + "boolean");
boolean x = r.getRequiredProperty(p).getBoolean();
if (x != result)
assertEquals("ASK test results do not match", x, result);
}
}
return;
}
use of org.apache.jena.rdf.model.Statement in project jena by apache.
the class TestItem method _getName.
private String _getName() {
Statement s = testResource.getProperty(TestManifest.name);
String ln = s.getSubject().getLocalName();
if (s == null)
return ln + " <<unset>>";
return "(" + ln + ") " + s.getString();
}
use of org.apache.jena.rdf.model.Statement in project jena by apache.
the class TestItem method _getNamedGraphsURIs.
/**
* Get the named graphs : maybe unknown if part for the query (FROM NAMED)
*
* @return List
*/
private List<String> _getNamedGraphsURIs() {
if (!_getAction().isAnon())
// Action is a URI - data had better be in the query itself.
return null;
List<String> l = new ArrayList<>();
ClosableIterator<Statement> cIter = _getAction().listProperties(VocabTestQuery.graphData);
for (; cIter.hasNext(); ) {
Statement obj = cIter.next();
String df = obj.getResource().getURI();
l.add(df);
}
cIter.close();
return l;
}
use of org.apache.jena.rdf.model.Statement in project jena by apache.
the class TestItem method _getDefaultGraphURIs.
// ----------------------------------------------------
// ---- Query specific properties
/**
* Get the data file (default graph): maybe unknown if part for the query
* (FROM)
*
* @return List
*/
private List<String> _getDefaultGraphURIs() {
if (!_getAction().isAnon())
// Action is a URI - data had better be in the query itself.
return null;
List<String> l = new ArrayList<>();
ClosableIterator<Statement> cIter = _getAction().listProperties(VocabTestQuery.data);
for (; cIter.hasNext(); ) {
Statement stmt = cIter.next();
String df = stmt.getResource().getURI();
l.add(df);
}
cIter.close();
return l;
}
use of org.apache.jena.rdf.model.Statement in project jena by apache.
the class UpdateTest method getDataset.
static Dataset getDataset(Resource r) {
//DataSource ds = DatasetFactory.create() ;
DatasetGraph dsg = DatasetGraphFactory.create();
// Growing. dataset.
Dataset ds = DatasetFactory.wrap(dsg);
List<String> dftData = getAll(r, TestManifestUpdate_11.data);
for (String x : dftData) FileManager.get().readModel(ds.getDefaultModel(), x);
ClosableIterator<Statement> cIter = r.listProperties(TestManifestUpdate_11.graphData);
for (; cIter.hasNext(); ) {
// An graphData entry can be a URI or a [ ut ... ; rdfs:label "foo" ] ;
Statement stmt = cIter.next();
Resource gn = stmt.getResource();
if (gn.isAnon()) {
if (!gn.hasProperty(TestManifestUpdate_11.graph))
System.err.println("No data for graphData");
String fn = gn.getProperty(TestManifestUpdate_11.graph).getResource().getURI();
String name = gn.getProperty(RDFS.label).getString();
Model m = FileManager.get().loadModel(fn);
ds.addNamedModel(name, m);
} else {
String x = gn.getURI();
Model m = FileManager.get().loadModel(x);
ds.addNamedModel(x, m);
}
}
cIter.close();
return ds;
}
Aggregations