use of com.thoughtworks.go.serverhealth.ServerHealthStates in project gocd by gocd.
the class PipelineServiceTriangleDependencyTest method stubPipelineSaveForStatusListener.
private Pipeline stubPipelineSaveForStatusListener(StageStatusListener stageStatusListener, JobStatusListener jobStatusListener) {
StageDao stageDao = mock(StageDao.class);
ServerHealthService serverHealthService = mock(ServerHealthService.class);
when(serverHealthService.getAllLogs()).thenReturn(new ServerHealthStates());
JobInstanceService jobInstanceService = new JobInstanceService(mock(JobInstanceDao.class), mock(PropertiesService.class), mock(JobResultTopic.class), mock(JobStatusCache.class), actualTransactionTemplate, transactionSynchronizationManager, null, null, goConfigService, null, pluginManager, serverHealthService, jobStatusListener);
StageService stageService = new StageService(stageDao, jobInstanceService, mock(StageStatusTopic.class), mock(StageStatusCache.class), mock(SecurityService.class), mock(PipelineDao.class), mock(ChangesetService.class), mock(GoConfigService.class), actualTransactionTemplate, transactionSynchronizationManager, goCache);
Stage savedStage = StageMother.passedStageInstance("stage", "job", "pipeline-name");
when(stageDao.save(any(Pipeline.class), any(Stage.class))).thenReturn(savedStage);
stageService.addStageStatusListener(stageStatusListener);
service = new PipelineService(pipelineDao, stageService, mock(PipelineLockService.class), pipelineTimeline, materialRepository, actualTransactionTemplate, systemEnvironment, null, materialConfigConverter);
Pipeline pipeline = PipelineMother.pipeline("cruise", savedStage);
when(pipelineDao.save(pipeline)).thenReturn(pipeline);
when(pipelineTimeline.pipelineBefore(anyLong())).thenReturn(9L);
when(pipelineTimeline.pipelineAfter(pipeline.getId())).thenReturn(-1L);
when(materialRepository.findMaterialRevisionsForPipeline(9L)).thenReturn(MaterialRevisions.EMPTY);
return pipeline;
}
use of com.thoughtworks.go.serverhealth.ServerHealthStates in project gocd by gocd.
the class ScheduleServiceStageTriggerTest method jobInstanceService.
private JobInstanceService jobInstanceService(JobResultTopic jobResultTopic) {
ServerHealthService serverHealthService = mock(ServerHealthService.class);
when(serverHealthService.getAllLogs()).thenReturn(new ServerHealthStates());
return new JobInstanceService(jobInstanceDao, propertiesService, jobResultTopic, jobStatusCache, transactionTemplate, transactionSynchronizationManager, null, null, goConfigService, null, pluginManager, serverHealthService);
}
use of com.thoughtworks.go.serverhealth.ServerHealthStates in project gocd by gocd.
the class ServerHealthInformationProvider method asJson.
@Override
public Map<String, Object> asJson() {
LinkedHashMap<String, Object> json = new LinkedHashMap<>();
ServerHealthStates allLogs = service.getAllLogs();
json.put("Messages Count", allLogs.size());
ArrayList<Map<String, String>> messages = new ArrayList<>();
for (ServerHealthState log : allLogs) {
messages.add(log.asJson());
}
json.put("Messages", messages);
return json;
}
use of com.thoughtworks.go.serverhealth.ServerHealthStates in project gocd by gocd.
the class PipelineServiceTest method stubPipelineSaveForStatusListener.
private Pipeline stubPipelineSaveForStatusListener(StageStatusListener stageStatusListener, JobStatusListener jobStatusListener) {
StageDao stageDao = mock(StageDao.class);
ServerHealthService serverHealthService = mock(ServerHealthService.class);
when(serverHealthService.getAllLogs()).thenReturn(new ServerHealthStates());
JobInstanceService jobInstanceService = new JobInstanceService(mock(JobInstanceDao.class), mock(PropertiesService.class), mock(JobResultTopic.class), mock(JobStatusCache.class), actualTransactionTemplate, transactionSynchronizationManager, null, null, goConfigService, null, pluginManager, serverHealthService, jobStatusListener);
StageService stageService = new StageService(stageDao, jobInstanceService, mock(StageStatusTopic.class), mock(StageStatusCache.class), mock(SecurityService.class), mock(PipelineDao.class), mock(ChangesetService.class), mock(GoConfigService.class), actualTransactionTemplate, transactionSynchronizationManager, goCache);
Stage savedStage = StageMother.passedStageInstance("stage", "job", "pipeline-name");
when(stageDao.save(any(Pipeline.class), any(Stage.class))).thenReturn(savedStage);
stageService.addStageStatusListener(stageStatusListener);
service = new PipelineService(pipelineDao, stageService, mock(PipelineLockService.class), pipelineTimeline, materialRepository, actualTransactionTemplate, systemEnvironment, null, materialConfigConverter);
Pipeline pipeline = PipelineMother.pipeline("cruise", savedStage);
when(pipelineDao.save(pipeline)).thenReturn(pipeline);
when(pipelineTimeline.pipelineBefore(anyLong())).thenReturn(9L);
when(pipelineTimeline.pipelineAfter(pipeline.getId())).thenReturn(-1L);
when(materialRepository.findMaterialRevisionsForPipeline(9L)).thenReturn(MaterialRevisions.EMPTY);
return pipeline;
}
use of com.thoughtworks.go.serverhealth.ServerHealthStates in project gocd by gocd.
the class SCMMaterialSourceTest method shouldReloadSchedulableMaterialsOnConfigChange.
@Test
public void shouldReloadSchedulableMaterialsOnConfigChange() {
Set<MaterialConfig> schedulableMaterialConfigs = new HashSet<>(Arrays.asList(svnMaterial.config()));
when(goConfigService.getSchedulableSCMMaterials()).thenReturn(schedulableMaterialConfigs);
when(materialConfigConverter.toMaterials(schedulableMaterialConfigs)).thenReturn(new HashSet<>(Arrays.asList(svnMaterial)));
Set<Material> materials = source.materialsForUpdate();
assertThat(materials.size(), is(1));
assertTrue(materials.contains(svnMaterial));
schedulableMaterialConfigs = new HashSet<>(Arrays.asList(svnMaterial.config(), gitMaterial.config()));
when(goConfigService.getSchedulableSCMMaterials()).thenReturn(schedulableMaterialConfigs);
when(materialConfigConverter.toMaterials(schedulableMaterialConfigs)).thenReturn(new HashSet<>(Arrays.asList(svnMaterial, gitMaterial)));
when(serverHealthService.getAllLogs()).thenReturn(new ServerHealthStates());
source.onConfigChange(mock(CruiseConfig.class));
materials = source.materialsForUpdate();
assertThat(materials.size(), is(2));
assertTrue(materials.contains(svnMaterial));
assertTrue(materials.contains(gitMaterial));
}
Aggregations