List of usage examples for org.springframework.web.servlet ModelAndView getViewName
@Nullable
public String getViewName()
From source file:com.formkiq.core.service.workflow.WorkflowServiceImplTest.java
/** * transition to NEXT final step and final step throw error. * @throws Exception Exception//from w w w .j a va2 s .co m */ @Test public void testTransition08() throws Exception { // given testTransition01(); resetAll(); // when expect(this.calculatorService.applyFieldValues(this.archive, this.form, this.req)) .andReturn(Collections.emptyMap()); expect(this.validatorService.validateFormJSON(this.archive, this.form)).andReturn(Collections.emptyMap()); expect(this.folderService.saveForm(this.folder, this.archive, null, false)) .andThrow(new RuntimeException()); replayAll(); ModelAndView result = this.ws.transition(this.req).getLeft(); // then verifyAll(); assertEquals("redirect:/flow/workflow?execution=s1e2", result.getViewName()); }
From source file:com.formkiq.core.service.workflow.WorkflowServiceImplTest.java
/** * transition to NEXT final step.//from w ww.ja v a2s . co m * @throws Exception Exception */ @Test public void testTransition05() throws Exception { // given FormSaveResult saveResult = new FormSaveResult(null, "", Collections.emptyMap()); testTransition01(); resetAll(); // when expect(this.calculatorService.applyFieldValues(this.archive, this.form, this.req)) .andReturn(Collections.emptyMap()); expect(this.validatorService.validateFormJSON(this.archive, this.form)).andReturn(Collections.emptyMap()); expect(this.folderService.saveForm(this.folder, this.archive, null, false)).andReturn(saveResult); replayAll(); ModelAndView result = this.ws.transition(this.req).getLeft(); // then verifyAll(); assertEquals("redirect:/flow/workflow?execution=s1e3", result.getViewName()); }
From source file:com.formkiq.core.service.workflow.WorkflowServiceImplTest.java
/** * transition to NEXT final step and final step and has errors. * @throws Exception Exception/* w ww . j a v a 2 s.co m*/ */ @Test public void testTransition09() throws Exception { // given Map<String, String> errors = ImmutableMap.of("k1", "k2"); FormSaveResult saveResult = new FormSaveResult(null, "", errors); testTransition01(); resetAll(); // when expect(this.calculatorService.applyFieldValues(this.archive, this.form, this.req)) .andReturn(Collections.emptyMap()); expect(this.validatorService.validateFormJSON(this.archive, this.form)).andReturn(Collections.emptyMap()); expect(this.folderService.saveForm(this.folder, this.archive, null, false)).andReturn(saveResult); replayAll(); ModelAndView result = this.ws.transition(this.req).getLeft(); // then verifyAll(); assertEquals("redirect:/flow/workflow?execution=s1e2", result.getViewName()); }
From source file:com.formkiq.core.service.workflow.WorkflowServiceImplTest.java
/** * transition to NEXT.//from ww w . j ava 2 s .c o m * @throws Exception Exception */ @Test public void testTransition01() throws Exception { // given Map<String, String> errors = Collections.emptyMap(); testStart01(); resetAll(); this.req.addParameter("_eventId_next", ""); this.req.setParameter("execution", "s1e1"); // when expect(this.calculatorService.applyFieldValues(this.archive, this.form, this.req)) .andReturn(Collections.emptyMap()); expect(this.validatorService.validateFormJSON(this.archive, this.form)).andReturn(errors); replayAll(); ModelAndView result = this.ws.transition(this.req).getLeft(); // then verifyAll(); assertEquals("redirect:/flow/workflow?execution=s1e2", result.getViewName()); }
From source file:com.formkiq.core.service.workflow.WorkflowServiceImplTest.java
/** * transition to NEXT fails validation./*ww w. j a v a2 s .c o m*/ * @throws Exception Exception */ @Test public void testTransition06() throws Exception { // given Map<String, String> errors = ImmutableMap.of("k1", "v1"); testStart01(); resetAll(); this.req.addParameter("_eventId_next", ""); this.req.setParameter("execution", "s1e1"); // when expect(this.calculatorService.applyFieldValues(this.archive, this.form, this.req)) .andReturn(Collections.emptyMap()); expect(this.validatorService.validateFormJSON(this.archive, this.form)).andReturn(errors); replayAll(); ModelAndView result = this.ws.transition(this.req).getLeft(); // then verifyAll(); assertEquals("redirect:/flow/workflow?execution=s1e1", result.getViewName()); }
From source file:com.formkiq.core.service.workflow.WorkflowServiceImplTest.java
/** * testStart01()./*from w w w . jav a 2 s .c om*/ * Start New Flow * @throws Exception Exception */ @Test public void testStart01() throws Exception { // given // when ModelAndView result = expectStart(this.form).getLeft(); // then verifyAll(); assertEquals("redirect:/flow/workflow?execution=s1e1", result.getViewName()); int i = 0; final int stateCount = 4; this.req.addParameter("execution", "s1e1"); WebFlow flow = FlowManager.get(this.req); assertEquals(stateCount, flow.getStates().size()); assertNull(flow.getStates().get(i).getViewName()); assertNull(flow.getStates().get(i).getData()); assertEquals(FlowStateType.START, flow.getStates().get(i++).getType()); assertEquals("flow/workflow", flow.getStates().get(i).getViewName()); assertNotNull(flow.getStates().get(i).getData()); assertEquals(FlowStateType.DEFAULT, flow.getStates().get(i++).getType()); assertEquals("flow/workflow", flow.getStates().get(i).getViewName()); assertNotNull(flow.getStates().get(i).getData()); assertEquals(FlowStateType.DEFAULT, flow.getStates().get(i++).getType()); assertEquals("flow/complete", flow.getStates().get(i).getViewName()); assertNull(flow.getStates().get(i).getData()); assertEquals(FlowStateType.END, flow.getStates().get(i++).getType()); }
From source file:org.openmrs.module.radiology.web.controller.RadiologyObsFormControllerTest.java
/** * @see RadiologyObsFormController#saveObs(HttpServletRequest,HttpServletResponse,String,RadiologyOrder,Obs,BindingResult) * @verifies return populated model and view for obs *//* w ww . j a va2 s.co m*/ @Test public void saveObs_shouldReturnPopulatedModelAndViewForObs() throws Exception { //given mockRequest.addParameter("saveObs", "saveObs"); when(obsService.saveObs(mockObs, "Test Edit Reason")).thenReturn(RadiologyTestData.getEditedMockObs()); ModelAndView modelAndView = radiologyObsFormController.saveObs(mockRequest, 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=" + RadiologyTestData.getEditedMockObs().getId())); }
From source file:org.openmrs.module.radiology.web.controller.RadiologyObsFormControllerTest.java
/** * @see RadiologyObsFormController#voidObs(HttpServletRequest,HttpServletResponse,RadiologyOrder,Obs,String) * @verifies void obs for given request, response, radiologyOrder, obs, and voidReason *//*from w w w . j ava 2 s .com*/ @Test public void voidObs_shouldVoidObsForGivenRequestResponseRadiologyOrderObsAndVoidReason() throws Exception { //given mockRequest.addParameter("voidObs", "voidObs"); ModelAndView modelAndView = radiologyObsFormController.voidObs(mockRequest, null, mockRadiologyOrder, mockObs, "Test Void Reason"); assertThat(mockSession.getAttribute(WebConstants.OPENMRS_MSG_ATTR), is(notNullValue())); assertThat((String) mockSession.getAttribute(WebConstants.OPENMRS_MSG_ATTR), is("Obs.voidedSuccessfully")); assertThat((String) modelAndView.getViewName(), is("redirect:" + RADIOLOGY_OBS_FORM_URL + "orderId=" + mockRadiologyOrder.getId() + "&obsId=" + mockObs.getId())); }
From source file:com.formkiq.core.service.workflow.WorkflowServiceImplTest.java
/** * transition to NEXT final step with DOCSIGNMSG. * @throws Exception Exception/* w w w .j a va 2s . c o m*/ */ @Test public void testTransition07() throws Exception { // given String html = "<html></html>"; String workflowname = "Sample"; byte[] bytes = Strings.getBytes(html); FormJSON docsignResult = new FormJSON(); docsignResult.setUUID(UUID.randomUUID().toString()); List<String> steps = new ArrayList<>(); String userid = UUID.randomUUID().toString(); testTransition01(); resetAll(); WebFlow flow = FlowManager.get(this.req); Map<String, Object> map = ImmutableMap.of("flow", flow); flow.setParameter("docsignmsg", this.docmsg); assertNotNull(flow); FormSaveResult saveResult = new FormSaveResult(null, "", Collections.emptyMap()); // when expect(this.calculatorService.applyFieldValues(this.archive, this.form, this.req)) .andReturn(Collections.emptyMap()); expect(this.validatorService.validateFormJSON(this.archive, this.form)).andReturn(Collections.emptyMap()); expect(this.docmsg.getUserid()).andReturn(userid); expect(this.securityService.login(userid)).andReturn(this.user); expect(this.archive.getWorkflow()).andReturn(this.workflow); expect(this.signingService.createDocsignResult(this.req, this.workflow)).andReturn(docsignResult); expect(this.workflow.getSteps()).andReturn(steps); this.archive.addForm(docsignResult); expect(this.printRender.generateHTML(this.req, "flow/print", map)).andReturn(html); expect(this.printRender.createPDF(html)).andReturn(bytes); expect(this.workflow.getUUID()).andReturn(workflowname); this.archive.addPDF(workflowname + ".pdf", bytes); expect(this.folderService.saveForm(this.folder, this.archive, null, false)).andReturn(saveResult); this.securityService.logout(); replayAll(); ModelAndView result = this.ws.transition(this.req).getLeft(); // then verifyAll(); assertEquals("redirect:/flow/workflow?execution=s1e3", result.getViewName()); assertEquals(1, steps.size()); assertEquals(docsignResult.getUUID(), steps.get(0)); }
From source file:com.formkiq.core.service.workflow.WorkflowServiceImplTest.java
/** * transition to NEXT final step with DOCSIGNMSG with validation errors. * Test roll back/*from w w w .j a va 2s .c o m*/ * @throws Exception Exception */ @Test public void testTransition10() throws Exception { // given String html = "<html></html>"; String workflowname = "Sample"; byte[] bytes = Strings.getBytes(html); FormJSON docsignResult = new FormJSON(); docsignResult.setUUID(UUID.randomUUID().toString()); List<String> steps = new ArrayList<>(); String userid = UUID.randomUUID().toString(); testTransition01(); resetAll(); WebFlow flow = FlowManager.get(this.req); Map<String, Object> map = ImmutableMap.of("flow", flow); flow.setParameter("docsignmsg", this.docmsg); assertNotNull(flow); Map<String, String> errors = ImmutableMap.of("k1", "k2"); FormSaveResult saveResult = new FormSaveResult(null, "", errors); // when expect(this.calculatorService.applyFieldValues(this.archive, this.form, this.req)) .andReturn(Collections.emptyMap()); expect(this.validatorService.validateFormJSON(this.archive, this.form)).andReturn(Collections.emptyMap()); expect(this.docmsg.getUserid()).andReturn(userid); expect(this.securityService.login(userid)).andReturn(this.user); expect(this.archive.getWorkflow()).andReturn(this.workflow).times(2); expect(this.signingService.createDocsignResult(this.req, this.workflow)).andReturn(docsignResult); expect(this.workflow.getSteps()).andReturn(steps).times(2); this.archive.addForm(docsignResult); expect(this.printRender.generateHTML(this.req, "flow/print", map)).andReturn(html); expect(this.printRender.createPDF(html)).andReturn(bytes); expect(this.workflow.getUUID()).andReturn(workflowname); this.archive.addPDF(workflowname + ".pdf", bytes); expect(this.folderService.saveForm(this.folder, this.archive, null, false)).andReturn(saveResult); this.archive.removeForm(docsignResult); this.securityService.logout(); replayAll(); ModelAndView result = this.ws.transition(this.req).getLeft(); // then verifyAll(); assertEquals("redirect:/flow/workflow?execution=s1e2", result.getViewName()); assertEquals(0, steps.size()); }