use of com.thoughtworks.go.presentation.pipelinehistory.Environment in project gocd by gocd.
the class EnvironmentService method addEnvironmentFor.
void addEnvironmentFor(CaseInsensitiveString environmentName, Username username, ArrayList<Environment> environments) throws NoSuchEnvironmentException {
List<CaseInsensitiveString> pipelines = environmentConfigService.pipelinesFor(environmentName);
if (pipelines.isEmpty()) {
environments.add(new Environment(CaseInsensitiveString.str(environmentName), new ArrayList<>()));
return;
}
List<PipelineModel> pipelineInstanceModels = getPipelinesInstanceForEnvironment(pipelines, username);
if (!pipelineInstanceModels.isEmpty()) {
environments.add(new Environment(CaseInsensitiveString.str(environmentName), pipelineInstanceModels));
}
}
use of com.thoughtworks.go.presentation.pipelinehistory.Environment in project gocd by gocd.
the class EnvironmentServiceTest method shouldReturnAllTheEnvironments.
@Test
public void shouldReturnAllTheEnvironments() throws Exception {
when(environmentConfigService.environmentNames()).thenReturn(Arrays.asList(new CaseInsensitiveString("uat"), new CaseInsensitiveString("preprod")));
when(environmentConfigService.pipelinesFor(new CaseInsensitiveString("uat"))).thenReturn(Arrays.asList(new CaseInsensitiveString("uat-pipeline"), new CaseInsensitiveString("staging-pipeline")));
when(environmentConfigService.pipelinesFor(new CaseInsensitiveString("preprod"))).thenReturn(Arrays.asList(new CaseInsensitiveString("preprod-pipeline")));
stubPipelineHistoryServiceToReturnPipelines("uat-pipeline", "preprod-pipeline", "staging-pipeline");
List<Environment> environments = environmentService.getEnvironments(USER_FOO);
assertThat(environments.size(), is(2));
assertThat(environments.get(0).getPipelineModels().size(), is(2));
assertThat(environments.get(1).getPipelineModels().size(), is(1));
}
use of com.thoughtworks.go.presentation.pipelinehistory.Environment in project gocd by gocd.
the class EnvironmentServiceTest method shouldAddEnvironmentsThatHaveNoPipelinesConfigured.
@Test
public void shouldAddEnvironmentsThatHaveNoPipelinesConfigured() throws Exception {
when(environmentConfigService.environmentNames()).thenReturn(Arrays.asList(new CaseInsensitiveString("uat"), new CaseInsensitiveString("preprod")));
when(environmentConfigService.pipelinesFor(new CaseInsensitiveString("uat"))).thenReturn(new ArrayList<>());
when(environmentConfigService.pipelinesFor(new CaseInsensitiveString("preprod"))).thenReturn(Arrays.asList(new CaseInsensitiveString("preprod-pipeline")));
stubPipelineHistoryServiceToReturnPipelines("preprod-pipeline");
List<Environment> environments = environmentService.getEnvironments(USER_FOO);
assertThat(environments.size(), is(2));
assertThat(environments.get(0).getPipelineModels().size(), is(0));
assertThat(environments.get(1).getPipelineModels().size(), is(1));
}
use of com.thoughtworks.go.presentation.pipelinehistory.Environment 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.presentation.pipelinehistory.Environment in project gocd by gocd.
the class EnvironmentServiceTest method shouldOmitEnvironmentsHavePipelinesConfiguredButHaveNoPermissionsOnThePipelines.
@Test
public void shouldOmitEnvironmentsHavePipelinesConfiguredButHaveNoPermissionsOnThePipelines() throws Exception {
when(environmentConfigService.environmentNames()).thenReturn(Arrays.asList(new CaseInsensitiveString("uat"), new CaseInsensitiveString("preprod")));
when(environmentConfigService.pipelinesFor(new CaseInsensitiveString("uat"))).thenReturn(Arrays.asList(new CaseInsensitiveString("staging-pipeline")));
when(environmentConfigService.pipelinesFor(new CaseInsensitiveString("preprod"))).thenReturn(Arrays.asList(new CaseInsensitiveString("preprod-pipeline")));
stubPipelineHistoryServiceToReturnPipelines("preprod-pipeline");
when(pipelineHistoryService.latest("staging-pipeline", USER_FOO)).thenReturn(null);
List<Environment> environments = environmentService.getEnvironments(USER_FOO);
assertThat(environments.size(), is(1));
assertThat(environments.get(0).getPipelineModels().size(), is(1));
}
Aggregations