use of com.thoughtworks.go.domain.StageConfigIdentifier in project gocd by gocd.
the class StageNotificationServiceTest method prepareOneMatchedUser.
private String prepareOneMatchedUser() {
String jezMail = "jez@cruise.com";
User jez = new User("jez", new String[] { "lgao" }, jezMail, true);
jez.setNotificationFilters(Arrays.asList(new NotificationFilter("go", "dev", StageEvent.All, true)));
when(userService.findValidSubscribers(new StageConfigIdentifier("go", "dev"))).thenReturn(new Users(Arrays.asList(jez)));
return jezMail;
}
use of com.thoughtworks.go.domain.StageConfigIdentifier in project gocd by gocd.
the class StageStatusCache method stageStatusChanged.
public void stageStatusChanged(Stage stage) {
StageConfigIdentifier configIdentifier = stage.getIdentifier().stageConfigIdentifier();
stages.put(configIdentifier, stage);
}
use of com.thoughtworks.go.domain.StageConfigIdentifier in project gocd by gocd.
the class StageStatusCacheTest method shouldLoadMostRecentInstanceFromDBOnlyOnce.
@Test
public void shouldLoadMostRecentInstanceFromDBOnlyOnce() throws SQLException {
Mockery mockery = new Mockery();
final StageDao mock = mockery.mock(StageDao.class);
final StageConfigIdentifier identifier = new StageConfigIdentifier("cruise", "dev");
final Stage instance = StageMother.failingStage("dev");
mockery.checking(new Expectations() {
{
one(mock).mostRecentStage(identifier);
will(returnValue(instance));
}
});
StageStatusCache cache = new StageStatusCache(mock);
assertThat(cache.currentStage(identifier).getName(), is(instance.getName()));
//call currentStage for the second time, should not call stageDao now
assertThat(cache.currentStage(identifier).getName(), is(instance.getName()));
}
use of com.thoughtworks.go.domain.StageConfigIdentifier in project gocd by gocd.
the class StageStatusCacheTest method shouldRemoveNeverBeenBuiltWhenTheStageIsBuiltForTheFirstTime.
@Test
public void shouldRemoveNeverBeenBuiltWhenTheStageIsBuiltForTheFirstTime() throws SQLException {
final StageDao stageDao = Mockito.mock(StageDao.class);
final StageConfigIdentifier identifier = new StageConfigIdentifier("cruise", "dev");
final Stage instance = StageMother.failingStage("dev");
instance.setIdentifier(new StageIdentifier("cruise", 1, "dev", "1"));
when(stageDao.mostRecentStage(identifier)).thenReturn(null);
StageStatusCache cache = new StageStatusCache(stageDao);
assertThat(cache.currentStage(identifier), is(nullValue()));
cache.stageStatusChanged(instance);
assertThat(cache.currentStage(identifier), is(instance));
verify(stageDao, times(1)).mostRecentStage(identifier);
}
use of com.thoughtworks.go.domain.StageConfigIdentifier in project gocd by gocd.
the class ScheduleStageTest method shouldRerunStageUsingPipelineCounter.
@Test
public void shouldRerunStageUsingPipelineCounter() throws Exception {
Pipeline pipeline = fixture.createdPipelineWithAllStagesPassed();
Stage oldStage = pipeline.getStages().byName(fixture.devStage);
scheduleService.rerunStage(pipeline.getName(), String.valueOf(pipeline.getCounter()), fixture.devStage);
Stage stage = dbHelper.getStageDao().mostRecentStage(new StageConfigIdentifier(pipeline.getName(), fixture.devStage));
assertThat(stage.getCounter(), is(oldStage.getCounter() + 1));
}
Aggregations