use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.
the class RestfulServiceTest method shouldShouldTranslateLatestPipelineLabel.
@Test
public void shouldShouldTranslateLatestPipelineLabel() throws Exception {
fixture.createdPipelineWithAllStagesPassed();
Pipeline latestPipleine = fixture.createdPipelineWithAllStagesPassed();
final JobIdentifier jobIdentifier1 = new JobIdentifier(latestPipleine.getName(), JobIdentifier.LATEST, fixture.devStage, JobIdentifier.LATEST, PipelineWithTwoStages.JOB_FOR_DEV_STAGE);
JobIdentifier jobIdentifier = restfulService.findJob(jobIdentifier1.getPipelineName(), jobIdentifier1.getPipelineLabel(), jobIdentifier1.getStageName(), jobIdentifier1.getStageCounter(), jobIdentifier1.getBuildName());
assertThat(jobIdentifier.getPipelineLabel(), is(latestPipleine.getLabel()));
}
use of com.thoughtworks.go.domain.JobIdentifier 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.JobIdentifier 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.JobIdentifier in project gocd by gocd.
the class RestfulServiceTest method canSupportQueryingUsingStageNameWithDifferentCase.
@Test
public void canSupportQueryingUsingStageNameWithDifferentCase() throws Exception {
Pipeline pipeline = fixture.createdPipelineWithAllStagesPassed();
JobIdentifier jobIdentifier = restfulService.findJob(pipeline.getName(), pipeline.getLabel(), fixture.devStage.toUpperCase(), "", PipelineWithTwoStages.JOB_FOR_DEV_STAGE);
assertThat(jobIdentifier.getStageName(), is(fixture.devStage));
}
use of com.thoughtworks.go.domain.JobIdentifier in project gocd by gocd.
the class ScheduleServiceCachedIntegrationTest method shouldUpdateResultOfStageWhenJobCompletes_irrespectiveOfOtherThreadsPrimingStageCache.
@Test
public void shouldUpdateResultOfStageWhenJobCompletes_irrespectiveOfOtherThreadsPrimingStageCache() throws Exception {
Pipeline assigned = preCondition.createPipelineWithFirstStageAssigned();
Stage stage = assigned.findStage(preCondition.devStage);
StageSummaryModel model = stageService.findStageSummaryByIdentifier(stage.getIdentifier(), new Username(new CaseInsensitiveString("foo")), new HttpLocalizedOperationResult());
JobIdentifier identifier = stage.getFirstJob().getIdentifier();
scheduleService.updateJobStatus(identifier, JobState.Building);
scheduleService.jobCompleting(identifier, JobResult.Passed, "uuid");
//priming the cache
Stage stageLoadedByOtherFlows = stageDao.stageById(stage.getId());
scheduleService.updateJobStatus(stage.getFirstJob().getIdentifier(), JobState.Completed);
StageSummaryModel reloadedModel = stageService.findStageSummaryByIdentifier(stage.getIdentifier(), new Username(new CaseInsensitiveString("foo")), new HttpLocalizedOperationResult());
Stage reloadedStage = reloadedModel.getStage();
assertThat(reloadedStage.getFirstJob().getState(), is(JobState.Completed));
assertThat(reloadedStage.getCompletedByTransitionId(), is(reloadedStage.getFirstJob().getTransitions().byState(JobState.Completed).getId()));
assertThat(reloadedStage.getResult(), is(StageResult.Passed));
assertThat(reloadedStage.getState(), is(StageState.Passed));
}
Aggregations