use of com.thoughtworks.go.domain.StageIdentifier 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));
}
use of com.thoughtworks.go.domain.StageIdentifier in project gocd by gocd.
the class PipelineLockServiceTest method shouldKnowIfPipelineIsLocked.
@Test
public void shouldKnowIfPipelineIsLocked() throws Exception {
String pipelineName = "mingle";
PipelineState pipelineState = new PipelineState(pipelineName, new StageIdentifier(pipelineName, 1, "1", "stage", "1"));
pipelineState.lock(1);
when(pipelineStateDao.pipelineStateFor(pipelineName)).thenReturn(pipelineState);
assertThat(pipelineLockService.isLocked(pipelineName), is(true));
assertThat(pipelineLockService.isLocked("twist"), is(false));
}
use of com.thoughtworks.go.domain.StageIdentifier in project gocd by gocd.
the class PipelineUnlockApiServiceTest method unlockShouldSetResultToNotAcceptableWhenAPipelineInstanceIsCurrentlyRunning.
@Test
public void unlockShouldSetResultToNotAcceptableWhenAPipelineInstanceIsCurrentlyRunning() throws Exception {
when(securityService.hasOperatePermissionForPipeline(new CaseInsensitiveString("username"), "pipeline-name")).thenReturn(true);
when(goConfigService.hasPipelineNamed(new CaseInsensitiveString("pipeline-name"))).thenReturn(true);
when(goConfigService.isLockable("pipeline-name")).thenReturn(true);
StageIdentifier identifier = new StageIdentifier("pipeline-name", 10, "10", "stage", "1");
when(pipelineLockService.lockedPipeline("pipeline-name")).thenReturn(identifier);
when(currentActivityService.isAnyStageActive(identifier.pipelineIdentifier())).thenReturn(true);
HttpOperationResult result = new HttpOperationResult();
pipelineUnlockApiService.unlock("pipeline-name", new Username(new CaseInsensitiveString("username")), result);
assertThat(result.httpCode(), is(409));
assertThat(result.message(), is("Locked pipeline instance is currently running (one of the stages is in progress)"));
}
use of com.thoughtworks.go.domain.StageIdentifier in project gocd by gocd.
the class PipelineUnlockApiServiceTest method shouldBeAbleToVerifyUnlockStatusOfAPipelineWithoutCheckingForUserPermissions.
@Test
public void shouldBeAbleToVerifyUnlockStatusOfAPipelineWithoutCheckingForUserPermissions() throws Exception {
when(goConfigService.isLockable("pipeline-name")).thenReturn(true);
when(pipelineLockService.lockedPipeline("pipeline-name")).thenReturn(new StageIdentifier("pipeline-name", 10, "10", "stage", "2"));
when(currentActivityService.isAnyStageActive(new PipelineIdentifier("pipeline-name", 10, "10"))).thenReturn(false);
assertThat(pipelineUnlockApiService.isUnlockable("pipeline-name"), is(true));
verify(pipelineLockService, times(0)).unlock("pipeline-name");
}
use of com.thoughtworks.go.domain.StageIdentifier in project gocd by gocd.
the class PipelineDependencyGraphOldTest method shouldProvideMaterialRevisionForAGivenDownStreamPipeline.
@Test
public void shouldProvideMaterialRevisionForAGivenDownStreamPipeline() throws Exception {
StageInstanceModels stages = new StageInstanceModels();
stages.add(new StageInstanceModel("stage-0", "21", StageResult.Cancelled, new StageIdentifier("blahUpStream", 23, "stage-0", "21")));
stages.add(new StageInstanceModel("stage-1", "2", StageResult.Cancelled, new StageIdentifier("blahUpStream", 23, "stage-1", "2")));
PipelineInstanceModel upStream = PipelineHistoryMother.singlePipeline("blahUpStream", stages);
PipelineInstanceModel down1 = pim("blahDown1");
down1.setMaterialConfigs(new MaterialConfigs(dependencyMaterialConfig("blahUpStream", "stage-0")));
PipelineInstanceModel down2 = pim("blahDown2");
down2.setMaterialConfigs(new MaterialConfigs(dependencyMaterialConfig("blahUpStream", "stage-1")));
PipelineDependencyGraphOld graph = new PipelineDependencyGraphOld(upStream, PipelineInstanceModels.createPipelineInstanceModels(down1, down2));
assertThat(graph.dependencyRevisionFor(down1), is("blahUpStream/23/stage-0/21"));
assertThat(graph.dependencyRevisionFor(down2), is("blahUpStream/23/stage-1/2"));
}
Aggregations