use of org.openrdf.model.impl.LiteralImpl in project wikidata-query-rdf by wikimedia.
the class NormalizingRdfHandlerUnitTest method testHandleStatement.
private void testHandleStatement(String suffix) throws RDFHandlerException {
StatementChecker checkStatement = new StatementChecker();
NormalizingRdfHandler handler = new NormalizingRdfHandler(checkStatement);
String testStr = "http://wikiba.se/ontology-" + suffix + "#Test";
Statement s = statement(testStr, RDF.TYPE, Ontology.ITEM);
Statement p = statement("Q1", testStr, Ontology.ITEM);
Statement o = statement("Q1", RDF.TYPE, new URIImpl(testStr));
Statement o2 = statement("Q1", RDF.TYPE, new LiteralImpl(testStr));
checkStatement.expect("http://wikiba.se/ontology#Test", null, null);
handler.handleStatement(s);
checkStatement.expect(null, "http://wikiba.se/ontology#Test", null);
handler.handleStatement(p);
checkStatement.expect(null, null, "http://wikiba.se/ontology#Test");
handler.handleStatement(o);
checkStatement.expect(null, null, testStr);
handler.handleStatement(o2);
}
use of org.openrdf.model.impl.LiteralImpl in project wikidata-query-rdf by wikimedia.
the class NormalizingRdfHandlerUnitTest method testDecimal.
private void testDecimal(String str) throws RDFHandlerException {
StatementChecker checkStatement = new StatementChecker();
NormalizingRdfHandler handler = new NormalizingRdfHandler(checkStatement);
handler.handleNamespace("xsd", XMLSchema.NAMESPACE);
Statement s = statement("Q1", "P1", new LiteralImpl(str, XMLSchema.DECIMAL));
checkStatement.expect(null, null, str);
handler.handleStatement(s);
}
use of org.openrdf.model.impl.LiteralImpl in project wikidata-query-rdf by wikimedia.
the class NormalizingRdfHandlerUnitTest method testHandleBadDecimal.
@Test
public void testHandleBadDecimal() throws RDFHandlerException {
StatementChecker checkStatement = new StatementChecker();
NormalizingRdfHandler handler = new NormalizingRdfHandler(checkStatement);
handler.handleNamespace("xsd", XMLSchema.NAMESPACE);
Statement s = statement("Q1", "P1", new LiteralImpl("", XMLSchema.DECIMAL));
checkStatement.expect(null, null, "0");
handler.handleStatement(s);
}
use of org.openrdf.model.impl.LiteralImpl in project wikidata-query-rdf by wikimedia.
the class NormalizingRdfHandlerUnitTest method testLiteral.
private void testLiteral(String str, String expected) throws RDFHandlerException {
StatementChecker checkStatement = new StatementChecker();
NormalizingRdfHandler handler = new NormalizingRdfHandler(checkStatement);
handler.handleNamespace("xsd", XMLSchema.NAMESPACE);
Statement s = statement("Q1", "P1", new LiteralImpl(str));
checkStatement.expect(null, null, expected);
handler.handleStatement(s);
s = statement("Q1", "P1", new LiteralImpl(str, "en"));
checkStatement.expect(null, null, expected);
handler.handleStatement(s);
// Non-string ones are not touched for now
s = statement("Q1", "P1", new LiteralImpl(str, XMLSchema.DATE));
checkStatement.expect(null, null, str);
handler.handleStatement(s);
}
use of org.openrdf.model.impl.LiteralImpl in project wikidata-query-rdf by wikimedia.
the class WikibaseGeoExtensionIntegrationTest method distanceSelf.
@Test
public void distanceSelf() throws QueryEvaluationException {
TupleQueryResult results = rdfRepository.query("SELECT * WHERE {" + "BIND(\"Point(-81.4167 -80.0)\"^^geo:wktLiteral as ?point)\n" + "BIND(geof:distance(?point, ?point) AS ?distance)}");
BindingSet result = results.next();
// distance between point and itself should be 0
assertThat(result, binds("distance", new LiteralImpl("0.0", XMLSchema.DOUBLE)));
}
Aggregations