use of com.thoughtworks.studios.shine.semweb.Graph 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"));
}
use of com.thoughtworks.studios.shine.semweb.Graph in project gocd by gocd.
the class JobResourceImporterTest method testLoadingFileThatDoesNotExist.
@Test
public void testLoadingFileThatDoesNotExist() throws GoIntegrationException, IOException, DocumentException {
Clock.fakeNowUTC(2008, 1, 20, 0, 0, 1);
when(xmlApiService.write(any(JobXmlViewModel.class), eq(baseUri))).thenReturn(docFor(jobWithArtifactsMissing));
JobResourceImporter rdfImporter = new JobResourceImporter("src/test-shared/resources/cruise/artifacts", new InMemoryTempGraphFactory(), transformerRegistry, xmlApiService, systemEnvironment);
Graph jobGraph = rdfImporter.importJob(JobInstanceMother.passed("foo"), "https://localhost:8154/go");
String ask = "PREFIX xunit: <" + XUnitOntology.URI + "> ASK WHERE { [] a xunit:TestCase }";
assertAskIsFalse(jobGraph, ask);
}
use of com.thoughtworks.studios.shine.semweb.Graph in project gocd by gocd.
the class JobResourceImporterTest method testArtifactsAreImported.
@Test
public void testArtifactsAreImported() throws Exception {
Clock.fakeNowUTC(2008, 1, 20, 0, 0, 1);
JobInstance failedJob = JobInstanceMother.failed("test");
Document document = docFor(happyJobResourceXML);
document.selectSingleNode("//link[@rel='self']/@href").setText(new JobXmlViewModel(failedJob).httpUrl(baseUri));
when(xmlApiService.write(any(JobXmlViewModel.class), eq(baseUri))).thenReturn(document);
JobResourceImporter rdfImporter = new JobResourceImporter("src/test-shared/resources/cruise/artifacts", new InMemoryTempGraphFactory(), transformerRegistry, xmlApiService, systemEnvironment);
Graph graph = rdfImporter.importJob(failedJob, baseUri);
String testCountSelect = "PREFIX xunit: <" + XUnitOntology.URI + "> SELECT ?testcase WHERE { ?testCase a xunit:TestCase }";
assertEquals(5, graph.select(testCountSelect).size());
}
use of com.thoughtworks.studios.shine.semweb.Graph in project gocd by gocd.
the class LazyStageGraphLoaderTest method realGraph.
private Graph realGraph() {
final Graph realStageGraph = graphFactory.createTempGraph();
realStageGraph.addTriplesFromTurtle("" + "@prefix cruise: <" + GoOntology.URI + "> . " + "@prefix xunit: <" + XUnitOntology.URI + "> . " + "@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . " + "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . " + "" + " <http://pipeline/1> a cruise:Pipeline . " + " <http://pipeline/1> cruise:pipelineName \"pipeline-foo\"^^xsd:string ." + " <http://pipeline/1> cruise:pipelineCounter \"23\"^^xsd:integer . " + " <http://pipeline/1> cruise:hasStage <http://stage/1> . " + " <http://stage/1> a cruise:Stage . " + " <http://stage/1> cruise:stageName \"stage-1\"^^xsd:string . " + " <http://stage/1> cruise:stageCounter \"1\"^^xsd:integer . " + // only job in the stage graph
" <http://stage/1> cruise:hasJob <http://job/1> . " + "");
return realStageGraph;
}
use of com.thoughtworks.studios.shine.semweb.Graph in project gocd by gocd.
the class StageStorageTest method saveStageGraphAndLoadOutSameGraph.
@Test
public void saveStageGraphAndLoadOutSameGraph() throws Exception {
Graph graph = graphWithRDF("" + "@prefix cruise: <" + GoOntology.URI + "> . " + "@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . " + "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . " + "" + "<http://pipeline/1> a cruise:Pipeline ." + "<http://pipeline/1> cruise:pipelineName \"p\"^^xsd:string ." + "<http://pipeline/1> cruise:pipelineCounter 1 ." + "<http://pipeline/1> cruise:hasStage <http://stage/1> ." + "<http://stage/1> rdf:type cruise:Stage . " + "<http://stage/1> cruise:stageName \"s\"^^xsd:string . " + "<http://stage/1> cruise:stageCounter 2 . " + "<http://stage/1> cruise:hasJob <http://job/1> . " + "<http://job/1> a cruise:Job . " + "");
stageStorage.save(graph);
Graph loadedGraph = stageStorage.load(new StageIdentifier("p", 1, "s", "2"));
assertAskIsTrue(loadedGraph, "" + "PREFIX cruise: <" + GoOntology.URI + "> " + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> " + "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> " + "ASK WHERE {" + " <http://pipeline/1> a cruise:Pipeline ." + " <http://pipeline/1> cruise:pipelineName \"p\"^^xsd:string ." + " <http://pipeline/1> cruise:pipelineCounter 1 ." + " <http://pipeline/1> cruise:hasStage <http://stage/1> ." + " <http://stage/1> rdf:type cruise:Stage . " + " <http://stage/1> cruise:stageName \"s\"^^xsd:string . " + " <http://stage/1> cruise:stageCounter 2 . " + " <http://stage/1> cruise:hasJob <http://job/1> . " + " <http://job/1> a cruise:Job . " + "}");
}
Aggregations