use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.
the class JobInstanceSqlMapDaoTest method createNewPipeline.
private Pipeline createNewPipeline(PipelineConfig pipelineConfig) {
Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, modifySomeFiles(pipelineConfig), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), "md5-test", new TimeProvider());
dbHelper.savePipelineWithStagesAndMaterials(pipeline);
return pipeline;
}
use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.
the class JobInstanceSqlMapDaoTest method shouldLoadRerunOfCounterValueForScheduledBuilds.
@Test
public void shouldLoadRerunOfCounterValueForScheduledBuilds() {
List<JobPlan> jobPlans = jobInstanceDao.orderedScheduledBuilds();
assertThat(jobPlans.size(), is(2));
assertThat(jobPlans.get(0).getIdentifier().getRerunOfCounter(), is(nullValue()));
assertThat(jobPlans.get(1).getIdentifier().getRerunOfCounter(), is(nullValue()));
dbHelper.passStage(savedStage);
Stage stage = instanceFactory.createStageForRerunOfJobs(savedStage, a(JOB_NAME), schedulingContext, pipelineConfig.getStage(new CaseInsensitiveString(STAGE_NAME)), new TimeProvider(), "md5");
dbHelper.saveStage(savedPipeline, stage, stage.getOrderId() + 1);
jobPlans = jobInstanceDao.orderedScheduledBuilds();
assertThat(jobPlans.size(), is(1));
assertThat(jobPlans.get(0).getIdentifier().getRerunOfCounter(), is(savedStage.getCounter()));
}
use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.
the class StageServiceIntegrationTest method shouldReturnStageWithSpecificCounter.
@Test
public void shouldReturnStageWithSpecificCounter() throws Exception {
Stage firstStage = savedPipeline.getStages().first();
Stage newInstance = instanceFactory.createStageInstance(pipelineConfig.first(), new DefaultSchedulingContext("anonymous"), md5, new TimeProvider());
Stage newSavedStage = stageService.save(savedPipeline, newInstance);
Stage latestStage = stageService.findStageWithIdentifier(new StageIdentifier(CaseInsensitiveString.str(pipelineConfig.name()), null, savedPipeline.getLabel(), firstStage.getName(), String.valueOf(newSavedStage.getCounter())));
assertThat(latestStage, is(newSavedStage));
}
use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.
the class StageServiceIntegrationTest method shouldIgnoreErrorsWhenNotifyingListenersDuringSave.
@Test
public void shouldIgnoreErrorsWhenNotifyingListenersDuringSave() throws Exception {
List<StageStatusListener> original = new ArrayList<>(stageService.getStageStatusListeners());
try {
stageService.getStageStatusListeners().clear();
StageStatusListener failingListener = mock(StageStatusListener.class);
doThrow(new RuntimeException("Should not be rethrown by save")).when(failingListener).stageStatusChanged(any(Stage.class));
StageStatusListener passingListener = mock(StageStatusListener.class);
stageService.getStageStatusListeners().add(failingListener);
stageService.getStageStatusListeners().add(passingListener);
Stage newInstance = instanceFactory.createStageInstance(pipelineConfig.first(), new DefaultSchedulingContext("anonumous"), md5, new TimeProvider());
Stage savedStage = stageService.save(savedPipeline, newInstance);
assertThat("Got: " + savedStage.getId(), savedStage.getId() > 0L, is(true));
verify(passingListener).stageStatusChanged(any(Stage.class));
} finally {
stageService.getStageStatusListeners().clear();
stageService.getStageStatusListeners().addAll(original);
}
}
use of com.thoughtworks.go.util.TimeProvider in project gocd by gocd.
the class StageServiceIntegrationTest method shouldSaveStageWithStateBuilding.
@Test
public void shouldSaveStageWithStateBuilding() throws Exception {
Stage stage = instanceFactory.createStageInstance(pipelineConfig.first(), new DefaultSchedulingContext("anonumous"), md5, new TimeProvider());
stageService.save(savedPipeline, stage);
Stage latestStage = stageService.findLatestStage(CaseInsensitiveString.str(pipelineConfig.name()), CaseInsensitiveString.str(pipelineConfig.first().name()));
assertThat(latestStage.getState(), is(StageState.Building));
}
Aggregations