Search in sources :

Example 36 with InMemoryTempGraphFactory

use of com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory 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);
}
Also used : Graph(com.thoughtworks.studios.shine.semweb.Graph) JobXmlViewModel(com.thoughtworks.go.server.domain.xml.JobXmlViewModel) InMemoryTempGraphFactory(com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory) Test(org.junit.Test)

Example 37 with InMemoryTempGraphFactory

use of com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory 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());
}
Also used : Graph(com.thoughtworks.studios.shine.semweb.Graph) JobInstance(com.thoughtworks.go.domain.JobInstance) JobXmlViewModel(com.thoughtworks.go.server.domain.xml.JobXmlViewModel) Document(org.dom4j.Document) InMemoryTempGraphFactory(com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory) 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