use of com.thoughtworks.go.domain.StageConfigIdentifier in project gocd by gocd.
the class StageResultCache method onMessage.
public void onMessage(StageStatusMessage message) {
StageConfigIdentifier identifier = message.getStageIdentifier().stageConfigIdentifier();
updateCache(identifier, message.getStageResult());
StageEvent event = message.getStageResult().describeChangeEvent(previousResult(identifier));
stageResultTopic.post(new StageResultMessage(message.getStageIdentifier(), event, message.username()));
}
use of com.thoughtworks.go.domain.StageConfigIdentifier in project gocd by gocd.
the class StageStatusCacheTest method shouldQueryTheDbOnlyOnceForStagesThatHaveNeverBeenBuilt.
@Test
public void shouldQueryTheDbOnlyOnceForStagesThatHaveNeverBeenBuilt() throws SQLException {
final StageDao stageDao = Mockito.mock(StageDao.class);
final StageConfigIdentifier identifier = new StageConfigIdentifier("cruise", "dev");
StageStatusCache cache = new StageStatusCache(stageDao);
when(stageDao.mostRecentStage(identifier)).thenReturn(null);
assertThat(cache.currentStage(identifier), is(nullValue()));
assertThat(cache.currentStage(identifier), is(nullValue()));
verify(stageDao, times(1)).mostRecentStage(identifier);
}
use of com.thoughtworks.go.domain.StageConfigIdentifier 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.StageConfigIdentifier in project gocd by gocd.
the class StageResultCacheTest method shouldReturnUnknownForStageWithNoHistory.
@Test
public void shouldReturnUnknownForStageWithNoHistory() {
StageConfigIdentifier stage = new StageConfigIdentifier("cruise", "dev");
assertThat(stageResultCache.previousResult(stage), is(StageResult.Unknown));
stageResultCache.updateCache(stage, StageResult.Passed);
assertThat(stageResultCache.previousResult(stage), is(StageResult.Unknown));
}
use of com.thoughtworks.go.domain.StageConfigIdentifier in project gocd by gocd.
the class StageResultCacheTest method shouldUpdatePreviousResultWhenNewResultComeIn.
@Test
public void shouldUpdatePreviousResultWhenNewResultComeIn() {
StageConfigIdentifier stage = new StageConfigIdentifier("cruise", "dev");
stageResultCache.updateCache(stage, StageResult.Failed);
stageResultCache.updateCache(stage, StageResult.Passed);
assertThat(stageResultCache.previousResult(stage), is(StageResult.Failed));
}
Aggregations