Search in sources :

Example 1 with Matcher

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\"}]}]"));
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) User(com.thoughtworks.go.domain.User) Username(com.thoughtworks.go.server.domain.Username) Matcher(com.thoughtworks.go.domain.Matcher) ArrayList(java.util.ArrayList) ModelAndView(org.springframework.web.servlet.ModelAndView) PipelineConfigs(com.thoughtworks.go.config.PipelineConfigs) NotificationFilter(com.thoughtworks.go.domain.NotificationFilter) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Aggregations

CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 PipelineConfigs (com.thoughtworks.go.config.PipelineConfigs)1 Matcher (com.thoughtworks.go.domain.Matcher)1 NotificationFilter (com.thoughtworks.go.domain.NotificationFilter)1 User (com.thoughtworks.go.domain.User)1 Username (com.thoughtworks.go.server.domain.Username)1 ArrayList (java.util.ArrayList)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 Test (org.junit.Test)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1