Search in sources :

Example 81 with JobInstance

use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.

the class StageSummaryModelTest method shouldRetrivePercentCompleteOnJobs.

@Test
public void shouldRetrivePercentCompleteOnJobs() throws Exception {
    JobInstance first = JobInstanceMother.completed("first", JobResult.Failed);
    Stage stage = StageMother.custom("pipeline", "stage", new JobInstances(first));
    StageSummaryModel model = new StageSummaryModel(stage, new Stages(stage), new JobDurationStrategy.ConstantJobDuration(1000 * 1000), null);
    assertThat(model.nonPassedJobs().get(0).getElapsedTime(), is(new Duration(120 * 1000)));
    assertThat(model.nonPassedJobs().get(0).getPercentComplete(), is(12));
}
Also used : JobInstance(com.thoughtworks.go.domain.JobInstance) Stages(com.thoughtworks.go.domain.Stages) Stage(com.thoughtworks.go.domain.Stage) JobDurationStrategy(com.thoughtworks.go.server.domain.JobDurationStrategy) Duration(org.joda.time.Duration) JobInstances(com.thoughtworks.go.domain.JobInstances) Test(org.junit.Test)

Example 82 with JobInstance

use of com.thoughtworks.go.domain.JobInstance 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

JobInstance (com.thoughtworks.go.domain.JobInstance)82 Test (org.junit.Test)56 Stage (com.thoughtworks.go.domain.Stage)16 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)15 Pipeline (com.thoughtworks.go.domain.Pipeline)15 JobInstances (com.thoughtworks.go.domain.JobInstances)12 JobConfigIdentifier (com.thoughtworks.go.domain.JobConfigIdentifier)7 Agent (com.thoughtworks.go.server.domain.Agent)6 Gson (com.google.gson.Gson)5 Stages (com.thoughtworks.go.domain.Stages)5 Map (java.util.Map)5 DurationBean (com.thoughtworks.go.dto.DurationBean)4 DateTime (org.joda.time.DateTime)4 ArtifactPropertiesGenerator (com.thoughtworks.go.config.ArtifactPropertiesGenerator)3 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)3 Resource (com.thoughtworks.go.config.Resource)3 DirectoryEntries (com.thoughtworks.go.domain.DirectoryEntries)3 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)3 ProjectStatus (com.thoughtworks.go.domain.activity.ProjectStatus)3 JobInstanceModel (com.thoughtworks.go.server.ui.JobInstanceModel)3