List of usage examples for org.springframework.ui ModelMap ModelMap
public ModelMap()
From source file:org.openmrs.web.controller.patient.PatientDashboardControllerTest.java
/** * @see PatientDashboardController#renderDashboard(Integer,ModelMap,HttpServletRequest) * @verifies render patient dashboard if given patient id is an existing uuid *///from w w w. java 2 s.c o m // @Test public void renderDashboard_shouldRenderPatientDashboardIfGivenPatientIdIsAnExistingUuid() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest(); ModelMap map = new ModelMap(); String view = patientDashboardController.renderDashboard(EXISTING_PATIENT_UUID, map, request); assertThat(view, is(PATIENT_DASHBOARD_VIEW)); assertThat(map, hasKey("patient")); Patient patient = (Patient) map.get("patient"); assertThat(patient.getUuid(), is(EXISTING_PATIENT_UUID)); assertNull(request.getSession().getAttribute(WebConstants.OPENMRS_ERROR_ATTR)); assertNull(request.getSession().getAttribute(WebConstants.OPENMRS_ERROR_ARGS)); }
From source file:com.callcenter.controller.RecordingLibraryServiceControllerTest.java
@Test public void shouldGetTheServiceBasedOnTheIdentifier( final @NonStrict RecordingLibraryService recordingLibraryService) { final RecordingLibraryService service = new RecordingLibraryService(); new NonStrictExpectations() { {/*from ww w . j a v a 2s .c o m*/ RecordingLibraryService.findRecordingLibraryService(1233L); returns(service); } }; final ModelMap map = new ModelMap(); controller.show(1233L, map); assertSame(service, map.get("service")); }
From source file:info.gehrels.voting.web.CastVoteController.java
private ModelAndView createModelAndView(BallotBuilder ballotBuilder, BallotInputTry firstOrSecondTry) { ModelMap modelMap = new ModelMap(); modelMap.addAttribute("ballotLayout", ballotLayoutState.ballotLayout); modelMap.addAttribute("ballotBuilder", ballotBuilder); modelMap.addAttribute("firstOrSecondTry", firstOrSecondTry); return new ModelAndView("castVote", modelMap); }
From source file:se.vgregion.portal.medcontrol.MedControlViewControllerTest.java
@Test public void testFatalErrorView() { // PortletPreferences ModelMap model = new ModelMap(); Map<String, String> attributeMap = new HashMap<String, String>(); attributeMap.put(PortletRequest.P3PUserInfos.USER_LOGIN_ID.toString(), "myUserId"); mockRenderRequest.setAttribute(PortletRequest.USER_INFO, attributeMap); mockDeviationService.throwException = true; assertEquals("fatal_error", medControlViewController.showMedControlNotifications(model, mockRenderRequest, mockRenderResponse)); }
From source file:org.energyos.espi.thirdparty.web.AuthorizationControllerTests.java
@Test @Ignore//from w w w . jav a 2 s.c o m public void authorization_updatesAuthorization() throws Exception { controller.authorization(CODE, authorization.getState(), new ModelMap(), principal, CODE, CODE, CODE); verify(service).merge(any(Authorization.class)); }
From source file:org.motechproject.server.omod.web.controller.MotechModuleFormControllerTest.java
public void testViewBlackoutForm() throws ParseException { Time startTime = Time.valueOf("07:00:00"), endTime = Time.valueOf("19:00:00"); Blackout interval = new Blackout(startTime, endTime); expect(contextService.getMotechService()).andReturn(motechService); expect(motechService.getBlackoutSettings()).andReturn(interval); replay(contextService, motechService); ModelMap model = new ModelMap(); String path = controller.viewBlackoutSettings(model); verify(contextService, motechService); assertEquals("/module/motechmodule/blackout", path); assertEquals(model.get("startTime"), startTime); assertEquals(model.get("endTime"), endTime); }
From source file:fragment.web.HomeControllerTest.java
@Before public void init() { map = new ModelMap(); request = new MockHttpServletRequest(); session = new MockHttpSession(); }
From source file:com.asual.summer.sample.web.TechnologyController.java
@RequestMapping("/{value}/edit") public ModelAndView edit(@PathVariable("value") String value) { Technology technology = Technology.find(value); if (technology == null) { throw new ViewNotFoundException(); }//from w ww . j av a 2 s. c om ModelMap model = new ModelMap(); model.addAllAttributes(Arrays.asList(technology, License.list(), Status.list())); return new ModelAndView("/edit", model); }
From source file:cz.muni.fi.mir.controllers.InstallController.java
@RequestMapping(value = "/step2/", method = RequestMethod.POST) public ModelAndView step2(HttpServletRequest request) { String username = null;/*from ww w .j a v a2s . c o m*/ String email = null; String pass1 = null; String passVerify = null; try { username = ServletRequestUtils.getStringParameter(request, "username"); email = ServletRequestUtils.getStringParameter(request, "email"); pass1 = ServletRequestUtils.getStringParameter(request, "password"); passVerify = ServletRequestUtils.getStringParameter(request, "passwordVerify"); } catch (ServletRequestBindingException ex) { logger.error(ex); } if (Tools.getInstance().stringIsEmpty(username)) { ModelMap mm = new ModelMap(); mm.addAttribute("email", email); return new ModelAndView("setup/step1", mm); } else if (Tools.getInstance().stringIsEmpty(email)) { ModelMap mm = new ModelMap(); mm.addAttribute("username", username); return new ModelAndView("setup/step1", mm); } else if (pass1 != null && !pass1.equals(passVerify)) { ModelMap mm = new ModelMap(); mm.addAttribute("email", email); mm.addAttribute("username", username); return new ModelAndView("setup/step1", mm); } else { List<UserRole> roles = userRoleService.getAllUserRoles(); if (Tools.getInstance().isEmpty(roles)) { UserRole ur1 = EntityFactory.createUserRole("ROLE_ADMINISTRATOR"); UserRole ur2 = EntityFactory.createUserRole("ROLE_USER"); userRoleService.createUserRole(ur1); userRoleService.createUserRole(ur2); roles = new ArrayList<>(); roles.add(ur1); roles.add(ur2); } User u = EntityFactory.createUser(username, pass1, username, email, roles); User u2 = EntityFactory.createUser("system", null, "system", "webmias@fi.muni.cz", roles); u.setPassword(Tools.getInstance().SHA1(u.getPassword())); userService.createUser(u); userService.createUser(u2); revisionService.createRevision( EntityFactory.createRevision(revisionValue, "Default revision created by install process.")); // config should be outside controller, but its run only once per // aplication setup so it does not matter somehow InputStream is = InstallController.class.getClassLoader() .getResourceAsStream("other/sample-config-1.1SNAP.xml"); Configuration config = null; try { String xmlContent = IOUtils.toString(is); config = EntityFactory.createConfiguration(xmlContent, "sample-config-1.1SNAP", "Default configuration created by install process."); logger.info("Loaded sample config"); logger.info(xmlContent); } catch (IOException ex) { logger.error(ex); } finally { if (is != null) { try { is.close(); } catch (IOException ex) { logger.error(ex); } } } if (config != null) { configurationService.createConfiguration(config); } for (AnnotationValue av : provideAnnotaionValues()) { annotationValueSerivce.createAnnotationValue(av); } mailService.sendMail(null, email, "Installation is now complete.", "Installation of MathCanEval application has ended. Below are user credentials submited in setup process.\n" + "Username: " + username + "\nPassword: " + passVerify); return new ModelAndView("redirect:/"); } }
From source file:se.vgregion.portal.iframe.controller.CSViewControllerTest.java
@Test public void testShowView() throws ReadOnlyException { PortletPreferences prefs = new MockPortletPreferences(); initPortletPreferences(prefs);//from w ww.j av a2 s. c o m RenderRequest mockReq = new MockRenderRequest(PortletMode.VIEW); RenderResponse mockResp = new MockRenderResponse(); ModelMap model = new ModelMap(); String response = controller.showView(prefs, mockReq, mockResp, model); assertEquals("userCredentialForm", response); }