use of com.thoughtworks.go.domain.Matcher in project gocd by gocd.
the class MyGoControllerTest method shouldRenderPipelineStageCombinationJSONSortedByPipelineNameIgnoringCase.
@Test
public void shouldRenderPipelineStageCombinationJSONSortedByPipelineNameIgnoringCase() {
HttpServletRequest request = mock(HttpServletRequest.class);
User user = new User(USERNAME, "Srikanth Maga", new String[] { "rope", "srikanth" }, "sriki@tw.com", true);
user.addNotificationFilter(new NotificationFilter("p1", "s1", StageEvent.All, true));
user.addNotificationFilter(new NotificationFilter("p2", "s2", StageEvent.Fails, true));
when(userService.load(USERID)).thenReturn(user);
List<PipelineConfigs> groups = new ArrayList<>();
groups.add(PipelineConfigMother.createGroup("g3", PipelineConfigMother.createPipelineConfigWithStages("pipeline3-1", "stage3-1")));
groups.add(PipelineConfigMother.createGroup("g1", PipelineConfigMother.createPipelineConfigWithStages("PIPELINE2-1", "stage2-1")));
groups.add(PipelineConfigMother.createGroup("g1", PipelineConfigMother.createPipelineConfigWithStages("pipeline1-1", "stage1-1", "stage1-2")));
when(pipelineConfigService.viewableGroupsFor(new Username(new CaseInsensitiveString(user.getName())))).thenReturn(groups);
ModelAndView modelAndView = controller.handleRequest(null, request);
assertThat(modelAndView.getModel().get("matchers"), is(new Matcher("rope,srikanth")));
assertThat(modelAndView.getModel().get("email"), is("sriki@tw.com"));
assertThat(modelAndView.getModel().get("emailMe"), is(true));
assertThat(modelAndView.getModel().get("notificationFilters"), is(user.getNotificationFilters()));
assertThat(modelAndView.getModel().get("l"), is(localizer));
assertThat(modelAndView.getModel().get("pipelines"), is("[{\"name\":\"" + GoConstants.ANY_PIPELINE + "\",\"stages\":[{\"stageName\":\"" + GoConstants.ANY_STAGE + "\"}]}," + "{\"name\":\"pipeline1-1\",\"stages\":[{\"stageName\":\"" + GoConstants.ANY_STAGE + "\"},{\"stageName\":\"stage1-1\"},{\"stageName\":\"stage1-2\"}]}," + "{\"name\":\"PIPELINE2-1\",\"stages\":[{\"stageName\":\"" + GoConstants.ANY_STAGE + "\"},{\"stageName\":\"stage2-1\"}]}," + "{\"name\":\"pipeline3-1\",\"stages\":[{\"stageName\":\"" + GoConstants.ANY_STAGE + "\"},{\"stageName\":\"stage3-1\"}]}]"));
}
Aggregations