Search in sources :

Example 1 with PipelineDao

use of com.thoughtworks.go.server.dao.PipelineDao 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;
}
Also used : StageDao(com.thoughtworks.go.server.dao.StageDao) JobResultTopic(com.thoughtworks.go.server.messaging.JobResultTopic) StageStatusTopic(com.thoughtworks.go.server.messaging.StageStatusTopic) ServerHealthStates(com.thoughtworks.go.serverhealth.ServerHealthStates) JobInstanceDao(com.thoughtworks.go.server.dao.JobInstanceDao) Pipeline(com.thoughtworks.go.domain.Pipeline) StageStatusCache(com.thoughtworks.go.domain.activity.StageStatusCache) JobStatusCache(com.thoughtworks.go.domain.activity.JobStatusCache) ServerHealthService(com.thoughtworks.go.serverhealth.ServerHealthService) PipelineDao(com.thoughtworks.go.server.dao.PipelineDao) Stage(com.thoughtworks.go.domain.Stage)

Example 2 with PipelineDao

use of com.thoughtworks.go.server.dao.PipelineDao 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;
}
Also used : StageDao(com.thoughtworks.go.server.dao.StageDao) JobResultTopic(com.thoughtworks.go.server.messaging.JobResultTopic) StageStatusTopic(com.thoughtworks.go.server.messaging.StageStatusTopic) ServerHealthStates(com.thoughtworks.go.serverhealth.ServerHealthStates) JobInstanceDao(com.thoughtworks.go.server.dao.JobInstanceDao) Pipeline(com.thoughtworks.go.domain.Pipeline) StageStatusCache(com.thoughtworks.go.domain.activity.StageStatusCache) JobStatusCache(com.thoughtworks.go.domain.activity.JobStatusCache) ServerHealthService(com.thoughtworks.go.serverhealth.ServerHealthService) PipelineDao(com.thoughtworks.go.server.dao.PipelineDao) Stage(com.thoughtworks.go.domain.Stage)

Example 3 with PipelineDao

use of com.thoughtworks.go.server.dao.PipelineDao 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);
    pipelineNames = asList(new CaseInsensitiveString("blah-pipeline"));
    user = new Username(new CaseInsensitiveString("poovan"));
    operationResult = new HttpLocalizedOperationResult();
    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) TestTransactionSynchronizationManager(com.thoughtworks.go.server.transaction.TestTransactionSynchronizationManager) HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) GoCache(com.thoughtworks.go.server.cache.GoCache) PipelineDao(com.thoughtworks.go.server.dao.PipelineDao) Before(org.junit.Before)

Aggregations

PipelineDao (com.thoughtworks.go.server.dao.PipelineDao)3 StageDao (com.thoughtworks.go.server.dao.StageDao)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 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 GoCache (com.thoughtworks.go.server.cache.GoCache)1 Username (com.thoughtworks.go.server.domain.Username)1 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)1 TestTransactionSynchronizationManager (com.thoughtworks.go.server.transaction.TestTransactionSynchronizationManager)1 TestTransactionTemplate (com.thoughtworks.go.server.transaction.TestTransactionTemplate)1 Before (org.junit.Before)1