use of com.thoughtworks.go.domain.StageIdentifier in project gocd by gocd.
the class StageFeedEntryTest method shouldNotAddDuplicateAuthorsCardsToAuthorsList.
@Test
public void shouldNotAddDuplicateAuthorsCardsToAuthorsList() {
StageFeedEntry entry = new StageFeedEntry(1, 1, new StageIdentifier(), 1, new Date(), StageResult.Passed);
entry.addAuthor(new Author("name", "email"));
entry.addAuthor(new Author("name", "email"));
entry.addAuthor(new Author("name1", "email1"));
assertThat(entry.getAuthors().size(), is(2));
}
use of com.thoughtworks.go.domain.StageIdentifier 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"));
when(pipelineDao.lockedPipeline("mingle")).thenReturn(new StageIdentifier(pipeline.getName(), 9999, "1.2.9999", "stage", "1"));
when(goConfigService.isLockable(pipeline.getName())).thenReturn(true);
pipelineLockService.lockIfNeeded(pipeline);
assertThat(pipelineLockService.canScheduleStageInPipeline(pipeline.getIdentifier()), is(false));
}
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(pipelineDao.lockedPipeline("mingle")).thenReturn(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 {
when(pipelineDao.lockedPipeline("mingle")).thenReturn(new StageIdentifier("mingle", 1, "1", "stage", "1"));
assertThat(pipelineLockService.isLocked("mingle"), 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 {
Mockito.when(securityService.hasOperatePermissionForPipeline(new CaseInsensitiveString("username"), "pipeline-name")).thenReturn(true);
Mockito.when(goConfigService.hasPipelineNamed(new CaseInsensitiveString("pipeline-name"))).thenReturn(true);
Mockito.when(goConfigService.isLockable("pipeline-name")).thenReturn(true);
StageIdentifier identifier = new StageIdentifier("pipeline-name", 10, "10", "stage", "1");
Mockito.when(pipelineLockService.lockedPipeline("pipeline-name")).thenReturn(identifier);
Mockito.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(406));
assertThat(result.message(), is("locked pipeline instance is currently running (one of the stages is in progress)"));
}
Aggregations