use of com.thoughtworks.go.server.ui.StageSummaryModels in project gocd by gocd.
the class StageServiceIntegrationTest method findStageHistoryForChart_shouldNotRetrieveCancelledStagesAndStagesWithRerunJobs.
@Test
public void findStageHistoryForChart_shouldNotRetrieveCancelledStagesAndStagesWithRerunJobs() throws Exception {
PipelineConfig pipelineConfig = configFileHelper.addPipeline("pipeline-1", "stage-1");
configFileHelper.turnOffSecurity();
Pipeline pipeline = dbHelper.schedulePipelineWithAllStages(pipelineConfig, ModificationsMother.modifySomeFiles(pipelineConfig));
dbHelper.pass(pipeline);
StageSummaryModels stages = stageService.findStageHistoryForChart(pipelineConfig.name().toString(), pipelineConfig.first().name().toString(), 1, 10, new Username(new CaseInsensitiveString("loser")));
assertThat(stages.size(), is(1));
scheduleService.rerunJobs(pipeline.getFirstStage(), Arrays.asList(CaseInsensitiveString.str(pipelineConfig.first().getJobs().first().name())), new HttpOperationResult());
stages = stageService.findStageHistoryForChart(pipelineConfig.name().toString(), pipelineConfig.first().name().toString(), 1, 10, new Username(new CaseInsensitiveString("loser")));
// should not retrieve stages with rerun jobs
assertThat(stages.size(), is(1));
pipeline = dbHelper.schedulePipelineWithAllStages(pipelineConfig, ModificationsMother.modifySomeFiles(pipelineConfig));
dbHelper.cancelStage(pipeline.getFirstStage());
stages = stageService.findStageHistoryForChart(pipelineConfig.name().toString(), pipelineConfig.first().name().toString(), 1, 10, new Username(new CaseInsensitiveString("loser")));
// should not retrieve cancelled stages
assertThat(stages.size(), is(1));
}
use of com.thoughtworks.go.server.ui.StageSummaryModels in project gocd by gocd.
the class StageServiceIntegrationTest method findStageHistoryForChart_shouldFindLatestStageInstancesForChart.
@Test
public void findStageHistoryForChart_shouldFindLatestStageInstancesForChart() throws Exception {
PipelineConfig pipelineConfig = configFileHelper.addPipeline("pipeline-1", "stage-1");
configFileHelper.turnOffSecurity();
List<Pipeline> completedPipelines = new ArrayList<>();
Pipeline pipeline;
for (int i = 0; i < 16; i++) {
pipeline = dbHelper.schedulePipelineWithAllStages(pipelineConfig, ModificationsMother.modifySomeFiles(pipelineConfig));
dbHelper.pass(pipeline);
completedPipelines.add(pipeline);
}
StageSummaryModels stages = stageService.findStageHistoryForChart(pipelineConfig.name().toString(), pipelineConfig.first().name().toString(), 1, 4, new Username(new CaseInsensitiveString("loser")));
assertThat(stages.size(), is(4));
assertThat(stages.get(0).getIdentifier().getPipelineCounter(), is(16));
stages = stageService.findStageHistoryForChart(pipelineConfig.name().toString(), pipelineConfig.first().name().toString(), 3, 4, new Username(new CaseInsensitiveString("loser")));
assertThat(stages.size(), is(4));
assertThat(stages.get(0).getIdentifier().getPipelineCounter(), is(8));
assertThat(stages.getPagination().getTotalPages(), is(4));
}
use of com.thoughtworks.go.server.ui.StageSummaryModels 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