Search in sources :

Example 1 with StageConfigIdentifier

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;
}
Also used : User(com.thoughtworks.go.domain.User) StageConfigIdentifier(com.thoughtworks.go.domain.StageConfigIdentifier) Matchers.anyString(org.mockito.Matchers.anyString) StringContains.containsString(org.hamcrest.core.StringContains.containsString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Users(com.thoughtworks.go.domain.Users) NotificationFilter(com.thoughtworks.go.domain.NotificationFilter)

Example 2 with StageConfigIdentifier

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

Example 3 with StageConfigIdentifier

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

Example 4 with StageConfigIdentifier

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

Example 5 with StageConfigIdentifier

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