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");
}
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);
}
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);
}
Aggregations