use of com.thoughtworks.go.server.domain.user.PipelineSelections in project gocd by gocd.
the class PipelineSelectionsService method persistSelectedPipelines.
public long persistSelectedPipelines(String id, Long userId, List<String> selectedPipelines, boolean isBlacklist) {
PipelineSelections pipelineSelections = findOrCreateCurrentPipelineSelectionsFor(id, userId);
if (isBlacklist) {
List<String> unselectedPipelines = invertSelections(selectedPipelines);
pipelineSelections.update(unselectedPipelines, clock.currentTime(), userId, isBlacklist);
} else {
pipelineSelections.update(selectedPipelines, clock.currentTime(), userId, isBlacklist);
}
return pipelineRepository.saveSelectedPipelines(pipelineSelections);
}
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));
}
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 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 GoConfigService method persistSelectedPipelines.
public long persistSelectedPipelines(String id, Long userId, List<String> selectedPipelines, boolean isBlacklist) {
PipelineSelections pipelineSelections = findOrCreateCurrentPipelineSelectionsFor(id, userId);
if (isBlacklist) {
List<String> unselectedPipelines = invertSelections(selectedPipelines);
pipelineSelections.update(unselectedPipelines, clock.currentTime(), userId, isBlacklist);
} else {
pipelineSelections.update(selectedPipelines, clock.currentTime(), userId, isBlacklist);
}
return pipelineRepository.saveSelectedPipelines(pipelineSelections);
}
Aggregations