Search in sources :

Example 6 with JobInstance

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

the class RestfulServiceTest method shouldReturnLatestJobWhenMultiplePipelinesWithSameLabel.

@Test
public void shouldReturnLatestJobWhenMultiplePipelinesWithSameLabel() throws Exception {
    configHelper.setPipelineLabelTemplate(fixture.pipelineName, "label-${COUNT}");
    Pipeline pipeline = fixture.createdPipelineWithAllStagesPassed();
    Pipeline newPipeline = createPipelineWithSameLabelButNoCounter(pipeline);
    Stage stage = newPipeline.getStages().byName(fixture.devStage);
    JobInstance job = stage.getJobInstances().first();
    JobIdentifier result = restfulService.findJob(newPipeline.getName(), newPipeline.getLabel(), stage.getName(), String.valueOf(stage.getCounter()), job.getName(), null);
    JobIdentifier expect = new JobIdentifier(pipeline, stage, job);
    assertThat(result, is(expect));
}
Also used : JobInstance(com.thoughtworks.go.domain.JobInstance) Stage(com.thoughtworks.go.domain.Stage) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 7 with JobInstance

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

the class RestfulServiceTest method shouldReturnJobWithJobIdWhenSpecifyPipelineCounter.

@Test
public void shouldReturnJobWithJobIdWhenSpecifyPipelineCounter() throws Exception {
    configHelper.setPipelineLabelTemplate(fixture.pipelineName, "label-${COUNT}");
    Pipeline oldPipeline = fixture.createdPipelineWithAllStagesPassed();
    fixture.createdPipelineWithAllStagesPassed();
    Stage stage = oldPipeline.getStages().byName(fixture.devStage);
    JobInstance job = stage.getJobInstances().first();
    JobIdentifier result = restfulService.findJob(oldPipeline.getName(), String.valueOf(oldPipeline.getCounter()), stage.getName(), String.valueOf(stage.getCounter()), job.getName(), null);
    JobIdentifier expect = new JobIdentifier(oldPipeline, stage, job);
    assertThat(result, is(expect));
}
Also used : JobInstance(com.thoughtworks.go.domain.JobInstance) Stage(com.thoughtworks.go.domain.Stage) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 8 with JobInstance

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

the class RestfulServiceTest method shouldReturnJobWithLabelWhenSpecifyPipelineLabel.

@Test
public void shouldReturnJobWithLabelWhenSpecifyPipelineLabel() throws Exception {
    configHelper.setPipelineLabelTemplate(fixture.pipelineName, "label-${COUNT}");
    Pipeline pipeline = fixture.createdPipelineWithAllStagesPassed();
    Stage stage = pipeline.getStages().byName(fixture.devStage);
    JobInstance job = stage.getJobInstances().first();
    JobIdentifier result = restfulService.findJob(pipeline.getName(), pipeline.getLabel(), stage.getName(), String.valueOf(stage.getCounter()), job.getName(), job.getId());
    JobIdentifier expect = new JobIdentifier(pipeline, stage, job);
    assertThat(result, is(expect));
}
Also used : JobInstance(com.thoughtworks.go.domain.JobInstance) Stage(com.thoughtworks.go.domain.Stage) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 9 with JobInstance

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

the class PipelineBuilder method addJob.

public void addJob(String jobName) {
    JobInstance instance = new JobInstance(jobName, null, new TimeProvider());
    currentStage().getJobInstances().add(instance);
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) JobInstance(com.thoughtworks.go.domain.JobInstance)

Example 10 with JobInstance

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

the class JobDetailPresentationModelTest method shouldAddFakeConsoleOutputEntryIfJobIsNotCompleted.

@Test
public void shouldAddFakeConsoleOutputEntryIfJobIsNotCompleted() throws Exception {
    JobInstance job = building("job");
    JobDetailPresentationModel model = new JobDetailPresentationModel(job, null, null, null, null, null, artifactsService, null, custom("stage"));
    when(artifactsService.findArtifact(job.getIdentifier(), "")).thenReturn(mock(File.class));
    when(artifactsService.findArtifactUrl(job.getIdentifier(), getConsoleOutputFolderAndFileName())).thenReturn("path/to/console");
    when(directoryReader.listEntries(any(File.class), eq(""))).thenReturn(new DirectoryEntries());
    DirectoryEntries expected = new DirectoryEntries();
    expected.addFolder("cruise-output").addFile("console.log", "path/to/console");
    assertThat(model.getArtifactFiles(directoryReader), is(expected));
}
Also used : DirectoryEntries(com.thoughtworks.go.domain.DirectoryEntries) JobInstance(com.thoughtworks.go.domain.JobInstance) File(java.io.File) Test(org.junit.Test)

Aggregations

JobInstance (com.thoughtworks.go.domain.JobInstance)90 Test (org.junit.Test)65 Stage (com.thoughtworks.go.domain.Stage)23 Pipeline (com.thoughtworks.go.domain.Pipeline)22 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)16 JobInstances (com.thoughtworks.go.domain.JobInstances)11 JobConfigIdentifier (com.thoughtworks.go.domain.JobConfigIdentifier)10 Stages (com.thoughtworks.go.domain.Stages)5 JsonTester (com.thoughtworks.go.util.JsonTester)5 Map (java.util.Map)5 ModelAndView (org.springframework.web.servlet.ModelAndView)5 AgentConfig (com.thoughtworks.go.config.AgentConfig)4 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)4 Date (java.util.Date)4 ArtifactPropertiesGenerator (com.thoughtworks.go.config.ArtifactPropertiesGenerator)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 StageDao (com.thoughtworks.go.server.dao.StageDao)3