use of com.thoughtworks.go.server.domain.xml.JobXmlViewModel 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.go.server.domain.xml.JobXmlViewModel in project gocd by gocd.
the class JobResourceImporter method importJob.
public Graph importJob(JobInstance job, final String baseUri) throws GoIntegrationException {
LOGGER.debug("Attempting to import job {}", job);
JobXmlViewModel xmlModel = new JobXmlViewModel(job);
Graph jobGraph = rdfizer.importURIUsingGRDDL(xmlModel, baseUri);
URIReference jobURI = jobGraph.getURIReference(xmlModel.httpUrl(baseUri));
importArtifactsForJob(jobURI, jobGraph);
LOGGER.debug("Done building jobs graph with {} triples", jobGraph.size());
return jobGraph;
}
use of com.thoughtworks.go.server.domain.xml.JobXmlViewModel in project gocd by gocd.
the class StageResourceImporterTest method canLoadAllStageInfoAfterImportIt.
@Test
public void canLoadAllStageInfoAfterImportIt() throws Exception {
TestFailureSetup.SavedStage savedStage = failureSetup.setupPipelineInstanceWithoutTestXmlStubbing(true, null, new Date());
Pipeline pipeline = savedStage.pipeline;
Graph graph = importer.load(savedStage.stageId, graphFactory, new XSLTTransformerRegistry());
String pipelineUrl = PipelineXmlViewModel.httpUrlForPipeline(baseUrl, pipeline.getId(), pipeline.getName());
Stage stage = savedStage.stage;
String stageUrl = new StageXmlViewModel(stage).httpUrl(baseUrl);
String jobUrl = new JobXmlViewModel(stage.getJobInstances().get(0)).httpUrl(baseUrl);
String ask = "" + "PREFIX cruise: <" + GoOntology.URI + "> " + "PREFIX xsd:<http://www.w3.org/2001/XMLSchema#> " + "ASK WHERE {" + " <" + pipelineUrl + "> a cruise:Pipeline ." + " <" + pipelineUrl + "> cruise:hasStage <" + stageUrl + "> ." + " <" + stageUrl + "> a cruise:Stage ." + " <" + stageUrl + "> cruise:hasJob <" + jobUrl + "> ." + " <" + jobUrl + "> a cruise:Job . " + "}";
assertAskIsTrue(graph, ask);
}
use of com.thoughtworks.go.server.domain.xml.JobXmlViewModel 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());
}
Aggregations