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);
}
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));
}
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;
}
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;
}
Aggregations