use of com.thoughtworks.go.server.domain.user.PipelineSelections in project gocd by gocd.
the class GoConfigServiceTest method hasValues.
private Matcher<PipelineSelections> hasValues(final List<String> isVisible, final List<String> isNotVisible, final Date today, final Long userId) {
return new BaseMatcher<PipelineSelections>() {
public boolean matches(Object o) {
PipelineSelections pipelineSelections = (PipelineSelections) o;
assertHasSelected(pipelineSelections, isVisible);
assertHasSelected(pipelineSelections, isNotVisible, false);
assertThat(pipelineSelections.lastUpdated(), is(today));
assertThat(pipelineSelections.userId(), is(userId));
return true;
}
public void describeTo(Description description) {
}
};
}
use of com.thoughtworks.go.server.domain.user.PipelineSelections in project gocd by gocd.
the class GoConfigServiceTest method shouldUpdateAlreadyPersistedSelection_WhenSecurityIsDisabled.
@Test
public void shouldUpdateAlreadyPersistedSelection_WhenSecurityIsDisabled() {
Date date = new DateTime(2000, 1, 1, 1, 1, 1, 1).toDate();
when(clock.currentTime()).thenReturn(date);
mockConfig();
PipelineSelections pipelineSelections = new PipelineSelections(Arrays.asList("pip1"));
when(pipelineRepository.findPipelineSelectionsById("123")).thenReturn(pipelineSelections);
List<String> newPipelines = Arrays.asList("pipeline1", "pipeline2");
goConfigService.persistSelectedPipelines("123", null, newPipelines, true);
assertHasSelected(pipelineSelections, newPipelines);
assertThat(pipelineSelections.lastUpdated(), is(date));
verify(pipelineRepository).findPipelineSelectionsById("123");
verify(pipelineRepository).saveSelectedPipelines(argThat(hasValues(Arrays.asList("pipeline1", "pipeline2"), Arrays.asList("pipelineX", "pipeline3"), clock.currentTime(), null)));
}
use of com.thoughtworks.go.server.domain.user.PipelineSelections in project gocd by gocd.
the class GoConfigServiceTest method shouldUpdatePipelineSelectionsWhenTheUserIsAnonymousAndHasSelectedPipelines_WithWhitelist.
@Test
public void shouldUpdatePipelineSelectionsWhenTheUserIsAnonymousAndHasSelectedPipelines_WithWhitelist() {
when(pipelineRepository.findPipelineSelectionsById("1")).thenReturn(new PipelineSelections(Arrays.asList("pipeline1", "pipeline2"), null, null, false));
goConfigService.updateUserPipelineSelections("1", null, new CaseInsensitiveString("pipelineNew"));
verify(pipelineRepository).findPipelineSelectionsById("1");
verify(pipelineRepository, times(1)).saveSelectedPipelines(argThat(isAPipelineSelectionsInstanceWith(false, "pipeline1", "pipeline2", "pipelineNew")));
}
use of com.thoughtworks.go.server.domain.user.PipelineSelections in project gocd by gocd.
the class GoConfigServiceTest method shouldNotUpdatePipelineSelectionsWhenTheUserIsLoggedIn_WithBlacklist.
@Test
public void shouldNotUpdatePipelineSelectionsWhenTheUserIsLoggedIn_WithBlacklist() {
mockConfigWithSecurity();
when(pipelineRepository.findPipelineSelectionsByUserId(1L)).thenReturn(new PipelineSelections(Arrays.asList("pipeline1", "pipeline2"), null, null, true));
goConfigService.updateUserPipelineSelections(null, 1L, new CaseInsensitiveString("pipelineNew"));
verify(pipelineRepository).findPipelineSelectionsByUserId(1L);
verify(pipelineRepository, times(0)).saveSelectedPipelines(argThat(Matchers.any(PipelineSelections.class)));
}
use of com.thoughtworks.go.server.domain.user.PipelineSelections in project gocd by gocd.
the class GoConfigServiceTest method shouldReturnPersistedPipelineSelectionsAgainstCookieId_WhenSecurityisDisabled.
@Test
public void shouldReturnPersistedPipelineSelectionsAgainstCookieId_WhenSecurityisDisabled() {
PipelineSelections pipelineSelections = new PipelineSelections(Arrays.asList("pip1"));
when(pipelineRepository.findPipelineSelectionsById("123")).thenReturn(pipelineSelections);
assertThat(goConfigService.getSelectedPipelines("123", null), is(pipelineSelections));
assertThat(goConfigService.getSelectedPipelines("", null), is(PipelineSelections.ALL));
assertThat(goConfigService.getSelectedPipelines("345", null), is(PipelineSelections.ALL));
}
Aggregations