Search in sources :

Example 6 with PipelineIdentifier

use of com.thoughtworks.go.domain.PipelineIdentifier in project gocd by gocd.

the class SchedulingCheckerServiceUnitTest method shouldCheckIfScheduleCheckersCalledOnStageRerun.

@Test
public void shouldCheckIfScheduleCheckersCalledOnStageRerun() {
    schedulingChecker.canRerunStage(new PipelineIdentifier("pipeline_name", 1), "stage_name", "user", operationResult);
    verify(schedulingChecker).buildScheduleCheckers(argumentCaptor.capture());
    verify(compositeChecker).check(operationResult);
    assertFor(argumentCaptor.getValue(), StageAuthorizationChecker.class);
    assertFor(argumentCaptor.getValue(), PipelinePauseChecker.class);
    assertFor(argumentCaptor.getValue(), PipelineActiveChecker.class);
    assertFor(argumentCaptor.getValue(), StageActiveChecker.class);
    assertFor(argumentCaptor.getValue(), OutOfDiskSpaceChecker.class);
}
Also used : PipelineIdentifier(com.thoughtworks.go.domain.PipelineIdentifier) Test(org.junit.Test)

Example 7 with PipelineIdentifier

use of com.thoughtworks.go.domain.PipelineIdentifier in project gocd by gocd.

the class SchedulingCheckerServiceUnitTest method shouldCheckIfScheduleCheckersCalledOnScheduleStage.

@Test
public void shouldCheckIfScheduleCheckersCalledOnScheduleStage() {
    schedulingChecker.canScheduleStage(new PipelineIdentifier("name", 1), "stage", "user", operationResult);
    verify(schedulingChecker).buildScheduleCheckers(argumentCaptor.capture());
    verify(compositeChecker).check(operationResult);
    assertFor(argumentCaptor.getValue(), StageAuthorizationChecker.class);
    assertFor(argumentCaptor.getValue(), StageLockChecker.class);
    assertFor(argumentCaptor.getValue(), PipelinePauseChecker.class);
    assertFor(argumentCaptor.getValue(), PipelineActiveChecker.class);
    assertFor(argumentCaptor.getValue(), StageActiveChecker.class);
    assertFor(argumentCaptor.getValue(), OutOfDiskSpaceChecker.class);
}
Also used : PipelineIdentifier(com.thoughtworks.go.domain.PipelineIdentifier) Test(org.junit.Test)

Example 8 with PipelineIdentifier

use of com.thoughtworks.go.domain.PipelineIdentifier in project gocd by gocd.

the class DownstreamInstancePopulator method populateRevisionsFor.

private void populateRevisionsFor(Node currentMaterial, MaterialInstance currentMaterialInstance, HashSet<Revision> visitedRevisions) {
    String revision = currentMaterial.revisions().get(0).getRevisionString();
    List<Node> downstreamPipelines = currentMaterial.getChildren();
    for (Node downstreamPipeline : downstreamPipelines) {
        List<PipelineIdentifier> pipelineIdentifiers = pipelineDao.getPipelineInstancesTriggeredWithDependencyMaterial(downstreamPipeline.getName(), currentMaterialInstance, revision);
        addRevisionsToNode(downstreamPipeline, pipelineIdentifiers);
        populateRevisionsForAllChildrenOf(downstreamPipeline, visitedRevisions);
    }
}
Also used : PipelineIdentifier(com.thoughtworks.go.domain.PipelineIdentifier) Node(com.thoughtworks.go.domain.valuestreammap.Node)

Example 9 with PipelineIdentifier

use of com.thoughtworks.go.domain.PipelineIdentifier 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(stageService.isAnyStageActiveForPipeline(new PipelineIdentifier(pipelineName, 10, "10"))).thenReturn(false);
    HttpOperationResult result = new HttpOperationResult();
    pipelineUnlockApiService.unlock(pipelineName, new Username(new CaseInsensitiveString("username")), result);
    assertThat(result.httpCode(), is(403));
    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.jupiter.api.Test)

Example 10 with PipelineIdentifier

use of com.thoughtworks.go.domain.PipelineIdentifier in project gocd by gocd.

the class PipelineActiveCheckerTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    service = mock(StageService.class);
    pipelineIdentifier = new PipelineIdentifier("cruise", 1, "label-1");
    checker = new PipelineActiveChecker(service, pipelineIdentifier);
}
Also used : PipelineIdentifier(com.thoughtworks.go.domain.PipelineIdentifier) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

PipelineIdentifier (com.thoughtworks.go.domain.PipelineIdentifier)11 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)4 Test (org.junit.jupiter.api.Test)4 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)2 Node (com.thoughtworks.go.domain.valuestreammap.Node)2 HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)2 Test (org.junit.Test)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 RecordNotFoundException (com.thoughtworks.go.config.exceptions.RecordNotFoundException)1 JobConfigIdentifier (com.thoughtworks.go.domain.JobConfigIdentifier)1 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)1 Stage (com.thoughtworks.go.domain.Stage)1 PipelineRevision (com.thoughtworks.go.domain.valuestreammap.PipelineRevision)1 Revision (com.thoughtworks.go.domain.valuestreammap.Revision)1 Username (com.thoughtworks.go.server.domain.Username)1 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1