use of com.thoughtworks.go.server.ui.StageSummaryModel 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));
}
use of com.thoughtworks.go.server.ui.StageSummaryModel in project gocd by gocd.
the class ScheduleServiceCachedIntegrationTest method shouldUpdateResultOfStageWhenJobCompletes.
@Test
public void shouldUpdateResultOfStageWhenJobCompletes() throws Exception {
// ScheduleService service = new ScheduleService(goConfigService, pipelineService, stageService, currentActivityService, schedulingChecker, pipelineScheduledTopic, pipelineDao,
// stageDao, stageOrderService, securityService, pipelineScheduleQueue, jobInstanceService, jobInstanceDao, agentAssignment, environmentConfigService,
// pipelineLockService, serverHealthService, transactionTemplate, agentService);
Pipeline assigned = preCondition.createPipelineWithFirstStageAssigned();
Stage stage = assigned.findStage(preCondition.devStage);
StageSummaryModel model = stageService.findStageSummaryByIdentifier(stage.getIdentifier(), new Username(new CaseInsensitiveString("foo")), new HttpLocalizedOperationResult());
assertThat(model.getStage().getFirstJob().getState(), is(JobState.Assigned));
scheduleService.updateJobStatus(stage.getFirstJob().getIdentifier(), JobState.Building);
StageSummaryModel reloadedModel = stageService.findStageSummaryByIdentifier(stage.getIdentifier(), new Username(new CaseInsensitiveString("foo")), new HttpLocalizedOperationResult());
assertThat(reloadedModel.getStage().getFirstJob().getState(), is(JobState.Building));
}
use of com.thoughtworks.go.server.ui.StageSummaryModel in project gocd by gocd.
the class StageService method findStageSummaryByIdentifier.
public StageSummaryModel findStageSummaryByIdentifier(StageIdentifier stageId, Username username, LocalizedOperationResult result) {
if (!securityService.hasViewPermissionForPipeline(username, stageId.getPipelineName())) {
result.unauthorized(LocalizedMessage.cannotViewPipeline(stageId.getPipelineName()), HealthStateType.general(HealthStateScope.forPipeline(stageId.getPipelineName())));
return null;
}
Stages stages = stageDao.getAllRunsOfStageForPipelineInstance(stageId.getPipelineName(), stageId.getPipelineCounter(), stageId.getStageName());
for (Stage stage : stages) {
if (stage.getIdentifier().getStageCounter().equals(stageId.getStageCounter())) {
StageSummaryModel summaryModel = new StageSummaryModel(stage, stages, stageDao, null);
return summaryModel;
}
}
result.notFound(LocalizedMessage.stageNotFound(stageId), HealthStateType.general(HealthStateScope.GLOBAL));
return null;
}
use of com.thoughtworks.go.server.ui.StageSummaryModel in project gocd by gocd.
the class StageService method findStageHistoryForChart.
public StageSummaryModels findStageHistoryForChart(String pipelineName, String stageName, int pageNumber, int pageSize, Username username) {
int total = stageDao.getTotalStageCountForChart(pipelineName, stageName);
Pagination pagination = Pagination.pageByNumber(pageNumber, total, pageSize);
List<Stage> stages = stageDao.findStageHistoryForChart(pipelineName, stageName, pageSize, pagination.getOffset());
StageSummaryModels stageSummaryModels = new StageSummaryModels();
for (Stage forStage : stages) {
StageSummaryModel stageSummaryByIdentifier = new StageSummaryModel(forStage, null, stageDao, forStage.getIdentifier());
if (!stageSummaryByIdentifier.getStage().getState().completed()) {
continue;
}
stageSummaryModels.add(stageSummaryByIdentifier);
}
stageSummaryModels.setPagination(pagination);
return stageSummaryModels;
}
Aggregations