use of com.thoughtworks.go.domain.StageIdentifier in project gocd by gocd.
the class ShineDaoIntegrationTest method shouldRetriveHistoricalFailureWithNoTests.
@Test
public void shouldRetriveHistoricalFailureWithNoTests() throws Exception {
failureSetup.setupPipelineInstance(true, null, goURLRepository);
StageIdentifier stageId3 = failureSetup.setupPipelineInstance(true, null, goURLRepository).stageId;
StageTestRuns stageTestRuns = shineDao.failedBuildHistoryForStage(stageId3, result);
List<FailingTestsInPipeline> failingTestsInPipelines = stageTestRuns.failingTestsInPipelines();
assertThat(failingTestsInPipelines.size(), is(3));
}
use of com.thoughtworks.go.domain.StageIdentifier in project gocd by gocd.
the class ArtifactDirectoryChooserTest method shouldLocateCachedArtifactIfItExists.
@Test
public void shouldLocateCachedArtifactIfItExists() throws IllegalArtifactLocationException {
StageIdentifier stageIdentifier = new StageIdentifier("P1", 1, "S1", "1");
File cachedStageFolder = new File(root2, "cache/artifacts/pipelines/P1/1/S1/1");
cachedStageFolder.mkdirs();
assertThat(chooser.findCachedArtifact(stageIdentifier), is(cachedStageFolder));
}
use of com.thoughtworks.go.domain.StageIdentifier in project gocd by gocd.
the class PathBasedArtifactsLocatorTest method shouldFindCachedArtifact.
@Test
public void shouldFindCachedArtifact() throws Exception {
PathBasedArtifactsLocator locator = new PathBasedArtifactsLocator(new File("root"));
File directory = locator.findCachedArtifact(new StageIdentifier("P1", 1, "S1", "1"));
assertThat(directory, is(new File("root/cache/artifacts/pipelines/P1/1/S1/1")));
}
use of com.thoughtworks.go.domain.StageIdentifier in project gocd by gocd.
the class PipelineUnlockApiServiceTest method unlockShouldSetResultToOkWhenSuccessful.
@Test
public void unlockShouldSetResultToOkWhenSuccessful() 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);
when(pipelineLockService.lockedPipeline("pipeline-name")).thenReturn(new StageIdentifier("pipeline-name", 10, "10", "stage", "2"));
Pipeline pipeline = new Pipeline();
when(pipelineDao.findPipelineByNameAndCounter("pipeline-name", 10)).thenReturn(pipeline);
HttpOperationResult result = new HttpOperationResult();
pipelineUnlockApiService.unlock("pipeline-name", new Username(new CaseInsensitiveString("username")), result);
assertThat(result.httpCode(), is(200));
assertThat(result.message(), is("Pipeline lock released for pipeline-name"));
verify(pipelineLockService).unlock("pipeline-name");
}
use of com.thoughtworks.go.domain.StageIdentifier in project gocd by gocd.
the class PipelineUnlockApiServiceTest method unlockShouldSetResultToNotAuthorizedWhenUserDoesNotHaveOperatePermissions.
@Test
public void unlockShouldSetResultToNotAuthorizedWhenUserDoesNotHaveOperatePermissions() throws Exception {
String pipelineName = "pipeline-name";
Mockito.when(securityService.hasOperatePermissionForPipeline(new CaseInsensitiveString("username"), pipelineName)).thenReturn(false);
Mockito.when(goConfigService.hasPipelineNamed(new CaseInsensitiveString(pipelineName))).thenReturn(true);
Mockito.when(goConfigService.isLockable(pipelineName)).thenReturn(true);
StageIdentifier identifier = new StageIdentifier(pipelineName, 10, "10", "stage", "1");
Mockito.when(pipelineLockService.lockedPipeline(pipelineName)).thenReturn(identifier);
Mockito.when(currentActivityService.isAnyStageActive(new PipelineIdentifier(pipelineName, 10, "10"))).thenReturn(false);
HttpOperationResult result = new HttpOperationResult();
pipelineUnlockApiService.unlock(pipelineName, new Username(new CaseInsensitiveString("username")), result);
assertThat(result.httpCode(), is(401));
assertThat(result.message(), is("user does not have operate permission on the pipeline"));
}
Aggregations