use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.
the class EnvironmentServiceTest method shouldReturnPipelineHistoryForPipelinesInAnEnvironment.
@Test
public void shouldReturnPipelineHistoryForPipelinesInAnEnvironment() throws Exception {
Username username = new Username(new CaseInsensitiveString("Foo"));
when(environmentConfigService.pipelinesFor(new CaseInsensitiveString("uat"))).thenReturn(Arrays.asList(new CaseInsensitiveString("uat-pipeline"), new CaseInsensitiveString("staging-pipeline")));
PipelineInstanceModel uatInstance = stubPipelineHistoryServiceToReturnPipelines("uat-pipeline");
PipelineInstanceModel stagingInstance = stubPipelineHistoryServiceToReturnPipelines("staging-pipeline");
ArrayList<Environment> environments = new ArrayList<>();
environmentService.addEnvironmentFor(new CaseInsensitiveString("uat"), username, environments);
assertThat(environments.size(), is(1));
Environment environment = environments.get(0);
assertThat(environment.getName(), is("uat"));
List<PipelineModel> models = environment.getPipelineModels();
assertThat(models.size(), is(2));
PipelineModel model1 = new PipelineModel(uatInstance.getName(), true, true, PipelinePauseInfo.notPaused());
model1.addPipelineInstance(uatInstance);
assertThat(models, hasItem(model1));
PipelineModel model2 = new PipelineModel(stagingInstance.getName(), true, true, PipelinePauseInfo.notPaused());
model2.addPipelineInstance(stagingInstance);
assertThat(models, hasItem(model2));
}
use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.
the class FailureServiceTest method setUp.
@Before
public void setUp() {
shineDao = mock(ShineDao.class);
securityService = mock(SecurityService.class);
stageFinder = mock(StageFinder.class);
failureService = new FailureService(securityService, shineDao, stageFinder);
username = new Username(new CaseInsensitiveString("foo"));
jobIdentifier = new JobIdentifier(new StageIdentifier("pipeline", 10, "stage", "5"), "job");
result = new HttpLocalizedOperationResult();
}
use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.
the class PipelineStagesFeedServiceTest method setUp.
@Before
public void setUp() throws Exception {
user = new Username(new CaseInsensitiveString("barrow"));
expected = new FeedEntries();
stageService = mock(StageService.class);
securityService = mock(SecurityService.class);
operationResult = new HttpLocalizedOperationResult();
pipelineStagesFeedResolver = new PipelineStagesFeedService(stageService, securityService).feedResolverFor("cruise");
}
use of com.thoughtworks.go.config.CaseInsensitiveString 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.config.CaseInsensitiveString in project gocd by gocd.
the class PipelineUnlockApiServiceTest method unlockShouldSetResultToNotAcceptableWhenNoPipelineInstanceIsCurrentlyLocked.
@Test
public void unlockShouldSetResultToNotAcceptableWhenNoPipelineInstanceIsCurrentlyLocked() 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);
Mockito.when(pipelineLockService.lockedPipeline("pipeline-name")).thenReturn(null);
HttpOperationResult result = new HttpOperationResult();
pipelineUnlockApiService.unlock("pipeline-name", new Username(new CaseInsensitiveString("username")), result);
assertThat(result.httpCode(), is(409));
assertThat(result.message(), is("Lock exists within the pipeline configuration but no pipeline instance is currently in progress"));
}
Aggregations