Search in sources :

Example 31 with InMemoryTempGraphFactory

use of com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory 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)

Example 32 with InMemoryTempGraphFactory

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

the class StagesQueryTest method setUp.

@Before
public void setUp() throws Exception {
    File tempFolder = temporaryFolder.newFolder("shine");
    graphLoader = new StageStorage(tempFolder.getAbsolutePath());
    graphLoader.clear();
    graphFactory = new InMemoryTempGraphFactory();
}
Also used : StageStorage(com.thoughtworks.studios.shine.cruise.stage.details.StageStorage) File(java.io.File) InMemoryTempGraphFactory(com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory) Before(org.junit.Before)

Example 33 with InMemoryTempGraphFactory

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

the class JobResourceImporterTest method listFilesOfTypeWhenThereAreNoMatches.

@Test
public void listFilesOfTypeWhenThereAreNoMatches() {
    JobResourceImporter rdfImporter = new JobResourceImporter("src/test-shared/resources/cruise", new InMemoryTempGraphFactory(), transformerRegistry, xmlApiService, systemEnvironment);
    File[] files = rdfImporter.getArtifactFilesOfType("artifacts/job2", "junit-reports", "boo");
    assertThat(files.length, equalTo(0));
}
Also used : InMemoryTempGraphFactory(com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory) File(java.io.File) Test(org.junit.Test)

Example 34 with InMemoryTempGraphFactory

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

the class JobResourceImporterTest method listArtifactFilesOfTypeWhenThereAreMatchesWithCaseInSensitiveExtensions.

@Test
public void listArtifactFilesOfTypeWhenThereAreMatchesWithCaseInSensitiveExtensions() {
    JobResourceImporter rdfImporter = new JobResourceImporter("src/test-shared/resources/cruise", new InMemoryTempGraphFactory(), transformerRegistry, xmlApiService, systemEnvironment);
    File[] files = rdfImporter.getArtifactFilesOfType("artifacts", "job2", "xml");
    assertThat(files.length, equalTo(4));
    List<String> actualFileNames = new ArrayList<>();
    for (File f : files) {
        actualFileNames.add(f.getName());
    }
    assertThat(actualFileNames, hasItem("junit-report-failed.xml"));
    assertThat(actualFileNames, hasItem("junit-report-passed.xml"));
    assertThat(actualFileNames, hasItem("junit-report-passed-with-capitalcase-extension.XML"));
    assertThat(actualFileNames, hasItem("junit-report-passed-with-mixedcase-extension.Xml"));
}
Also used : ArrayList(java.util.ArrayList) InMemoryTempGraphFactory(com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory) File(java.io.File) Test(org.junit.Test)

Example 35 with InMemoryTempGraphFactory

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

the class JobResourceImporterTest method listArtifactFilesReturnsEmptyListWhenJobArtifactPathIsAFile.

@Test
public void listArtifactFilesReturnsEmptyListWhenJobArtifactPathIsAFile() {
    JobResourceImporter rdfImporter = new JobResourceImporter("src/test-shared/resources/cruise", new InMemoryTempGraphFactory(), transformerRegistry, xmlApiService, systemEnvironment);
    File[] files = rdfImporter.getArtifactFilesOfType("artifacts/job2/junit-reports", "junit-report-failed.xml", "xml");
    assertThat(files.length, equalTo(0));
}
Also used : InMemoryTempGraphFactory(com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory) File(java.io.File) Test(org.junit.Test)

Aggregations

InMemoryTempGraphFactory (com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory)37 Test (org.junit.Test)28 Graph (com.thoughtworks.studios.shine.semweb.Graph)18 File (java.io.File)14 ByteArrayInputStream (java.io.ByteArrayInputStream)9 InputStream (java.io.InputStream)7 Before (org.junit.Before)6 JobXmlViewModel (com.thoughtworks.go.server.domain.xml.JobXmlViewModel)2 XSLTTransformerRegistry (com.thoughtworks.studios.shine.semweb.grddl.XSLTTransformerRegistry)2 JobInstance (com.thoughtworks.go.domain.JobInstance)1 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)1 TestFailureSetup (com.thoughtworks.go.server.dao.sparql.TestFailureSetup)1 ShineRuntimeException (com.thoughtworks.studios.shine.ShineRuntimeException)1 StageStorage (com.thoughtworks.studios.shine.cruise.stage.details.StageStorage)1 BoundVariables (com.thoughtworks.studios.shine.semweb.BoundVariables)1 GRDDLTransformer (com.thoughtworks.studios.shine.semweb.grddl.GRDDLTransformer)1 BufferedInputStream (java.io.BufferedInputStream)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1