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;
}
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));
}
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"));
}
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())));
}
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);
}
}
Aggregations