Search in sources :

Example 11 with Graph

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

the class StagesQueryTest method graphWithRDF.

private Graph graphWithRDF(String rdf) {
    Graph graph = graphFactory.createTempGraph();
    graph.addTriplesFromTurtle(rdf);
    return graph;
}
Also used : Graph(com.thoughtworks.studios.shine.semweb.Graph)

Example 12 with Graph

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

the class LazyStageGraphLoaderTest method loadsFromRealLoaderAndSavesToStorageWhenNotAlreadyStoried.

@Test
public void loadsFromRealLoaderAndSavesToStorageWhenNotAlreadyStoried() {
    StageIdentifier stageId = new StageIdentifier("pipeline-foo", 23, "stage-1", "1");
    DummyStageResourceImporter realLoader = new DummyStageResourceImporter(realGraph(), stageId);
    LazyStageGraphLoader loader = new LazyStageGraphLoader(realLoader, stageStorage);
    Graph stageGraph = loader.load(stageId);
    assertTrue(stageGraph.containsResourceWithURI("http://stage/1"));
    assertTrue(stageStorage.isStageStored(stageId));
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) Graph(com.thoughtworks.studios.shine.semweb.Graph) Test(org.junit.Test)

Example 13 with Graph

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

the class LazyStageGraphLoaderTest method directLoadFromStageStorageIfStageAlreadyStored.

@Test
public void directLoadFromStageStorageIfStageAlreadyStored() {
    Graph stageGraph = graphFactory.createTempGraph();
    stageGraph.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 . " + "");
    stageStorage.save(stageGraph);
    LazyStageGraphLoader loader = new LazyStageGraphLoader(null, stageStorage);
    Graph loadedStageGraph = loader.load(new StageIdentifier("pipeline-foo", 23, "stage-1", "1"));
    assertTrue(loadedStageGraph.containsResourceWithURI("http://stage/1"));
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) Graph(com.thoughtworks.studios.shine.semweb.Graph) Test(org.junit.Test)

Example 14 with Graph

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

the class BackgroundStageLoaderIntegrationTest method handleAStageURLNotYetSeenShouldStoreStageResourceIntoStageStorage.

@Test
public void handleAStageURLNotYetSeenShouldStoreStageResourceIntoStageStorage() {
    TestFailureSetup.SavedStage savedStage = failureSetup.setupPipelineInstanceWithoutTestXmlStubbing(true, null, new Date());
    loader.handle(feedEntry(savedStage), pipelineInstanceLoader);
    assertTrue(stageStorage.isStageStored(savedStage.stageId));
    Graph storedGraph = stageStorage.load(savedStage.stageId);
    Stage stage = savedStage.stage;
    String baseUrl = "https://localhost:8154/go";
    String jobUrl = new JobXmlViewModel(stage.getJobInstances().first()).httpUrl(baseUrl);
    assertTrue(storedGraph.containsResourceWithURI(jobUrl));
    assertTrue(storedGraph.containsResourceWithURI(new StageXmlViewModel(stage).httpUrl(baseUrl)));
    Pipeline pipeline = savedStage.pipeline;
    assertTrue(storedGraph.containsResourceWithURI(PipelineXmlViewModel.httpUrlForPipeline(baseUrl, pipeline.getId(), pipeline.getName())));
    Modification latestModification = pipeline.getMaterialRevisions().getRevisions().get(0).getLatestModification();
    assertTrue(storedGraph.containsResourceWithURI(ScmMaterial.changesetUrl(latestModification, baseUrl, latestModification.getMaterialInstance().getId())));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) Graph(com.thoughtworks.studios.shine.semweb.Graph) StageXmlViewModel(com.thoughtworks.go.server.domain.xml.StageXmlViewModel) JobXmlViewModel(com.thoughtworks.go.server.domain.xml.JobXmlViewModel) TestFailureSetup(com.thoughtworks.go.server.dao.sparql.TestFailureSetup) Stage(com.thoughtworks.go.domain.Stage) Date(java.util.Date) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 15 with Graph

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

the class StageResourceImporterTest method shouldImportPipelineBuildTriggers.

@Test
public void shouldImportPipelineBuildTriggers() throws Exception {
    TestFailureSetup.SavedStage savedStage = failureSetup.setupPipelineInstanceWithoutTestXmlStubbing(true, null, new Date());
    Graph graph = importer.load(savedStage.stageId, graphFactory, new XSLTTransformerRegistry());
    for (Modification modification : savedStage.pipeline.getMaterialRevisions().getRevisions().get(0).getModifications()) {
        String changeSetUri = ScmMaterial.changesetUrl(modification, baseUrl, modification.getMaterialInstance().getId());
        assertTrue(graph.containsResourceWithURI(changeSetUri));
        String ask = "" + "PREFIX cruise: <" + GoOntology.URI + "> " + "PREFIX xsd:<http://www.w3.org/2001/XMLSchema#> " + "ASK WHERE {" + "  <" + PipelineXmlViewModel.httpUrlForPipeline(baseUrl, savedStage.pipeline.getId(), savedStage.pipeline.getName()) + "> cruise:pipelineTrigger <" + changeSetUri + "> . " + "}";
        assertAskIsTrue(graph, ask);
    }
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) Graph(com.thoughtworks.studios.shine.semweb.Graph) TestFailureSetup(com.thoughtworks.go.server.dao.sparql.TestFailureSetup) XSLTTransformerRegistry(com.thoughtworks.studios.shine.semweb.grddl.XSLTTransformerRegistry) Date(java.util.Date) Test(org.junit.Test)

Aggregations

Graph (com.thoughtworks.studios.shine.semweb.Graph)41 Test (org.junit.Test)26 InMemoryTempGraphFactory (com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory)18 File (java.io.File)7 JobXmlViewModel (com.thoughtworks.go.server.domain.xml.JobXmlViewModel)5 ShineRuntimeException (com.thoughtworks.studios.shine.ShineRuntimeException)5 InputStream (java.io.InputStream)5 TestFailureSetup (com.thoughtworks.go.server.dao.sparql.TestFailureSetup)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 Date (java.util.Date)4 Pipeline (com.thoughtworks.go.domain.Pipeline)3 Stage (com.thoughtworks.go.domain.Stage)3 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)3 StageXmlViewModel (com.thoughtworks.go.server.domain.xml.StageXmlViewModel)3 XSLTTransformerRegistry (com.thoughtworks.studios.shine.semweb.grddl.XSLTTransformerRegistry)3 Modification (com.thoughtworks.go.domain.materials.Modification)2 GoGRDDLResourceRDFizer (com.thoughtworks.studios.shine.cruise.GoGRDDLResourceRDFizer)2 BoundVariables (com.thoughtworks.studios.shine.semweb.BoundVariables)2 IOException (java.io.IOException)2 Transformer (javax.xml.transform.Transformer)2