/** * Fetch list. * * @throws Exception the exception */ @Test public void fetchList() throws Exception { // Success situation getGroupMock().setMode(ModeEnum.MODE_SUCCESS); getMockMvc() .perform(get(FETCH_LIST).session(SessionAuthenticationTestUtil.getSessionTest())) .andExpect(status().isOk()) .andExpect(model().attribute(RESPONSE, containsString("\"operationSuccess\":true"))) .equals(new ModelAndView(GROUP_GROUP_MAIN, RESPONSE, new String())); // Failure situation getGroupMock().setMode(ModeEnum.MODE_FAILURE); getMockMvc() .perform(get(FETCH_LIST).session(SessionAuthenticationTestUtil.getSessionTest())) .andExpect(status().isOk()) .andExpect( model().attribute(RESPONSE, containsString(TestMessageEnum.MESSAGE_ERROR.getValue()))) .equals(new ModelAndView(GROUP_GROUP_MAIN, RESPONSE, new String())); // Success refresh situation getGroupMock().setMode(ModeEnum.MODE_SUCCESS); getMockMvc() .perform( get(FETCH_LIST) .param("initialLoad", "false") .session(SessionAuthenticationTestUtil.getSessionTest())) .andExpect(status().isOk()) .andExpect(model().attribute(REFRESH, containsString(REFRESH))) .equals(new ModelAndView(GROUP_GROUP_MAIN, RESPONSE, new String())); }
/** * Fetch update. * * @throws Exception the exception */ @Test public void fetchUpdate() throws Exception { // Success situation getGroupMock().setMode(ModeEnum.MODE_SUCCESS); getMockMvc() .perform(get(FETCH_UPDATE).session(SessionAuthenticationTestUtil.getSessionTest())) .andExpect(status().isOk()) .andExpect(model().attribute(RESPONSE, containsString("\"operationSuccess\":true"))) .equals(new ModelAndView(GROUP_GROUP_CREATE, RESPONSE, new String())); // Failure situation getGroupMock().setMode(ModeEnum.MODE_FAILURE); getMockMvc() .perform(get(FETCH_UPDATE).session(SessionAuthenticationTestUtil.getSessionTest())) .andExpect(status().isOk()) .andExpect( model().attribute(RESPONSE, containsString(TestMessageEnum.MESSAGE_ERROR.getValue()))) .equals(new ModelAndView(GROUP_GROUP_CREATE, RESPONSE, new String())); }