Search in sources :

Example 11 with StageDao

use of com.thoughtworks.go.server.dao.StageDao in project gocd by gocd.

the class JobStatusCacheTest method shouldRemoveTheNeverRunInstanceWhenTheJobRunsForTheFirstTime.

@Test
public void shouldRemoveTheNeverRunInstanceWhenTheJobRunsForTheFirstTime() {
    StageDao dao = mock(StageDao.class);
    when(dao.mostRecentJobsForStage("cruise", "dev")).thenReturn(new ArrayList<>());
    JobStatusCache cache = new JobStatusCache(dao);
    assertThat(cache.currentJobs(new JobConfigIdentifier("cruise", "dev", "linux-firefox")).isEmpty(), is(true));
    JobInstance instance = jobInstance("linux-firefox");
    cache.jobStatusChanged(instance);
    assertThat(cache.currentJobs(new JobConfigIdentifier("cruise", "dev", "linux-firefox")).get(0), is(instance));
    Mockito.verify(dao, times(1)).mostRecentJobsForStage("cruise", "dev");
}
Also used : StageDao(com.thoughtworks.go.server.dao.StageDao) Test(org.junit.Test)

Example 12 with StageDao

use of com.thoughtworks.go.server.dao.StageDao 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) Test(org.junit.Test)

Example 13 with StageDao

use of com.thoughtworks.go.server.dao.StageDao in project gocd by gocd.

the class StageServiceTest method setUp.

@Before
public void setUp() throws Exception {
    stageDao = mock(StageDao.class);
    pipelineDao = mock(PipelineDao.class);
    jobInstanceService = mock(JobInstanceService.class);
    securityService = mock(SecurityService.class);
    cruiseConfig = mock(BasicCruiseConfig.class);
    goConfigService = mock(GoConfigService.class);
    changesetService = mock(ChangesetService.class);
    goCache = mock(GoCache.class);
    transactionSynchronizationManager = new TestTransactionSynchronizationManager();
    transactionTemplate = new TestTransactionTemplate(transactionSynchronizationManager);
}
Also used : StageDao(com.thoughtworks.go.server.dao.StageDao) TestTransactionTemplate(com.thoughtworks.go.server.transaction.TestTransactionTemplate) GoCache(com.thoughtworks.go.server.cache.GoCache) PipelineDao(com.thoughtworks.go.server.dao.PipelineDao) TestTransactionSynchronizationManager(com.thoughtworks.go.server.transaction.TestTransactionSynchronizationManager) Before(org.junit.Before)

Aggregations

StageDao (com.thoughtworks.go.server.dao.StageDao)13 Test (org.junit.Test)10 PipelineDao (com.thoughtworks.go.server.dao.PipelineDao)3 Pipeline (com.thoughtworks.go.domain.Pipeline)2 Stage (com.thoughtworks.go.domain.Stage)2 JobStatusCache (com.thoughtworks.go.domain.activity.JobStatusCache)2 StageStatusCache (com.thoughtworks.go.domain.activity.StageStatusCache)2 JobInstanceDao (com.thoughtworks.go.server.dao.JobInstanceDao)2 StageStatusListener (com.thoughtworks.go.server.domain.StageStatusListener)2 JobResultTopic (com.thoughtworks.go.server.messaging.JobResultTopic)2 StageStatusTopic (com.thoughtworks.go.server.messaging.StageStatusTopic)2 ServerHealthService (com.thoughtworks.go.serverhealth.ServerHealthService)2 ServerHealthStates (com.thoughtworks.go.serverhealth.ServerHealthStates)2 Expectations (org.jmock.Expectations)2 Mockery (org.jmock.Mockery)2 GoCache (com.thoughtworks.go.server.cache.GoCache)1 SchedulingPerformanceLogger (com.thoughtworks.go.server.perf.SchedulingPerformanceLogger)1 TestTransactionSynchronizationManager (com.thoughtworks.go.server.transaction.TestTransactionSynchronizationManager)1 TestTransactionTemplate (com.thoughtworks.go.server.transaction.TestTransactionTemplate)1 SQLException (java.sql.SQLException)1