use of com.thoughtworks.go.domain.Pipeline in project gocd by gocd.
the class PipelineLockServiceTest method shouldNotifyListenersAfterPipelineIsLocked.
@Test
public void shouldNotifyListenersAfterPipelineIsLocked() throws Exception {
when(goConfigService.isLockable("pipeline1")).thenReturn(true);
PipelineLockStatusChangeListener lockStatusChangeListener = mock(PipelineLockStatusChangeListener.class);
Pipeline pipeline = PipelineMother.firstStageBuildingAndSecondStageScheduled("pipeline1", asList("stage1", "stage2"), asList("job1"));
pipelineLockService.registerListener(lockStatusChangeListener);
pipelineLockService.lockIfNeeded(pipeline);
verify(lockStatusChangeListener).lockStatusChanged(Event.lock("pipeline1"));
}
use of com.thoughtworks.go.domain.Pipeline in project gocd by gocd.
the class PipelineLockServiceTest method shouldNotAllowStageFromLockedPipelineToBeScheduled.
@Test
public void shouldNotAllowStageFromLockedPipelineToBeScheduled() throws Exception {
Pipeline pipeline = PipelineMother.firstStageBuildingAndSecondStageScheduled("mingle", asList("dev", "ft"), asList("test"));
PipelineState pipelineState = new PipelineState(pipeline.getName(), new StageIdentifier(pipeline.getName(), 9999, "1.2.9999", "stage", "1"));
pipelineState.lock(1);
when(pipelineStateDao.pipelineStateFor("mingle")).thenReturn(pipelineState);
when(goConfigService.isLockable(pipeline.getName())).thenReturn(true);
pipelineLockService.lockIfNeeded(pipeline);
assertThat(pipelineLockService.canScheduleStageInPipeline(pipeline.getIdentifier()), is(false));
}
use of com.thoughtworks.go.domain.Pipeline in project gocd by gocd.
the class PipelineLockServiceTest method shouldAllowStageFromCurrentPipelineToBeScheduled.
@Test
public void shouldAllowStageFromCurrentPipelineToBeScheduled() throws Exception {
Pipeline pipeline = PipelineMother.firstStageBuildingAndSecondStageScheduled("mingle", asList("dev", "ft"), asList("test"));
when(pipelineStateDao.pipelineStateFor("mingle")).thenReturn(new PipelineState(pipeline.getName(), pipeline.getStages().get(0).getIdentifier()));
when(goConfigService.isLockable(pipeline.getName())).thenReturn(true);
pipelineLockService.lockIfNeeded(pipeline);
assertThat(pipelineLockService.canScheduleStageInPipeline(pipeline.getIdentifier()), is(true));
}
use of com.thoughtworks.go.domain.Pipeline in project gocd by gocd.
the class PipelineLockServiceTest method shouldLockPipeline.
@Test
public void shouldLockPipeline() throws Exception {
when(goConfigService.isLockable("mingle")).thenReturn(true);
Pipeline pipeline = PipelineMother.firstStageBuildingAndSecondStageScheduled("mingle", asList("dev", "ft"), asList("test"));
pipelineLockService.lockIfNeeded(pipeline);
verify(pipelineStateDao).lockPipeline(pipeline);
}
use of com.thoughtworks.go.domain.Pipeline in project gocd by gocd.
the class PipelineLockServiceTest method shouldAllowStageFromAnotherPipelineIfThePipelineIsNotLockabler.
@Test
public void shouldAllowStageFromAnotherPipelineIfThePipelineIsNotLockabler() throws Exception {
Pipeline pipeline = PipelineMother.firstStageBuildingAndSecondStageScheduled("mingle", asList("dev", "ft"), asList("test"));
when(pipelineStateDao.pipelineStateFor("mingle")).thenReturn(new PipelineState(pipeline.getName(), new StageIdentifier(pipeline.getName(), 9999, "1.2.9999", "stage", "1")));
when(goConfigService.isLockable(pipeline.getName())).thenReturn(false);
pipelineLockService.lockIfNeeded(pipeline);
assertThat(pipelineLockService.canScheduleStageInPipeline(pipeline.getIdentifier()), is(true));
}
Aggregations