use of com.thoughtworks.go.server.domain.user.PipelineSelections in project gocd by gocd.
the class PipelineSelectionsServiceTest method shouldPersistPipelineSelectionsAgainstUser_WhenUserHasNoSelections.
@Test
public void shouldPersistPipelineSelectionsAgainstUser_WhenUserHasNoSelections() {
Date date = new DateTime(2000, 1, 1, 1, 1, 1, 1).toDate();
when(clock.currentTime()).thenReturn(date);
User user = getUser("badger", 10L);
Matcher<PipelineSelections> pipelineSelectionsMatcher = hasValues(Arrays.asList("pipelineX", "pipeline3"), Arrays.asList("pipeline1", "pipeline2"), date, user.getId());
when(pipelineRepository.findPipelineSelectionsByUserId(user.getId())).thenReturn(null);
when(pipelineRepository.saveSelectedPipelines(argThat(pipelineSelectionsMatcher))).thenReturn(2L);
when(goConfigService.getAllPipelineConfigs()).thenReturn(Arrays.asList(pipelineConfig("pipeline1"), pipelineConfig("pipeline2"), pipelineConfig("pipelineX"), pipelineConfig("pipeline3")));
when(goConfigService.isSecurityEnabled()).thenReturn(true);
long pipelineSelectionsId = pipelineSelectionsService.persistSelectedPipelines("1", user.getId(), Arrays.asList("pipelineX", "pipeline3"), true);
assertThat(pipelineSelectionsId, is(2l));
verify(pipelineRepository).saveSelectedPipelines(argThat(pipelineSelectionsMatcher));
verify(pipelineRepository).findPipelineSelectionsByUserId(user.getId());
verify(pipelineRepository, never()).findPipelineSelectionsById("1");
}
use of com.thoughtworks.go.server.domain.user.PipelineSelections in project gocd by gocd.
the class PipelineSelectionsServiceTest 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) {
}
};
}
Aggregations