List of usage examples for org.springframework.ui ModelMap ModelMap
public ModelMap()
From source file:org.energyos.espi.datacustodian.web.custodian.RetailCustomerUsagePointControllerTests.java
@Test public void form_setsUsagePointModel() { ModelMap model = new ModelMap(); controller.form(1L, model);//from w ww.j a v a2 s . com assertEquals(AssociateUsagePointController.UsagePointForm.class, model.get("usagePointForm").getClass()); }
From source file:org.openmrs.module.formfilter.web.controller.ViewFormFilterControllerTest.java
/** * @see {@link ViewFormFilterController#viewFormFilter(ModelMap, Integer, Integer)} *//*w w w . ja v a 2s. co m*/ @Test @Verifies(value = "should return FormFilter by form id", method = "viewFormFilter(ModelMap, Integer, Integer)") public void viewFormFilter_ShouldReturnFormFilterByFormId() { ViewFormFilterController controller = new ViewFormFilterController(); ModelMap model = new ModelMap(); controller.viewFormFilter(model, "1", null); Assert.assertNotNull(((FormFilter) model.get("formfilter"))); }
From source file:se.vgregion.portal.patientcontext.SearchControllerTest.java
@Before public void setUp() throws Exception { controller = new SearchController(); model = new ModelMap(); }
From source file:org.openmrs.web.controller.person.PersonAttributeTypeListControllerTest.java
License:asdf
/** * @see PersonAttributeTypeListController#displayPage(ModelMap) */// w ww . j av a 2 s .co m @SuppressWarnings("unchecked") @Test @Verifies(value = "should put all attribute types into map", method = "displayPage(ModelMap)") public void displayPage_shouldPutAllAttributeTypesIntoMap() throws Exception { ModelMap map = new ModelMap(); new PersonAttributeTypeListController().displayPage(map); List<PersonAttributeType> alltypes = (List<PersonAttributeType>) map.get("personAttributeTypeList"); Assert.assertEquals(3, alltypes.size()); }
From source file:org.openmrs.module.formfilter.web.controller.PersonFormFilterEntryPortletControllerTest.java
/** * @see {@link PersonFormFilterEntryPortletController#populateModel(HttpServletRequest, Map)} *///from w w w . ja v a2 s .c o m @Test @Verifies(value = "should return FormList", method = "populateModel(HttpServletRequest, Map)") public void populateModel_shouldReturnFormList() { PersonFormFilterEntryPortletController controller = new PersonFormFilterEntryPortletController(); ModelMap model = new ModelMap(); MockHttpServletRequest request = new MockHttpServletRequest(); model.addAttribute("patient", Context.getPatientService().getPatient(2)); model.addAttribute("person", Context.getPersonService().getPerson(2)); controller.populateModel(request, model); //TODO return form list using PersonFormFilterEntryPortletController#populateModel Assert.assertEquals(0, ((Map<Form, FormEntryHandler>) model.get("formToEntryUrlMap")).size()); }
From source file:com.mtt.myapp.home.controller.HomeControllerTest.java
@Test public void testHome() { MockHttpServletResponse res = new MockHttpServletResponse(); MockHttpServletRequest req = new MockHttpServletRequest(); CookieLocaleResolver localeResolver = new CookieLocaleResolver(); req.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, localeResolver); User testUser2 = getTestUser();//from www . j a v a 2s .c o m testUser2.setUserLanguage("EN"); ModelMap model = new ModelMap(); String viewName = homeController.home(testUser2, null, null, model, res, req); assertThat(viewName).isEqualTo("index"); User testUserError = Mockito.spy(testUser2); Mockito.when(testUserError.getRole()).thenReturn(Role.SYSTEM_USER); viewName = homeController.home(testUserError, "Test Error message!", null, model, res, req); assertThat(viewName).isEqualTo("login"); }
From source file:org.esupportail.dining.web.controllers.AbstractExceptionController.java
@ExceptionHandler(Exception.class) public final ModelAndView handleException(final Exception ex) { logger.error("Exception catching in spring mvc controller ... ", ex); ModelMap model = new ModelMap(); ByteArrayOutputStream output = new ByteArrayOutputStream(); PrintStream print = new PrintStream(output); ex.printStackTrace(print);// ww w . j ava2 s . c o m String exceptionStackTrace = new String(output.toByteArray()); model.put("exceptionStackTrace", exceptionStackTrace); model.put("exceptionMessage", ex.getMessage()); return new ModelAndView("exception", model); }
From source file:com.github.britter.springbootherokudemo.HomeControllerTest.java
@Before public void setUp() throws Exception { map = new ModelMap(); repository = mock(RecordRepository.class); ctrl = new HomeController(repository); }
From source file:org.ngrinder.user.controller.UserControllerTest.java
/** * Test method for/* w ww . j a v a 2 s .c o m*/ * {@link org.ngrinder.user.controller.UserController#getAll(org.springframework.ui.ModelMap, org.ngrinder.model.Role, * org.springframework.data.domain.Pageable, java.lang.String)} * . */ @Test public void testGetAll() { Pageable page = new PageRequest(1, 10); ModelMap model = new ModelMap(); userController.getAll(model, null, page, null); model.clear(); userController.getAll(model, Role.ADMIN, page, null); model.clear(); userController.getAll(model, null, page, "user"); }
From source file:org.ngrinder.home.controller.HomeControllerTest.java
@Test public void testHome() { MockHttpServletResponse res = new MockHttpServletResponse(); MockHttpServletRequest req = new MockHttpServletRequest(); CookieLocaleResolver localeResolver = new CookieLocaleResolver(); req.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, localeResolver); User testUser2 = getTestUser();/*from ww w . j a v a 2s . c om*/ testUser2.setUserLanguage("EN"); ModelMap model = new ModelMap(); String viewName = homeController.home(testUser2, null, null, model, res, req); assertThat(viewName, is("index")); User testUserError = Mockito.spy(testUser2); Mockito.when(testUserError.getRole()).thenReturn(Role.SYSTEM_USER); viewName = homeController.home(testUserError, "Test Error message!", null, model, res, req); assertThat(viewName, is("login")); }