Search in sources :

Example 46 with Pipeline

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"));
}
Also used : PipelineLockStatusChangeListener(com.thoughtworks.go.server.domain.PipelineLockStatusChangeListener) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 47 with Pipeline

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));
}
Also used : PipelineState(com.thoughtworks.go.domain.PipelineState) StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 48 with Pipeline

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));
}
Also used : PipelineState(com.thoughtworks.go.domain.PipelineState) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 49 with Pipeline

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);
}
Also used : Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 50 with 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));
}
Also used : PipelineState(com.thoughtworks.go.domain.PipelineState) StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Aggregations

Pipeline (com.thoughtworks.go.domain.Pipeline)184 Test (org.junit.Test)122 Stage (com.thoughtworks.go.domain.Stage)33 Username (com.thoughtworks.go.server.domain.Username)30 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)29 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)24 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)24 PipelineMaterialRevision (com.thoughtworks.go.domain.PipelineMaterialRevision)21 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)20 JobInstance (com.thoughtworks.go.domain.JobInstance)19 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)13 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)13 Modification (com.thoughtworks.go.domain.materials.Modification)13 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)13 Date (java.util.Date)13 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)11 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)10 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)8 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)7 PipelineState (com.thoughtworks.go.domain.PipelineState)6