use of com.thoughtworks.go.server.domain.user.PipelineSelections in project gocd by gocd.
the class PipelineHistoryServiceTest method allActivePipelines_shouldOnlyKeepSelectedPipelines_andRemove_EmptyGroups.
@Test
public void allActivePipelines_shouldOnlyKeepSelectedPipelines_andRemove_EmptyGroups() {
Username foo = new Username(new CaseInsensitiveString("foo"));
CruiseConfig cruiseConfig = ConfigMigrator.loadWithMigration(ConfigFileFixture.CONFIG).config;
when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
PipelineInstanceModels activePipelineInstances = createPipelineInstanceModels(activePipeline("pipeline1", 1, 1.0), activePipeline("pipeline2", 1, 1.0), activePipeline("pipeline4", 1, 1.0), activePipeline("non-operatable-pipeline", 1, 1.0));
for (String pipeline : new String[] { "pipeline1", "pipeline2", "pipeline3", "pipeline4", "non-operatable-pipeline" }) {
stubPermisssionsForActivePipeline(foo, cruiseConfig, pipeline, true, true);
when(pipelineDao.loadHistory(pipeline, 1, 0)).thenReturn(createPipelineInstanceModels());
}
when(pipelineDao.loadActivePipelines()).thenReturn(activePipelineInstances);
when(goConfigService.hasPipelineNamed(new CaseInsensitiveString(any(String.class)))).thenReturn(true);
List<PipelineGroupModel> groups = pipelineHistoryService.allActivePipelineInstances(foo, new PipelineSelections(Arrays.asList("non-operatable-pipeline")));
assertThat(groups.size(), is(1));
assertThat(groups.get(0).getName(), is("defaultGroup"));
assertThat(groups.get(0).containsPipeline("pipeline1"), is(true));
assertThat(groups.get(0).containsPipeline("pipeline2"), is(true));
assertThat(groups.get(0).containsPipeline("pipeline3"), is(true));
assertThat(groups.get(0).containsPipeline("pipeline4"), is(true));
}
use of com.thoughtworks.go.server.domain.user.PipelineSelections in project gocd by gocd.
the class GoConfigService method updateUserPipelineSelections.
public void updateUserPipelineSelections(String id, Long userId, CaseInsensitiveString pipelineToAdd) {
PipelineSelections currentSelections = findOrCreateCurrentPipelineSelectionsFor(id, userId);
if (!currentSelections.isBlacklist()) {
currentSelections.addPipelineToSelections(pipelineToAdd);
pipelineRepository.saveSelectedPipelines(currentSelections);
}
}
use of com.thoughtworks.go.server.domain.user.PipelineSelections in project gocd by gocd.
the class PipelineRepositoryIntegrationTest method shouldSaveSelectedPipelinesWithoutUserId.
@Test
public void shouldSaveSelectedPipelinesWithoutUserId() {
Date date = new Date();
List<String> unSelected = Arrays.asList("pipeline1", "pipeline2");
long id = pipelineRepository.saveSelectedPipelines(new PipelineSelections(unSelected, date, null, true));
PipelineSelections found = pipelineRepository.findPipelineSelectionsById(id);
assertHasPipelines(found, new String[] { "pipeline3", "pipeline4" });
assertHasPipelines(found, new String[] { "pipeline1", "pipeline2" }, false);
assertThat(found.userId(), is(nullValue()));
assertEquals(date, found.lastUpdated());
}
use of com.thoughtworks.go.server.domain.user.PipelineSelections in project gocd by gocd.
the class PipelineRepositoryIntegrationTest method shouldSaveSelectedPipelinesWithBlacklistPreferenceTrue.
@Test
public void shouldSaveSelectedPipelinesWithBlacklistPreferenceTrue() {
User user = createUser();
List<String> unSelected = Arrays.asList("pipeline1", "pipeline2");
long id = pipelineRepository.saveSelectedPipelines(new PipelineSelections(unSelected, new Date(), user.getId(), true));
assertThat(pipelineRepository.findPipelineSelectionsById(id).isBlacklist(), is(true));
}
use of com.thoughtworks.go.server.domain.user.PipelineSelections in project gocd by gocd.
the class PipelineRepositoryIntegrationTest method shouldSaveSelectedPipelinesWithBlacklistPreferenceFalse.
@Test
public void shouldSaveSelectedPipelinesWithBlacklistPreferenceFalse() {
User user = createUser();
List<String> unSelected = Arrays.asList("pipeline1", "pipeline2");
long id = pipelineRepository.saveSelectedPipelines(new PipelineSelections(unSelected, new Date(), user.getId(), false));
assertThat(pipelineRepository.findPipelineSelectionsById(id).isBlacklist(), is(false));
}
Aggregations