Search in sources :

Example 71 with LiteralImpl

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);
}
Also used : LiteralImpl(org.openrdf.model.impl.LiteralImpl) Statement(org.openrdf.model.Statement) URIImpl(org.openrdf.model.impl.URIImpl)

Example 72 with LiteralImpl

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);
}
Also used : LiteralImpl(org.openrdf.model.impl.LiteralImpl) Statement(org.openrdf.model.Statement)

Example 73 with LiteralImpl

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);
}
Also used : LiteralImpl(org.openrdf.model.impl.LiteralImpl) Statement(org.openrdf.model.Statement) Test(org.junit.Test)

Example 74 with LiteralImpl

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);
}
Also used : LiteralImpl(org.openrdf.model.impl.LiteralImpl) Statement(org.openrdf.model.Statement)

Example 75 with LiteralImpl

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)));
}
Also used : BindingSet(org.openrdf.query.BindingSet) LiteralImpl(org.openrdf.model.impl.LiteralImpl) TupleQueryResult(org.openrdf.query.TupleQueryResult) Test(org.junit.Test)

Aggregations

LiteralImpl (org.openrdf.model.impl.LiteralImpl)155 Test (org.junit.Test)124 URIImpl (org.openrdf.model.impl.URIImpl)62 BindingSet (org.openrdf.query.BindingSet)58 Statement (org.openrdf.model.Statement)40 ArrayList (java.util.ArrayList)34 TupleQueryResult (org.openrdf.query.TupleQueryResult)34 QueryBindingSet (org.openrdf.query.algebra.evaluation.QueryBindingSet)33 URI (org.openrdf.model.URI)29 IntegerLiteralImpl (org.openrdf.model.impl.IntegerLiteralImpl)23 QueryEvaluationException (org.openrdf.query.QueryEvaluationException)22 HashSet (java.util.HashSet)21 RyaStatement (org.apache.rya.api.domain.RyaStatement)19 RyaType (org.apache.rya.api.domain.RyaType)19 RyaURI (org.apache.rya.api.domain.RyaURI)19 ParsedQuery (org.openrdf.query.parser.ParsedQuery)19 SPARQLParser (org.openrdf.query.parser.sparql.SPARQLParser)19 StatementMetadata (org.apache.rya.api.domain.StatementMetadata)17 StatementImpl (org.openrdf.model.impl.StatementImpl)16 NumericLiteralImpl (org.openrdf.model.impl.NumericLiteralImpl)15