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