List of usage examples for org.springframework.ui ModelMap ModelMap
public ModelMap()
From source file:org.openmrs.contrib.metadatarepository.webapp.controller.PackageFormControllerTest.java
@Test public void testRemove() throws Exception { request = newPost("/packageform"); request.addParameter("delete", ""); pkg = new MetadataPackage(); pkg.setId(1L);//from w ww . j a v a2s .c o m BindingResult errors = new DataBinder(pkg).getBindingResult(); form.onSubmit(pkg, errors, request, new MockHttpServletResponse(), new ModelMap()); assertNotNull(request.getSession().getAttribute("successMessages")); }
From source file:com.trenako.web.controllers.CommentsControllerTests.java
@Test public void shouldRedirectAfterValidationErrorsDuringCommentPosting() { when(mockResult.hasErrors()).thenReturn(true); ModelMap model = new ModelMap(); String redirect = controller.postComment(commentForm(), mockResult, model, mockRedirectAtts); assertEquals("redirect:/rollingstocks/{slug}", redirect); assertEquals(commentForm(), (CommentForm) model.get("commentForm")); verify(mockService, times(0)).postComment(eq(rollingStock()), eq(comment())); }
From source file:org.openmrs.module.sync.web.controller.HistoryListControllerTest.java
@Test public void shouldResetSelectedRecordsAsIgnore() throws Exception { executeDataSet("org/openmrs/module/sync/include/SyncHistoryListRecords.xml"); executeDataSet("org/openmrs/module/sync/include/SyncServerRecords-others.xml"); SyncService syncService = Context.getService(SyncService.class); String uuids = "e1165fef-f3ae-411a-8de8-cb07419f90a4 c7c38315-285d-471a-94cd-1fdc71a5459b 2d49b210-f25d-4d55-a6b0-7588680b0fb7"; String[] uuidArray = uuids.split(" "); for (String uuid : uuidArray) { Assert.assertEquals(SyncRecordState.NEW, syncService.getSyncRecord(uuid).getState()); }//w ww. jav a 2 s . c o m final String newServerRecordId = "103"; String ids = "101 102 " + newServerRecordId; String[] idsArray = ids.split(" "); for (String id : idsArray) { SyncServerRecord serverRecord = syncService.getSyncServerRecord(Integer.valueOf(id)); if (id.equals(newServerRecordId)) { Assert.assertEquals(SyncRecordState.NEW, serverRecord.getState()); } else { Assert.assertEquals(SyncRecordState.FAILED, serverRecord.getState()); } } HistoryListController controller = new HistoryListController(); controller.historyResetRemoveRecords(new ModelMap(), new MockHttpServletRequest(), uuids, ids, "remove", 1, 1); for (String uuid : uuidArray) { Assert.assertEquals(SyncRecordState.NOT_SUPPOSED_TO_SYNC, syncService.getSyncRecord(uuid).getState()); } for (String id : idsArray) { Integer idInt = Integer.valueOf(id); Assert.assertEquals(SyncRecordState.NOT_SUPPOSED_TO_SYNC, syncService.getSyncServerRecord(idInt).getState()); } }
From source file:com.pkrete.locationservice.admin.controller.mvc.EditLibraryController.java
@RequestMapping(method = RequestMethod.POST) public ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, @ModelAttribute("library") Library library, BindingResult result) throws Exception { library.setAreas(parseAreas(request, library)); validator.validate(library, result); if (result.hasErrors()) { ModelMap model = new ModelMap(); this.setReferenceData(request, model); return new ModelAndView("edit_library", model); }/*from w w w. ja va 2s . co m*/ library.setUpdater(getUser(request).getUsername()); if (!locationsService.update(library)) { throw new Exception("Updating library failed."); } return new ModelAndView("redirect:locations.htm?select_library=" + request.getParameter("select_library")); }
From source file:com.pkrete.locationservice.admin.controller.mvc.AddMapController.java
@RequestMapping(method = RequestMethod.POST) public ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, @ModelAttribute("map") Map map, BindingResult result) throws Exception { Owner owner = getOwner(request); // Set creator map.setCreator(getUser(request).getUsername()); // Set owner//from w w w .j a v a 2s. co m map.setOwner(owner); validator.validate(map, result); if (result.hasErrors()) { ModelMap modelMap = new ModelMap(); modelMap.put("files", mapsService.getAdminMaps(owner)); modelMap.put("languages", Language.toMap(owner.getLanguages())); return new ModelAndView("add_map", modelMap); } // Save to DB if (!mapsService.create(map)) { throw new Exception("Creating map failed."); } return new ModelAndView("redirect:illustrations.htm"); }
From source file:game.kalaha.test.ModelControlTest.java
@Test public void testRetrieveBox() { ModelMap model = new ModelMap(); String functionReturn = controller.retrieveBox(0, 0, model); assertEquals("Function return unexpected", "board_status", functionReturn); assertTrue("No stonecount in the model", model.containsKey("stonecount")); }
From source file:org.agatom.springatom.cmp.wizards.core.AbstractStepHelper.java
@Override public ModelMap initialize(final Locale locale) throws Exception { return new ModelMap(); }
From source file:org.cloudfoundry.identity.uaa.oauth.AccessControllerTests.java
@SuppressWarnings("unchecked") @Test//from w ww .ja v a 2s .c o m public void testSchemePreserved() throws Exception { InMemoryClientDetailsService clientDetailsService = new InMemoryClientDetailsService(); clientDetailsService.setClientDetailsStore(Collections.singletonMap("client", new BaseClientDetails())); controller.setClientDetailsService(clientDetailsService); controller.setApprovalStore(Mockito.mock(ApprovalStore.class)); MockHttpServletRequest request = new MockHttpServletRequest(); request.setScheme("https"); request.addHeader("Host", "foo"); ModelMap model = new ModelMap(); model.put("authorizationRequest", new DefaultAuthorizationRequest("client", null)); Authentication auth = UaaAuthenticationTestFactory.getAuthentication("foo@bar.com", "Foo Bar", "foo@bar.com"); controller.confirm(model, request, auth, new SimpleSessionStatus()); Map<String, Object> options = (Map<String, Object>) ((Map<String, Object>) model.get("options")) .get("confirm"); assertEquals("https://foo/oauth/authorize", options.get("location")); assertEquals("/oauth/authorize", options.get("path")); }
From source file:com.forexnepal.controller.HomeController.java
@RequestMapping(value = "/exchange_rates", method = RequestMethod.GET) public @ResponseBody ModelMap allExchangeRates() { ModelMap map = new ModelMap(); map.addAttribute("allExchangeRates", exchangeRatesService.getAll()); return map;//from w ww . j ava 2 s . co m }
From source file:ask.springboot.controller.UserInfoController.java
@RequestMapping(value = "/save", method = RequestMethod.POST) public ModelMap save(UserInfo userInfo) { ModelMap result = new ModelMap(); String msg = userInfo.getId() == null ? "?!" : "?!"; userInfoService.save(userInfo);// w w w .ja v a 2s .c o m result.put("userInfo", userInfo); result.put("msg", msg); return result; }