Search in sources :

Example 1 with StageResult

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

the class StageResultTypeHandlerCallbackTest method assertMaps.

private void assertMaps(final String str, StageResult value) throws SQLException {
    final ResultGetter resultGetter;
    Mockery context = new Mockery() {

        {
            setImposteriser(ClassImposteriser.INSTANCE);
        }
    };
    resultGetter = context.mock(ResultGetter.class);
    context.checking(new Expectations() {

        {
            one(resultGetter).getString();
            will(returnValue(str));
        }
    });
    StageResult result = (StageResult) callback.getResult(resultGetter);
    assertThat(result, is(equal(value)));
    final ParameterSetter parameterSetter = context.mock(ParameterSetter.class);
    context.checking(new Expectations() {

        {
            one(parameterSetter).setString(str);
        }
    });
    callback.setParameter(parameterSetter, value);
}
Also used : Expectations(org.jmock.Expectations) StageResult(com.thoughtworks.go.domain.StageResult) ParameterSetter(com.ibatis.sqlmap.client.extensions.ParameterSetter) ResultGetter(com.ibatis.sqlmap.client.extensions.ResultGetter) Mockery(org.jmock.Mockery)

Example 2 with StageResult

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

the class StageResultCacheTest method shouldLoadStageResultFromDBWhenNoGivenStageInCache.

@Test
public void shouldLoadStageResultFromDBWhenNoGivenStageInCache() {
    pipelineFixture.createdPipelineWithAllStagesPassed();
    StageConfigIdentifier stage = new StageConfigIdentifier(pipelineFixture.pipelineName, pipelineFixture.ftStage);
    stageResultCache.updateCache(stage, StageResult.Failed);
    StageResult stageResult = stageResultCache.previousResult(stage);
    assertThat(stageResult, is(StageResult.Passed));
}
Also used : StageConfigIdentifier(com.thoughtworks.go.domain.StageConfigIdentifier) StageResult(com.thoughtworks.go.domain.StageResult) Test(org.junit.Test)

Example 3 with StageResult

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

the class StageResultCache method currentResult.

private StageResult currentResult(StageConfigIdentifier identifier) {
    StageResult stageResult = currentResults.get(identifier);
    if (stageResult == null) {
        Stage stage = stageDao.mostRecentCompleted(identifier);
        if (stage != null) {
            stageResult = stage.getResult();
            currentResults.put(identifier, stageResult);
        }
    }
    return stageResult == null ? StageResult.Unknown : stageResult;
}
Also used : StageResult(com.thoughtworks.go.domain.StageResult) Stage(com.thoughtworks.go.domain.Stage)

Example 4 with StageResult

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

the class SchedulingCheckerService method shouldAllowSchedulingStage.

ScheduleStageResult shouldAllowSchedulingStage(Pipeline pipeline, String stageName) {
    if (pipeline == null) {
        return ScheduleStageResult.PipelineNotFound;
    }
    if (pipeline.hasStageBeenRun(stageName)) {
        return ScheduleStageResult.CanSchedule;
    }
    String pipelineName = pipeline.getName();
    if (!goConfigService.hasPreviousStage(pipelineName, stageName)) {
        return ScheduleStageResult.CanSchedule;
    }
    CaseInsensitiveString previousStageName = goConfigService.previousStage(pipelineName, stageName).name();
    if (!pipeline.hasStageBeenRun(CaseInsensitiveString.str(previousStageName))) {
        return ScheduleStageResult.PreviousStageNotRan;
    }
    StageConfig currentStageConfig = goConfigService.nextStage(pipelineName, previousStageName.toString());
    Approval approval = currentStageConfig.getApproval();
    if (approval.isAllowOnlyOnSuccess()) {
        Stage previousStage = pipeline.getStages().byName(previousStageName.toString());
        StageResult previousStageResult = previousStage.getResult();
        if (previousStageResult != StageResult.Passed) {
            return ScheduleStageResult.PreviousStageNotPassed.setPreviousStageValues(previousStageName.toString(), previousStageResult.name());
        }
    }
    return ScheduleStageResult.CanSchedule;
}
Also used : StageResult(com.thoughtworks.go.domain.StageResult) Stage(com.thoughtworks.go.domain.Stage) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Approval(com.thoughtworks.go.config.Approval) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) StageConfig(com.thoughtworks.go.config.StageConfig)

Aggregations

StageResult (com.thoughtworks.go.domain.StageResult)4 Stage (com.thoughtworks.go.domain.Stage)2 ParameterSetter (com.ibatis.sqlmap.client.extensions.ParameterSetter)1 ResultGetter (com.ibatis.sqlmap.client.extensions.ResultGetter)1 Approval (com.thoughtworks.go.config.Approval)1 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 StageConfig (com.thoughtworks.go.config.StageConfig)1 StageConfigIdentifier (com.thoughtworks.go.domain.StageConfigIdentifier)1 Expectations (org.jmock.Expectations)1 Mockery (org.jmock.Mockery)1 Test (org.junit.Test)1