Search in sources :

Example 46 with StageIdentifier

use of com.thoughtworks.go.domain.StageIdentifier in project gocd by gocd.

the class PipelineHistoryMother method stagePerJob.

public static StageInstanceModels stagePerJob(String baseName, List<JobHistory> histories) {
    StageInstanceModels stageInstanceModels = new StageInstanceModels();
    for (int i = 0; i < histories.size(); i++) {
        String stageName = baseName + "-" + i;
        StageInstanceModel stage = new StageInstanceModel(stageName, "1", StageResult.Passed, new StageIdentifier("pipeline", 1, "1", stageName, "1"));
        stage.setBuildHistory(histories.get(i));
        stageInstanceModels.add(stage);
        stageInstanceModels.latestStage().setApprovedBy("cruise");
    }
    return stageInstanceModels;
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) StageInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) StageInstanceModel(com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel)

Example 47 with StageIdentifier

use of com.thoughtworks.go.domain.StageIdentifier in project gocd by gocd.

the class ShineDao method failedBuildHistoryForStage.

public StageTestRuns failedBuildHistoryForStage(StageIdentifier stageId, LocalizedOperationResult result) {
    try {
        StageTestRuns stageTestRuns = getTestCount(stageId);
        List<StageIdentifier> failedStageIds = stageService.findRunForStage(stageId);
        populateFailingTests(stageTestRuns, getFailedTests(failedStageIds));
        populateUsers(stageTestRuns, getCommitters(failedStageIds));
        stageTestRuns.removeDuplicateTestEntries();
        return stageTestRuns;
    } catch (RuntimeException e) {
        LOGGER.error("can not retrieve shine test history!", e);
        result.connectionError(LocalizedMessage.unableToRetrieveFailureResults());
        return new StageTestRuns(0, 0, 0);
    }
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) StageTestRuns(com.thoughtworks.go.domain.testinfo.StageTestRuns)

Example 48 with StageIdentifier

use of com.thoughtworks.go.domain.StageIdentifier in project gocd by gocd.

the class MaterialDatabaseDependencyUpdaterTest method stubStageServiceGetHistoryAfter.

private void stubStageServiceGetHistoryAfter(DependencyMaterial material, int pipelineCounter, Stages... stageses) {
    if (material == null) {
        material = new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name"));
    }
    StageIdentifier identifier = new StageIdentifier(String.format("%s/%s/%s/0", material.getPipelineName().toString(), pipelineCounter, material.getStageName().toString()));
    for (int i = 0; i < stageses.length; i++) {
        Stages stages = stageses[i];
        List<Modification> mods = new ArrayList<>();
        for (Stage stage : stages) {
            StageIdentifier id = stage.getIdentifier();
            mods.add(new Modification(stage.completedDate(), id.stageLocator(), id.getPipelineLabel(), stage.getPipelineId()));
        }
        Mockito.when(dependencyMaterialSourceDao.getPassedStagesAfter(identifier.stageLocator(), material, Pagination.pageStartingAt(i * MaterialDatabaseUpdater.STAGES_PER_PAGE, null, MaterialDatabaseUpdater.STAGES_PER_PAGE))).thenReturn(mods);
    }
    when(dependencyMaterialSourceDao.getPassedStagesAfter(identifier.stageLocator(), material, Pagination.pageStartingAt(MaterialDatabaseUpdater.STAGES_PER_PAGE * stageses.length, null, MaterialDatabaseUpdater.STAGES_PER_PAGE))).thenReturn(new ArrayList<>());
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) Modification(com.thoughtworks.go.domain.materials.Modification) Stages(com.thoughtworks.go.domain.Stages) ArrayList(java.util.ArrayList) Stage(com.thoughtworks.go.domain.Stage) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 49 with StageIdentifier

use of com.thoughtworks.go.domain.StageIdentifier in project gocd by gocd.

the class MaterialDatabaseDependencyUpdaterTest method stubStageServiceGetHistory.

private void stubStageServiceGetHistory(DependencyMaterial dependencyMaterial, Stages... stageses) {
    if (material == null) {
        dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name"));
    }
    for (int i = 0; i < stageses.length; i++) {
        ArrayList<Modification> mods = new ArrayList<>();
        for (Stage stage : stageses[i]) {
            StageIdentifier id = stage.getIdentifier();
            mods.add(new Modification(stage.completedDate(), id.stageLocator(), id.getPipelineLabel(), stage.getPipelineId()));
        }
        Mockito.when(dependencyMaterialSourceDao.getPassedStagesByName(dependencyMaterial, Pagination.pageStartingAt(i * MaterialDatabaseUpdater.STAGES_PER_PAGE, null, MaterialDatabaseUpdater.STAGES_PER_PAGE))).thenReturn(mods);
    }
    Mockito.when(dependencyMaterialSourceDao.getPassedStagesByName(dependencyMaterial, Pagination.pageStartingAt(MaterialDatabaseUpdater.STAGES_PER_PAGE * stageses.length, null, MaterialDatabaseUpdater.STAGES_PER_PAGE))).thenReturn(new ArrayList<>());
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) ArrayList(java.util.ArrayList) Stage(com.thoughtworks.go.domain.Stage) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 50 with StageIdentifier

use of com.thoughtworks.go.domain.StageIdentifier in project gocd by gocd.

the class MaterialDatabaseDependencyUpdaterTest method stage.

private Stage stage(int pipelineCounter) {
    Stage stage = new Stage();
    stage.setIdentifier(new StageIdentifier("pipeline-name", pipelineCounter, "LABEL-" + pipelineCounter, "stage-name", "0"));
    return stage;
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) Stage(com.thoughtworks.go.domain.Stage)

Aggregations

StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)58 Test (org.junit.Test)30 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)12 Pipeline (com.thoughtworks.go.domain.Pipeline)10 Stage (com.thoughtworks.go.domain.Stage)9 StageInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel)6 ArrayList (java.util.ArrayList)6 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)5 PipelineState (com.thoughtworks.go.domain.PipelineState)5 Modification (com.thoughtworks.go.domain.materials.Modification)5 StageInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels)5 Username (com.thoughtworks.go.server.domain.Username)4 Date (java.util.Date)4 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)3 JobInstance (com.thoughtworks.go.domain.JobInstance)3 PipelineDependencyGraphOld (com.thoughtworks.go.domain.PipelineDependencyGraphOld)3 PipelineIdentifier (com.thoughtworks.go.domain.PipelineIdentifier)3 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)3 PipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel)3 HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)3