Search in sources :

Example 1 with StageSummaryModels

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));
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) Username(com.thoughtworks.go.server.domain.Username) StageSummaryModels(com.thoughtworks.go.server.ui.StageSummaryModels) Test(org.junit.jupiter.api.Test)

Example 2 with StageSummaryModels

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));
}
Also used : Username(com.thoughtworks.go.server.domain.Username) ArrayList(java.util.ArrayList) StageSummaryModels(com.thoughtworks.go.server.ui.StageSummaryModels) Test(org.junit.jupiter.api.Test)

Example 3 with StageSummaryModels

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;
}
Also used : Pagination(com.thoughtworks.go.server.util.Pagination) StageSummaryModel(com.thoughtworks.go.server.ui.StageSummaryModel) StageSummaryModels(com.thoughtworks.go.server.ui.StageSummaryModels)

Aggregations

StageSummaryModels (com.thoughtworks.go.server.ui.StageSummaryModels)3 Username (com.thoughtworks.go.server.domain.Username)2 Test (org.junit.jupiter.api.Test)2 HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)1 StageSummaryModel (com.thoughtworks.go.server.ui.StageSummaryModel)1 Pagination (com.thoughtworks.go.server.util.Pagination)1 ArrayList (java.util.ArrayList)1