Search in sources :

Example 1 with JobXmlViewModel

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())));
}
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 2 with JobXmlViewModel

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;
}
Also used : Graph(com.thoughtworks.studios.shine.semweb.Graph) URIReference(com.thoughtworks.studios.shine.semweb.URIReference) JobXmlViewModel(com.thoughtworks.go.server.domain.xml.JobXmlViewModel)

Example 3 with JobXmlViewModel

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);
}
Also used : 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) XSLTTransformerRegistry(com.thoughtworks.studios.shine.semweb.grddl.XSLTTransformerRegistry) Date(java.util.Date) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 4 with JobXmlViewModel

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

JobXmlViewModel (com.thoughtworks.go.server.domain.xml.JobXmlViewModel)4 Graph (com.thoughtworks.studios.shine.semweb.Graph)4 Test (org.junit.Test)3 Pipeline (com.thoughtworks.go.domain.Pipeline)2 Stage (com.thoughtworks.go.domain.Stage)2 TestFailureSetup (com.thoughtworks.go.server.dao.sparql.TestFailureSetup)2 StageXmlViewModel (com.thoughtworks.go.server.domain.xml.StageXmlViewModel)2 Date (java.util.Date)2 JobInstance (com.thoughtworks.go.domain.JobInstance)1 Modification (com.thoughtworks.go.domain.materials.Modification)1 URIReference (com.thoughtworks.studios.shine.semweb.URIReference)1 XSLTTransformerRegistry (com.thoughtworks.studios.shine.semweb.grddl.XSLTTransformerRegistry)1 InMemoryTempGraphFactory (com.thoughtworks.studios.shine.semweb.sesame.InMemoryTempGraphFactory)1 Document (org.dom4j.Document)1