List of usage examples for org.springframework.web.servlet ModelAndView getViewName
@Nullable
public String getViewName()
From source file:org.openmrs.module.radiology.web.controller.RadiologyObsFormControllerTest.java
/** * @see RadiologyObsFormController#saveComplexObs(MultipartHttpServletRequest,HttpServletResponse,String,RadiologyOrder,Obs,BindingResult) * @verifies populate model and view with obs for occuring Exception *//*ww w . j av a 2 s . c o m*/ @Test public void saveComplexObs_shouldPopulateModelAndViewWithObsForOccuringException() throws Exception { APIException apiException = new APIException("Test Exception Handling"); when(obsService.saveObs(mockObs, "Test Edit Reason")).thenThrow(apiException); ModelAndView modelAndView = radiologyObsFormController.saveComplexObs( mockMultipartHttpServletRequestRequest, null, "Test Edit Reason", mockRadiologyOrder, mockObs, obsErrors); assertThat((String) mockSession.getAttribute(WebConstants.OPENMRS_ERROR_ATTR), is("Test Exception Handling")); assertThat(modelAndView, is(notNullValue())); assertThat(modelAndView.getViewName(), is("module/radiology/radiologyObsForm")); assertThat(modelAndView.getModelMap(), hasKey("obs")); Obs obs = (Obs) modelAndView.getModelMap().get("obs"); assertThat(obs, is(mockObs)); }
From source file:com.formkiq.core.service.workflow.WorkflowServiceImplTest.java
/** * testStart03()./* w w w.j a va 2 s .co m*/ * ID Barcode form * @throws Exception Exception */ @Test public void testStart03() throws Exception { // given FormJSON idbarcode = TestDataBuilder.createIdBarcode(); List<String> steps = Arrays.asList(idbarcode.getUUID()); // when expect(this.archiveService.get(this.folder, this.uuid, true)) .andReturn(Pair.of(this.archive, UUID.randomUUID().toString())); expect(this.archive.getWorkflow()).andReturn(this.workflow); expect(this.workflow.getSteps()).andReturn(steps); expect(this.archive.getForm(idbarcode.getUUID())).andReturn(idbarcode); replayAll(); ModelAndView result = this.ws.start(this.req, WorkflowEditorServiceImpl.class, this.folder, this.uuid) .getLeft(); // then verifyAll(); assertEquals("redirect:/flow/workflow?execution=s1e1", result.getViewName()); }
From source file:org.openmrs.module.radiology.web.controller.RadiologyObsFormControllerTest.java
/** * @see RadiologyObsFormController#saveComplexObs(MultipartHttpServletRequest,HttpServletResponse,String,RadiologyOrder,Obs,BindingResult) * @verifies return populated model and view for complex obs *//* w w w . j av a 2s.co m*/ @Test public void saveComplexObs_shouldReturnPopulatedModelAndViewForComplexObs() throws Exception { //given Obs editedMockObs = RadiologyTestData.getEditedMockObs(); when(obsService.saveObs(mockObs, "Test Edit Reason")).thenReturn(editedMockObs); ModelAndView modelAndView = radiologyObsFormController.saveComplexObs( mockMultipartHttpServletRequestRequest, null, "Test Edit Reason", mockRadiologyOrder, mockObs, obsErrors); assertThat(mockSession.getAttribute(WebConstants.OPENMRS_MSG_ATTR), is(notNullValue())); assertThat((String) mockSession.getAttribute(WebConstants.OPENMRS_MSG_ATTR), is("Obs.saved")); assertThat(modelAndView.getViewName(), is("redirect:" + RADIOLOGY_OBS_FORM_URL + "orderId=" + mockRadiologyOrder.getId() + "&obsId=" + editedMockObs.getId())); }
From source file:net.nicholaswilliams.java.teamcity.plugin.buildNumber.TestSharedBuildNumberController.java
@Test public void testDoHandleListPage01() throws IOException, ServletException { this.setUpSecurity(); SortedSet<SharedBuildNumber> set = new TreeSet<SharedBuildNumber>(); expect(this.request.getParameter("action")).andReturn(null); expect(this.request.getMethod()).andReturn("GET"); expect(this.request.getParameter("direction")).andReturn(null); expect(this.request.getParameter("sort")).andReturn(null); expect(this.service.getAllSharedBuildNumbersSortedById(false)).andReturn(set); replay(this.service, this.request, this.response); ModelAndView modelAndView = this.controller.doHandle(this.request, this.response); assertNotNull("The model and view should not be null.", modelAndView); assertEquals("The view is not correct.", "/plugin/" + testNum + "/jsp/list.jsp", modelAndView.getViewName()); Map<String, Object> model = modelAndView.getModel(); assertNotNull("The model should not be null.", model); assertEquals("sortedBy is not correct.", "id", model.get("sortedBy")); assertEquals("sortClass is not correct.", "sortedAsc", model.get("sortClass")); assertEquals("sortChange is not correct.", "desc", model.get("sortChange")); assertEquals("sbnParameterPrefix is not correct.", BuildNumberPropertiesProvider.PARAMETER_PREFIX, model.get("sbnParameterPrefix")); assertEquals("numResults is not correct.", 0, model.get("numResults")); assertSame("buildNumbers is not correct.", set, model.get("buildNumbers")); }
From source file:net.nicholaswilliams.java.teamcity.plugin.buildNumber.TestSharedBuildNumberController.java
@Test public void testDoHandleListPage02() throws IOException, ServletException { this.setUpSecurity(); SortedSet<SharedBuildNumber> set = new TreeSet<SharedBuildNumber>(); expect(this.request.getParameter("action")).andReturn(""); expect(this.request.getMethod()).andReturn("GET"); expect(this.request.getParameter("direction")).andReturn(null); expect(this.request.getParameter("sort")).andReturn(null); expect(this.service.getAllSharedBuildNumbersSortedById(false)).andReturn(set); replay(this.service, this.request, this.response); ModelAndView modelAndView = this.controller.doHandle(this.request, this.response); assertNotNull("The model and view should not be null.", modelAndView); assertEquals("The view is not correct.", "/plugin/" + testNum + "/jsp/list.jsp", modelAndView.getViewName()); Map<String, Object> model = modelAndView.getModel(); assertNotNull("The model should not be null.", model); assertEquals("sortedBy is not correct.", "id", model.get("sortedBy")); assertEquals("sortClass is not correct.", "sortedAsc", model.get("sortClass")); assertEquals("sortChange is not correct.", "desc", model.get("sortChange")); assertEquals("sbnParameterPrefix is not correct.", BuildNumberPropertiesProvider.PARAMETER_PREFIX, model.get("sbnParameterPrefix")); assertEquals("numResults is not correct.", 0, model.get("numResults")); assertSame("buildNumbers is not correct.", set, model.get("buildNumbers")); }
From source file:net.nicholaswilliams.java.teamcity.plugin.buildNumber.TestSharedBuildNumberController.java
@Test public void testDoHandleListPage03() throws IOException, ServletException { this.setUpSecurity(); SortedSet<SharedBuildNumber> set = new TreeSet<SharedBuildNumber>(); expect(this.request.getParameter("action")).andReturn("list"); expect(this.request.getMethod()).andReturn("POST"); expect(this.request.getParameter("direction")).andReturn("asc"); expect(this.request.getParameter("sort")).andReturn("id"); expect(this.service.getAllSharedBuildNumbersSortedById(false)).andReturn(set); replay(this.service, this.request, this.response); ModelAndView modelAndView = this.controller.doHandle(this.request, this.response); assertNotNull("The model and view should not be null.", modelAndView); assertEquals("The view is not correct.", "/plugin/" + testNum + "/jsp/list.jsp", modelAndView.getViewName()); Map<String, Object> model = modelAndView.getModel(); assertNotNull("The model should not be null.", model); assertEquals("sortedBy is not correct.", "id", model.get("sortedBy")); assertEquals("sortClass is not correct.", "sortedAsc", model.get("sortClass")); assertEquals("sortChange is not correct.", "desc", model.get("sortChange")); assertEquals("sbnParameterPrefix is not correct.", BuildNumberPropertiesProvider.PARAMETER_PREFIX, model.get("sbnParameterPrefix")); assertEquals("numResults is not correct.", 0, model.get("numResults")); assertSame("buildNumbers is not correct.", set, model.get("buildNumbers")); }
From source file:net.nicholaswilliams.java.teamcity.plugin.buildNumber.TestSharedBuildNumberController.java
@Test public void testDoHandleListPage04() throws IOException, ServletException { this.setUpSecurity(); SortedSet<SharedBuildNumber> set = new TreeSet<SharedBuildNumber>(); set.add(new SharedBuildNumber(12)); expect(this.request.getParameter("action")).andReturn("list"); expect(this.request.getMethod()).andReturn("POST"); expect(this.request.getParameter("direction")).andReturn("desc"); expect(this.request.getParameter("sort")).andReturn("id"); expect(this.service.getAllSharedBuildNumbersSortedById(true)).andReturn(set); replay(this.service, this.request, this.response); ModelAndView modelAndView = this.controller.doHandle(this.request, this.response); assertNotNull("The model and view should not be null.", modelAndView); assertEquals("The view is not correct.", "/plugin/" + testNum + "/jsp/list.jsp", modelAndView.getViewName()); Map<String, Object> model = modelAndView.getModel(); assertNotNull("The model should not be null.", model); assertEquals("sortedBy is not correct.", "id", model.get("sortedBy")); assertEquals("sortClass is not correct.", "sortedDesc", model.get("sortClass")); assertEquals("sortChange is not correct.", "asc", model.get("sortChange")); assertEquals("sbnParameterPrefix is not correct.", BuildNumberPropertiesProvider.PARAMETER_PREFIX, model.get("sbnParameterPrefix")); assertEquals("numResults is not correct.", 1, model.get("numResults")); assertSame("buildNumbers is not correct.", set, model.get("buildNumbers")); }
From source file:net.nicholaswilliams.java.teamcity.plugin.buildNumber.TestSharedBuildNumberController.java
@Test public void testDoHandleEditBuildNumberGet02() throws IOException, ServletException { this.setUpSecurity(); SharedBuildNumber number = new SharedBuildNumber(17); expect(this.request.getParameter("action")).andReturn("edit"); expect(this.request.getMethod()).andReturn("GET"); expect(this.request.getParameter("id")).andReturn("17"); expect(this.service.getSharedBuildNumber(17)).andReturn(number); replay(this.service, this.request, this.response); ModelAndView modelAndView = this.controller.doHandle(this.request, this.response); assertNotNull("The model and view should not be null.", modelAndView); assertEquals("The view is not correct.", "/plugin/" + testNum + "/jsp/editBuildNumber.jsp", modelAndView.getViewName()); Map<String, Object> model = modelAndView.getModel(); assertNotNull("The model should not be null.", model); assertEquals("sbnParameterPrefix is not correct.", BuildNumberPropertiesProvider.PARAMETER_PREFIX, model.get("sbnParameterPrefix")); assertSame("sharedBuildNumberForm is not correct.", number, model.get("sharedBuildNumberForm")); }
From source file:net.nicholaswilliams.java.teamcity.plugin.buildNumber.TestSharedBuildNumberController.java
@Test public void testDoHandleAddBuildNumberGet01() throws IOException, ServletException { this.setUpSecurity(); expect(this.request.getParameter("action")).andReturn("add"); expect(this.request.getMethod()).andReturn("GET"); replay(this.service, this.request, this.response); ModelAndView modelAndView = this.controller.doHandle(this.request, this.response); assertNotNull("The model and view should not be null.", modelAndView); assertEquals("The view is not correct.", "/plugin/" + testNum + "/jsp/addBuildNumber.jsp", modelAndView.getViewName()); Map<String, Object> model = modelAndView.getModel(); assertNotNull("The model should not be null.", model); Object object = model.get("sharedBuildNumberForm"); assertNotNull("sharedBuildNumberForm should not be null.", object); assertTrue("sharedBuildNumberForm should be a SharedBuildNumber.", object instanceof SharedBuildNumber); SharedBuildNumber form = (SharedBuildNumber) object; assertEquals("The format is not correct.", "{0}", form.getFormat()); assertEquals("The date format is not correct.", "yyyyMMddHHmmss", form.getDateFormat()); assertEquals("The counter is not correct.", 1, form.getCounter()); }
From source file:net.nicholaswilliams.java.teamcity.plugin.buildNumber.TestSharedBuildNumberController.java
@Test public void testDoHandleListPage06() throws IOException, ServletException { this.setUpSecurity(); SortedSet<SharedBuildNumber> set = new TreeSet<SharedBuildNumber>(new Comparator<SharedBuildNumber>() { @Override//from w w w .ja v a2 s. c o m public int compare(SharedBuildNumber left, SharedBuildNumber right) { return NumberUtils.compare(left.getId(), right.getCounter()); } }); set.add(new SharedBuildNumber(12)); set.add(new SharedBuildNumber(22)); set.add(new SharedBuildNumber(15)); expect(this.request.getParameter("action")).andReturn("list"); expect(this.request.getMethod()).andReturn("POST"); expect(this.request.getParameter("direction")).andReturn("desc"); expect(this.request.getParameter("sort")).andReturn("name"); expect(this.service.getAllSharedBuildNumbersSortedByName(true)).andReturn(set); replay(this.service, this.request, this.response); ModelAndView modelAndView = this.controller.doHandle(this.request, this.response); assertNotNull("The model and view should not be null.", modelAndView); assertEquals("The view is not correct.", "/plugin/" + testNum + "/jsp/list.jsp", modelAndView.getViewName()); Map<String, Object> model = modelAndView.getModel(); assertNotNull("The model should not be null.", model); assertEquals("sortedBy is not correct.", "name", model.get("sortedBy")); assertEquals("sortClass is not correct.", "sortedDesc", model.get("sortClass")); assertEquals("sortChange is not correct.", "asc", model.get("sortChange")); assertEquals("sbnParameterPrefix is not correct.", BuildNumberPropertiesProvider.PARAMETER_PREFIX, model.get("sbnParameterPrefix")); assertEquals("numResults is not correct.", 3, model.get("numResults")); assertSame("buildNumbers is not correct.", set, model.get("buildNumbers")); }