List of usage examples for org.springframework.ui ModelMap ModelMap
public ModelMap()
From source file:fragment.web.SupportControllerTest.java
@Before public void init() { prepareMock(true, new BootstrapActivator()); setMockHandlersInSupportService();/*ww w .ja v a2 s. c o m*/ map = new ModelMap(); request = new MockHttpServletRequest(); tenant = createTestTenant(accountTypeDAO.getDefaultRegistrationAccountType(), new Date()); tenant.setSourceChannel(channelService.getDefaultServiceProviderChannel()); user = createTestUserInTenant(tenant); tenant.setOwner(user); tenantDAO.save(tenant); List<TicketStatus> listTicketStatus = new ArrayList<Ticket.TicketStatus>(); listTicketStatus.add(TicketStatus.NEW); listTicketStatus.add(TicketStatus.CLOSED); listTicketStatus.add(TicketStatus.ESCALATED); listTicketStatus.add(TicketStatus.WORKING); List<User> users = new ArrayList<User>(); users.add(user); supportService.list(0, 0, listTicketStatus, users, "", "", new HashMap<String, String>()).clear(); createTestTicket(5, tenant, user); }
From source file:com.trenako.web.controllers.admin.AdminOptionsControllerTests.java
@Test public void shouldCreateNewOptions() throws IOException { ModelMap model = new ModelMap(); Option option = postedForm().buildOption(); when(bindingResult.hasErrors()).thenReturn(false); String viewName = controller.create(postedForm(), bindingResult, model, redirectAtts); assertEquals("redirect:/admin/options", viewName); verify(service, times(1)).save(eq(option)); }
From source file:cz.muni.fi.mir.controllers.ConfigurationController.java
@RequestMapping(value = { "/view/{id}", "/view/{id}/" }, method = RequestMethod.GET) @SiteTitle("{entity.configuration.view}") public ModelAndView viewConfiguration(@PathVariable Long id) { ModelMap mm = new ModelMap(); mm.addAttribute("configurationEntry", configurationService.getConfigurationByID(id)); return new ModelAndView("configuration_view", mm); }
From source file:org.ngrinder.user.controller.UserControllerTest.java
@Test public void testUpdate() { // test update the role of current user. ModelMap model = new ModelMap(); User currUser = getTestUser();//from w ww .j av a2 s . co m assertThat(currUser.getRole(), is(Role.USER)); // current test user is "USER" User updatedUser = new User(currUser.getUserId(), currUser.getUserName(), currUser.getPassword(), "temp@nhn.com", currUser.getRole()); updatedUser.setId(currUser.getId()); updatedUser.setEmail("test@test.com"); updatedUser.setRole(Role.ADMIN); // Attempt to modify himself as ADMIN userController.save(currUser, updatedUser, model); userController.getOne(currUser.getUserId(), model); User user = (User) model.get("user"); assertThat(user.getUserName(), is(currUser.getUserName())); assertThat(user.getPassword(), is(currUser.getPassword())); assertThat(user.getRole(), is(Role.USER)); }
From source file:org.ngrinder.perftest.controller.PerfTestControllerTest.java
@Test public void testDeleteTests() { String testName = "test1"; PerfTest test = createPerfTest(testName, Status.READY, new Date()); ModelMap model = new ModelMap(); controller.delete(getTestUser(), String.valueOf(test.getId())); model.clear();//from w ww . j av a 2s .co m PerfTest test1 = createPerfTest(testName, Status.READY, new Date()); PerfTest test2 = createPerfTest(testName, Status.READY, new Date()); String delIds = "" + test1.getId() + "," + test2.getId(); controller.delete(getTestUser(), delIds); model.clear(); controller.getOne(getTestUser(), test1.getId(), model); assertThat(((PerfTest) model.get(PARAM_TEST)).getId(), nullValue()); model.clear(); controller.getOne(getTestUser(), test2.getId(), model); assertThat(((PerfTest) model.get(PARAM_TEST)).getId(), nullValue()); }
From source file:au.org.ala.layers.web.TabulationService.java
@RequestMapping(value = WS_TABULATION_LIST, method = RequestMethod.GET) public ModelAndView listAvailableTabulationsHtml(HttpServletRequest req, HttpServletResponse resp) throws IOException { List<Tabulation> tabulations = tabulationDao.listTabulations(); ModelMap m = new ModelMap(); m.addAttribute("tabulations", tabulations); return new ModelAndView("tabulations/list", m); }
From source file:game.kalaha.test.ModelControlTest.java
@Test public void testBoardGui() { ModelMap model = new ModelMap(); String functionReturn = controller.board(model); assertNotNull("Board image is NULL", model.get("boardimg")); assertNotEquals("Board image empty", "", model.get("boardimg")); assertEquals("View unexpected", "board", functionReturn); }
From source file:org.openmrs.module.patientflags.web.FindFlaggedPatientsController.java
@RequestMapping(method = RequestMethod.GET, params = "flagId") public ModelAndView processSubmit(@ModelAttribute("flag") Flag flag, BindingResult result, SessionStatus status) {//from w ww . j ava 2s.com if (result.hasErrors()) { return new ModelAndView("/module/patientflags/findFlaggedPatients"); } // get all Patients that trigger the selected Flag FlagService flagService = Context.getService(FlagService.class); flag = flagService.getFlag(flag.getFlagId()); Cohort flaggedPatients = flagService.getFlaggedPatients(flag); Cohort allPatients = Context.getPatientSetService().getAllPatients(); // create the model map ModelMap model = new ModelMap(); model.addAttribute("flag", flag); model.addAttribute("allPatients", allPatients); List<Map<String, Object>> fpl = new ArrayList<Map<String, Object>>(); if (flaggedPatients != null) { Set<Integer> idsFp = flaggedPatients.getMemberIds(); for (Integer patientId : idsFp) { Map<String, Object> mapFp = new HashMap<String, Object>(); mapFp.put("patientId", patientId); mapFp.put("flagMessage", flag.evalMessage(patientId)); fpl.add(mapFp); } } model.addAttribute("flaggedPatients", fpl); model.addAttribute("patientLink", Context.getAdministrationService() .getGlobalProperty("patientflags.defaultPatientLink", PatientFlagsConstants.DEFAULT_PATIENT_LINK)); // clears the command object from the session status.setComplete(); // displays the query results return new ModelAndView("/module/patientflags/findFlaggedPatientsResults", model); }
From source file:org.energyos.espi.thirdparty.web.AuthorizationControllerTests.java
@Test @Ignore// w ww . ja v a 2 s . co m public void authorization_returnsAuthorizationList() throws Exception { List<Authorization> authorizations = new ArrayList<>(); authorizations.add(new Authorization()); when(service.findAllByRetailCustomerId(anyLong())).thenReturn(authorizations); ModelMap model = new ModelMap(); controller.authorization(CODE, authorization.getState(), model, principal, CODE, CODE, CODE); assertEquals(authorizations, model.get("authorizationList")); }
From source file:com.trenako.web.controllers.ReviewsControllerTests.java
@Test public void shouldPostNewReviews() { String slug = "acme-123456"; ModelMap model = new ModelMap(); when(mockResult.hasErrors()).thenReturn(false); when(mockRsService.findBySlug(eq(slug))).thenReturn(rollingStock()); when(mockUserContext.getCurrentUser()).thenReturn(new AccountDetails(author())); String redirect = controller.postReview(postedForm(), mockResult, model, mockRedirectAtts); assertEquals("redirect:/rollingstocks/{slug}/reviews", redirect); ArgumentCaptor<Review> arg = ArgumentCaptor.forClass(Review.class); verify(mockService, times(1)).postReview(eq(rollingStock()), arg.capture()); Review review = (Review) arg.getValue(); assertEquals(author().getSlug(), review.getAuthor()); assertEquals("My title", review.getTitle()); assertEquals("My content", review.getContent()); assertEquals(3, review.getRating()); verify(mockRsService, times(1)).findBySlug(eq(slug)); verify(mockUserContext, times(1)).getCurrentUser(); verify(mockRedirectAtts, times(1)).addAttribute(eq("slug"), eq(rollingStock().getSlug())); verify(mockRedirectAtts, times(1)).addFlashAttribute(eq("message"), eq(ReviewsController.REVIEW_POSTED_MSG)); }