List of usage examples for org.springframework.ui ModelMap ModelMap
public ModelMap()
From source file:info.raack.appliancedetection.evaluation.web.SimulationController.java
@RequestMapping(value = "/simulationcontrolpanel/{id}/{algorithmId}", method = RequestMethod.GET) public ModelAndView showSimulationControlPanelWithSimulationPreloaded(@PathVariable("id") String simulationId, @PathVariable("algorithmId") String algorithmName, HttpServletRequest request, HttpServletResponse response) {// ww w . j a v a 2 s .c om ModelMap modelMap = new ModelMap(); modelMap.put("simulations", simulationService.getAllSimulationInformation()); modelMap.put("algorithms", new ArrayList<ApplianceEnergyConsumptionDetectionAlgorithm>(algorithms)); modelMap.put("simulationIdToPreload", simulationId); modelMap.put("algorithmNameToPreload", algorithmName); return new ModelAndView("controlPanel", modelMap); }
From source file:com.trenako.web.controllers.RollingStocksControllerTests.java
@Test public void shouldRenderRollingStockCreationViews() { ModelMap model = new ModelMap(); String viewName = controller.createNew(model); assertEquals("rollingstock/new", viewName); RollingStockForm form = (RollingStockForm) model.get("rollingStockForm"); assertEquals(new RollingStock(), form.getRs()); }
From source file:org.motechproject.server.omod.web.controller.MotechModuleFormControllerTest.java
public void testLookupTroubledPhoneNoPhone() { String phone = null;/* w w w . j av a 2 s.co m*/ ModelMap model = new ModelMap(); String path = controller.handleTroubledPhone(phone, null, model); assertNull(model.get("troubledPhone")); assertEquals("/module/motechmodule/troubledphone", path); }
From source file:fragment.web.AbstractConnectorControllerTest.java
@Test public void testShowOSSServices() throws Exception { map = new ModelMap(); setValidServiceAndServiceInstance(); String viewService = controller.showOSSServices(validServiceUuid, "", "view", map); Assert.assertTrue(map.containsAttribute("viewServiceDetails")); Assert.assertEquals(map.get("page"), Page.HOME_CONNECTORS_OSS); Assert.assertEquals("main.home_oss.instance.edit", viewService); map = new ModelMap(); String confService = controller.showOSSServices(validServiceUuid, "", "", map); Assert.assertTrue(map.containsAttribute("service_config_properties")); Assert.assertEquals(map.get("page"), Page.HOME_CONNECTORS_OSS); Assert.assertEquals("main.home_oss.instance.edit", confService); map = new ModelMap(); String viewServiceInstance = controller.showOSSServices("", validServiceInstanceUuid, "view", map); Assert.assertTrue(map.containsAttribute("instance")); Assert.assertTrue(map.containsAttribute("service")); Assert.assertTrue(map.containsAttribute("instance_properties")); Assert.assertEquals(map.get("page"), Page.HOME_CONNECTORS_OSS); Assert.assertEquals("main.home_oss.instance.edit", viewServiceInstance); /*/* w w w .j a v a 2s.c om*/ * map = new ModelMap(); String viewOSSServices = controller.showOSSServices("", "", "view", map); * Assert.assertTrue(map.containsAttribute("instance")); Assert.assertTrue(map.containsAttribute("service")); * Assert.assertEquals(map.get("page"), Page.HOME_CONNECTORS_OSS); Assert.assertEquals("main.home_connector_oss", * viewOSSServices); */ }
From source file:fragment.web.AbstractProfilesControllerTest.java
/** * Author: vinayv Description: Test to edit profiles logging in as User *//* w w w . jav a2 s .c om*/ @Test public void testEditProfilesAsUser() { try { User user = userDAO.find(3L); asUser(user); map = new ModelMap(); String authorityNames = ",ROLE_TICKET_MANAGEMENT"; profilesController.editProfile(map, "4", authorityNames); } catch (Exception e) { Assert.assertEquals("Access is denied", e.getMessage()); } }
From source file:nl.surfnet.coin.selfservice.control.HomeController.java
@RequestMapping("/idp.shtml") public ModelAndView idp(HttpServletRequest httpServletRequest) { InstitutionIdentityProvider currentIdp = getSelectedIdp(httpServletRequest); ModelMap model = new ModelMap(); addRoleAssignmentsToModel(currentIdp, model); addOfferedServiceToModel(currentIdp, model); return new ModelAndView("idp", model); }
From source file:org.esupportail.portlet.filemanager.portlet.PortletControllerAction.java
@RequestMapping(value = { "VIEW" }, params = { "action=renameWai" }) public ModelAndView renameWai(RenderRequest request, RenderResponse response, @RequestParam String dir, @RequestParam List<String> dirs) { dir = pathEncodingUtils.decodeDir(dir); dirs = pathEncodingUtils.decodeDirs(dirs); ModelMap model = new ModelMap(); List<JsTreeFile> files = this.serverAccess.getChildren(dir, userParameters); List<JsTreeFile> filesToRename = new ArrayList<JsTreeFile>(); if (!dirs.isEmpty()) { for (JsTreeFile file : files) { if (dirs.contains(file.getPath())) filesToRename.add(file); }/*ww w. j a v a 2 s . com*/ } else { filesToRename = files; } model.put("files", filesToRename); pathEncodingUtils.encodeDir(files); model.put("currentDir", pathEncodingUtils.encodeDir(dir)); return new ModelAndView("view-portlet-rename-wai", model); }
From source file:fragment.web.WorkflowControllerTest.java
@Before public void init() throws Exception { map = new ModelMap(); request = new MockHttpServletRequest(); status = new MockSessionStatus(); }
From source file:org.esupportail.dining.web.controllers.ViewController.java
@RequestMapping("/meals") public ModelAndView renderMealsView(@RequestParam(value = "id", required = true) int id) throws Exception { ModelMap model = new ModelMap(); User user = this.authenticator.getUser(); try {// w ww.j a v a 2s . c om ResultSet prefUser = this.dc .executeQuery("SELECT NUTRITIONCODE FROM nutritionPreferences WHERE USERNAME='" + StringEscapeUtils.escapeSql(user.getLogin()) + "';"); Set<String> nutritionPrefs = new HashSet<String>(); while (prefUser.next()) { nutritionPrefs.add(prefUser.getString("NUTRITIONCODE")); } model.put("nutritionPrefs", nutritionPrefs); } catch (SQLException e) { /**/ } catch (NullPointerException e) { /* * Useful is the user isn't logged * in */ } try { Restaurant restaurant = this.cache.getCachedDining(id); model.put("restaurant", restaurant); List<Manus> menuList = new ArrayList<Manus>(); Date dateNow = new Date(); for (Manus m : restaurant.getMenus()) { Date dateMenu = new SimpleDateFormat("yyyy-MM-dd").parse(m.getDate()); // We only send upcomings menu to the view if (dateMenu.compareTo(dateNow) >= 0) { menuList.add(m); } } model.put("menus", menuList); if (this.feed.isClosed(restaurant)) { model.put("restaurantClosed", true); } } catch (Exception e) { return new ModelAndView("error", new ModelMap("err", e.getMessage())); } try { ResultSet results = this.dc.executeQuery("SELECT * FROM FAVORITERESTAURANT WHERE USERNAME='" + StringEscapeUtils.escapeSql(user.getLogin()) + "' AND RESTAURANTID='" + id + "';"); if (results.next()) { model.put("isFavorite", true); } } catch (NullPointerException e) { /* * Useful is the user isn't logged * in */ } return new ModelAndView("meals", model); }
From source file:org.ngrinder.perftest.controller.PerfTestControllerTest.java
/** * for "saved" or "ready" test, can be modified, but for running or finished test, can not * modify//from w w w .j a v a2 s . c o m */ @Test public void testSavePerfTestExist() { String testName = "test1"; String newName = "new test1"; PerfTest test = createPerfTest(testName, Status.READY, new Date()); test.setTestName(newName); PerfTest newTest = new PerfTest(); newTest.setId(test.getId()); newTest.setTestName(newName); newTest.setStatus(Status.SAVED); newTest.setThreshold(test.getThreshold()); newTest.setDuration(test.getDuration()); newTest.setVuserPerAgent(test.getVuserPerAgent()); newTest.setScheduledTime(test.getScheduledTime()); newTest.setIgnoreSampleCount(test.getIgnoreSampleCount()); newTest.setTargetHosts(test.getTargetHosts()); newTest.setScriptName(test.getScriptName()); newTest.setProcesses(2); newTest.setThreads(2); newTest.setVuserPerAgent(newTest.getProcesses() * newTest.getThreads()); newTest.setRegion(config.getRegion()); newTest.setAgentCount(1); ModelMap model = new ModelMap(); controller.saveOne(getTestUser(), newTest, false, model); controller.getOne(getTestUser(), newTest.getId(), model); PerfTest testInDB = (PerfTest) model.get(PARAM_TEST); assertThat(testInDB.getTestName(), is(newName)); assertThat(testInDB.getId(), is(test.getId())); model.clear(); newTest.setStatus(Status.READY); controller.saveOne(getTestUser(), newTest, false, model); controller.getOne(getTestUser(), newTest.getId(), model); testInDB = (PerfTest) model.get(PARAM_TEST); assertThat(testInDB.getTestName(), is(newName)); assertThat(testInDB.getId(), is(test.getId())); // test status id "START_TESTING", can not be saved. newTest.setStatus(Status.START_TESTING); try { newTest.setStatus(Status.START_TESTING); controller.saveOne(getTestUser(), newTest, false, model); fail("test status id START_TESTING, can not be saved"); } catch (IllegalArgumentException e) { } }