Search in sources :

Example 51 with StageIdentifier

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

Example 52 with StageIdentifier

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

Example 53 with StageIdentifier

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

Example 54 with StageIdentifier

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");
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) Username(com.thoughtworks.go.server.domain.Username) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 55 with StageIdentifier

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"));
}
Also used : StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) Username(com.thoughtworks.go.server.domain.Username) PipelineIdentifier(com.thoughtworks.go.domain.PipelineIdentifier) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Aggregations

StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)58 Test (org.junit.Test)30 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)12 Pipeline (com.thoughtworks.go.domain.Pipeline)10 Stage (com.thoughtworks.go.domain.Stage)9 StageInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModel)6 ArrayList (java.util.ArrayList)6 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)5 PipelineState (com.thoughtworks.go.domain.PipelineState)5 Modification (com.thoughtworks.go.domain.materials.Modification)5 StageInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.StageInstanceModels)5 Username (com.thoughtworks.go.server.domain.Username)4 Date (java.util.Date)4 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)3 JobInstance (com.thoughtworks.go.domain.JobInstance)3 PipelineDependencyGraphOld (com.thoughtworks.go.domain.PipelineDependencyGraphOld)3 PipelineIdentifier (com.thoughtworks.go.domain.PipelineIdentifier)3 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)3 PipelineInstanceModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel)3 HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)3