Example usage for org.springframework.ui ModelMap ModelMap

List of usage examples for org.springframework.ui ModelMap ModelMap

Introduction

In this page you can find the example usage for org.springframework.ui ModelMap ModelMap.

Prototype

public ModelMap() 

Source Link

Document

Construct a new, empty ModelMap .

Usage

From source file:org.ngrinder.monitor.controller.MonitorControllerTest.java

@Test
public void testMonitorData() throws ParseException, IOException {
    ModelMap model = new ModelMap();
    String monitorIP = "127.0.0.1";
    long mockTestId = 1234567890;
    String mockPath = String.valueOf(mockTestId) + File.separator + "report";
    File mockTestReportFile = new ClassPathResource(mockPath).getFile();

    // set a mock home object to let it find the sample monitor file.
    Home realHome = config.getHome();//from   w w w. j a  va2s.c o m
    Home mockHome = mock(Home.class);
    when(mockHome.getPerfTestReportDirectory(String.valueOf(mockTestId))).thenReturn(mockTestReportFile);
    ReflectionTestUtils.setField(config, "home", mockHome);

    String rtnStr = monitorController.getMonitorData(model, mockTestId, monitorIP, 700);
    LOG.debug("Monitor data for ip:{} is\n{}", "127.0.0.1", rtnStr);

    // reset the home object
    ReflectionTestUtils.setField(config, "home", realHome);
}

From source file:org.openmrs.web.controller.person.PersonAttributeTypeListControllerTest.java

License:asdf

/**
 * @see PersonAttributeTypeListController#displayPage(ModelMap)
 *///from w w w  .j a va  2s . c o m
@Test
@Verifies(value = "should not fail if not authenticated", method = "displayPage(ModelMap)")
public void displayPage_shouldNotFailIfNotAuthenticated() throws Exception {
    Context.logout();
    new PersonAttributeTypeListController().displayPage(new ModelMap());
}

From source file:com.asual.summer.core.ErrorController.java

@ResponseViews({ AbstractResponseView.class, StringView.class })
public ModelAndView error(Exception ex) {

    Writer stringWriter = new StringWriter();
    PrintWriter printWriter = new PrintWriter(stringWriter);
    ex.printStackTrace(printWriter);/*from w w w  .  j  ava  2s . c om*/

    ModelMap model = new ModelMap();
    model.addAttribute("error", ex);
    model.addAttribute("stackTrace", stringWriter.toString());
    return new ModelAndView("/error", model);
}

From source file:cz.muni.fi.mir.controllers.RevisionController.java

@RequestMapping(value = { "/", "/list/", "/list" }, method = RequestMethod.GET)
@SiteTitle("{navigation.revision.list}")
public ModelAndView list() {
    ModelMap mm = new ModelMap();
    mm.addAttribute("revisionList", revisionService.getAllRevisions());

    return new ModelAndView("revision_list", mm);
}

From source file:cz.muni.fi.mir.controllers.UserRoleController.java

@RequestMapping(value = { "/", "/list", "/list/" }, method = RequestMethod.GET)
@SiteTitle("{navigation.userrole.list}")
public ModelAndView list() {
    ModelMap mm = new ModelMap();
    mm.addAttribute("userRoleList", userRoleService.getAllUserRoles());

    return new ModelAndView("userrole_list", mm);
}

From source file:org.openmrs.module.formfilter.web.controller.FormFilterManageControllerTest.java

/**
 * @see {@link FormFilterManageController#manage(ModelMap)}
 *//*  w  w w .ja  v  a2 s .  c  om*/
@Test
@Verifies(value = "should return FormList ", method = "manage(ModelMap)")
public void manage_shouldReturnFormList() {
    FormFilterManageController controller = new FormFilterManageController();
    ModelMap model = new ModelMap();
    controller.manage(model);
    //TODO return form list using FormFilterManageController#manage 
    Assert.assertEquals(0, ((List<Form>) model.get("formList")).size());
}

From source file:eu.jasha.demo.sbtfragments.CityControllerTest.java

@Before
public void setup() throws Exception {
    controller = new CityController(cityDao);

    modelMap = new ModelMap();
    city = new City(CITY_ID, "Sim City", 2016, 123_456);
}

From source file:cz.muni.fi.mir.controllers.SourceDocumentController.java

@RequestMapping(value = { "/", "/list", "/list/" }, method = RequestMethod.GET)
@SiteTitle("{navigation.sourcedocument.list}")
public ModelAndView list() {
    ModelMap mm = new ModelMap();
    mm.addAttribute("sourceDocumentList", sourceDocumentService.getAllDocuments());

    return new ModelAndView("sourcedocument_list", mm);
}

From source file:se.vgregion.portal.patientcontext.ConfigurationControllerTest.java

@Test
public void testView() throws Exception {
    ModelMap model = new ModelMap();
    MockPortletPreferences mockPrefs = new MockPortletPreferences();

    String result = controller.view(model, mockPrefs);

    assertTrue(model.containsAttribute("configure"));
    ConfigurationFormBean formBean = (ConfigurationFormBean) model.get("configure");
    assertEquals(formBean.getGroupCode(), PatientEvent.DEFAULT_GROUP_CODE);

    assertEquals(result, ConfigurationController.EDIT_JSP);
}

From source file:cz.muni.fi.mir.controllers.ConfigurationController.java

@RequestMapping(value = { "/", "/list", "/list/" }, method = RequestMethod.GET)
@SiteTitle("{navigation.configuration.list}")
public ModelAndView list() {
    ModelMap mm = new ModelMap();
    mm.addAttribute("configurationList", configurationService.getAllCofigurations());

    return new ModelAndView("configuration_list", mm);
}