Search in sources :

Example 6 with StageConfigIdentifier

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()));
}
Also used : StageConfigIdentifier(com.thoughtworks.go.domain.StageConfigIdentifier) StageEvent(com.thoughtworks.go.domain.StageEvent)

Example 7 with StageConfigIdentifier

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);
}
Also used : StageDao(com.thoughtworks.go.server.dao.StageDao) StageConfigIdentifier(com.thoughtworks.go.domain.StageConfigIdentifier) Test(org.junit.Test)

Example 8 with StageConfigIdentifier

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));
}
Also used : StageConfigIdentifier(com.thoughtworks.go.domain.StageConfigIdentifier) StageResult(com.thoughtworks.go.domain.StageResult) Test(org.junit.Test)

Example 9 with StageConfigIdentifier

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));
}
Also used : StageConfigIdentifier(com.thoughtworks.go.domain.StageConfigIdentifier) Test(org.junit.Test)

Example 10 with StageConfigIdentifier

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));
}
Also used : StageConfigIdentifier(com.thoughtworks.go.domain.StageConfigIdentifier) Test(org.junit.Test)

Aggregations

StageConfigIdentifier (com.thoughtworks.go.domain.StageConfigIdentifier)11 Test (org.junit.Test)8 Stage (com.thoughtworks.go.domain.Stage)4 StageDao (com.thoughtworks.go.server.dao.StageDao)3 Pipeline (com.thoughtworks.go.domain.Pipeline)2 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 NotificationFilter (com.thoughtworks.go.domain.NotificationFilter)1 StageEvent (com.thoughtworks.go.domain.StageEvent)1 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)1 StageResult (com.thoughtworks.go.domain.StageResult)1 User (com.thoughtworks.go.domain.User)1 Users (com.thoughtworks.go.domain.Users)1 StringContains.containsString (org.hamcrest.core.StringContains.containsString)1 Expectations (org.jmock.Expectations)1 Mockery (org.jmock.Mockery)1 Matchers.anyString (org.mockito.Matchers.anyString)1