Search in sources :

Example 16 with BoundVariables

use of com.thoughtworks.studios.shine.semweb.BoundVariables in project gocd by gocd.

the class SesameDateTimeOrderingTest method sesameBetterOrderDateTimesCorrectly.

@Test
public void sesameBetterOrderDateTimesCorrectly() throws Exception {
    Graph tempGraph = new InMemoryTempGraphFactory().createTempGraph();
    tempGraph.addTriplesFromTurtle("" + "@prefix xsd:<http://www.w3.org/2001/XMLSchema#>  . " + "<http://foo1> <http://bar> \"2005-02-28T00:00:00Z\"^^xsd:dateTime . " + "<http://foo2> <http://bar> \"2005-02-28T00:00:01Z\"^^xsd:dateTime . " + "<http://foo3> <http://bar> \"2005-02-28T00:00:00-05:00\"^^xsd:dateTime . " + "");
    List<BoundVariables> bvs = tempGraph.select("PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>" + "SELECT ?subject WHERE { " + "  ?subject ?p ?o . " + "} ORDER BY (?o)");
    assertEquals("http://foo1", bvs.get(0).getAsString("subject"));
    assertEquals("http://foo2", bvs.get(1).getAsString("subject"));
    assertEquals("http://foo3", bvs.get(2).getAsString("subject"));
    bvs = tempGraph.select("PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>" + "SELECT ?subject WHERE { " + "  ?subject ?p ?o . " + "} ORDER BY DESC (?o)");
    assertEquals("http://foo3", bvs.get(0).getAsString("subject"));
    assertEquals("http://foo2", bvs.get(1).getAsString("subject"));
    assertEquals("http://foo1", bvs.get(2).getAsString("subject"));
}
Also used : Graph(com.thoughtworks.studios.shine.semweb.Graph) BoundVariables(com.thoughtworks.studios.shine.semweb.BoundVariables) InMemoryTempGraphFactory(com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory) Test(org.junit.Test)

Aggregations

BoundVariables (com.thoughtworks.studios.shine.semweb.BoundVariables)16 Test (org.junit.Test)10 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)3 ShineRuntimeException (com.thoughtworks.studios.shine.ShineRuntimeException)3 Graph (com.thoughtworks.studios.shine.semweb.Graph)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 QueryEvaluationException (org.openrdf.query.QueryEvaluationException)2 TupleQueryResult (org.openrdf.query.TupleQueryResult)2 MoreThanOneResultFoundException (com.thoughtworks.studios.shine.semweb.MoreThanOneResultFoundException)1 InMemoryTempGraphFactory (com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 LinkedList (java.util.LinkedList)1