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.perftest.controller.PerfTestControllerTest.java

@SuppressWarnings("unchecked")
@Test//from   www . j  a v a  2s  .co  m
public void testGetTestList() {
    createPerfTest("new test1", Status.READY, new Date());
    ModelMap model = new ModelMap();
    controller.getAll(getTestUser(), null, null, null, new PageRequest(0, 10), model);
    Page<PerfTest> testPage = (Page<PerfTest>) model.get("testListPage");
    List<PerfTest> testList = testPage.getContent();
    assertThat(testList.size(), is(1));
}

From source file:fragment.web.AbstractManageResourceControllerTest.java

/**
 * @author Abhaik/*from w w  w.j av a  2  s. c om*/
 * @description : Test to get the SSO Cmd for an Active Tenant having Null SSO Handler through Service Provider User
 */
@Test
public void testSSOFromSPUserForSsoHandlerIsNull() {

    request = new MockHttpServletRequest();
    response = new MockHttpServletResponse();
    map = new ModelMap();
    Tenant systemTenant = tenantService.getSystemTenant();
    Tenant tenant = tenantdao.find(2L);
    ServiceInstance instance = serviceInstanceDao.find(1L);
    request.setAttribute("effectiveTenant", tenant);
    request.setAttribute("isSurrogatedTenant", isSurrogatedTenant(systemTenant, tenant.getParam()));

    Map<String, String> resultMap = controller.getSSOCmdString(systemTenant, tenant.getParam(),
            instance.getUuid(), map, request, response);
    Assert.assertNotNull(resultMap);

    String status = resultMap.get("status");
    Assert.assertEquals("success", status);

    String cmdString = resultMap.get("cmdString");
    Assert.assertNull(cmdString);

}

From source file:com.forexnepal.controller.HomeController.java

@RequestMapping(value = "/exchange_rates/{currencyId}/{bankId}", method = RequestMethod.GET)
public @ResponseBody ModelMap ExchangeRtaesByCurrencyBank(@PathVariable(value = "currencyId") int currencyId,
        @PathVariable(value = "bankId") int bankId) {
    ModelMap map = new ModelMap();
    map.addAttribute("trendCurrencyBank",
            exchangeRatesService.getExchangeRatesByCurrencyBank(currencyId, bankId));
    return map;/*w w  w .j a  va 2  s  .  co  m*/
}

From source file:fragment.web.AbstractProductsControllerTest.java

@Before
public void init() throws Exception {

    map = new ModelMap();
    request = new MockHttpServletRequest();
    response = new MockHttpServletResponse();
}

From source file:fragment.web.AbstractConnectorControllerTest.java

@Test
public void testShowCloudServices() throws Exception {
    map = new ModelMap();
    setValidServiceAndServiceInstance();
    String viewService = controller.showCloudServices(validServiceUuid, "", "view", map);
    Assert.assertTrue(map.containsAttribute("viewServiceDetails"));
    Assert.assertEquals(map.get("page"), Page.HOME_CONNECTORS_CS);
    Assert.assertEquals("main.home_service.details", viewService);

    map = new ModelMap();
    String viewServiceInstance = controller.showCloudServices("", validServiceInstanceUuid, "view", map);
    Assert.assertTrue(map.containsAttribute("instance"));
    Assert.assertTrue(map.containsAttribute("service"));
    Assert.assertTrue(map.containsAttribute("instance_properties"));
    Assert.assertEquals("main.home_cs.instance.edit", viewServiceInstance);

    map = new ModelMap();
    String viewCloudServices = controller.showCloudServices("", "", "view", map);
    Assert.assertTrue(map.containsAttribute("categories"));
    Assert.assertTrue(map.containsAttribute("services"));
    Assert.assertEquals(map.get("page"), Page.HOME_CONNECTORS_CS);
    Assert.assertEquals("main.home_connector_cs_admin", viewCloudServices);

}

From source file:com.trenako.web.controllers.RollingStocksControllerTests.java

@Test
public void shouldRedirectAfterValidationErrorsDuringRollingStocksCreation() {
    when(mockResult.hasErrors()).thenReturn(true);
    when(mockFile.isEmpty()).thenReturn(true);
    RollingStockForm form = rsForm(mockFile);

    ModelMap model = new ModelMap();

    String viewName = controller.create(form, mockResult, model, mockRedirect);

    assertEquals("rollingstock/new", viewName);
    assertNotNull("Form is null", model.get("rollingStockForm"));
}

From source file:org.esupportail.portlet.filemanager.portlet.PortletControllerAction.java

@RequestMapping(value = { "VIEW" }, params = { "action=fileUploadWai" })
public ModelAndView fileUploadWai(RenderRequest request, RenderResponse response, @RequestParam String dir) {

    ModelMap model = new ModelMap();
    model.put("currentDir", dir);
    return new ModelAndView("view-portlet-upload-wai", model);
}

From source file:nl.surfnet.coin.teams.control.AbstractControllerTest.java

@Before
public void setup() throws Exception {
    this.request = new MockHttpServletRequest();
    this.modelMap = new ModelMap();
    setUpSession(request);/*from   w ww  .  j av a 2 s .  c  om*/
}

From source file:org.ngrinder.perftest.controller.PerfTestControllerTest.java

@Test
public void testGetTestListByAdmin() {
    String testName = "new test1";
    createPerfTest(testName, Status.READY, new Date());
    ModelMap model = new ModelMap();
    User testAdmin = new User();
    testAdmin.setUserId("testAdmin");
    testAdmin.setPassword("testAdmin");
    testAdmin.setRole(Role.ADMIN);
    testAdmin.setTimeZone("Asia/Seoul");
    testAdmin = userService.save(testAdmin);

    controller.getAll(testAdmin, null, null, null, new PageRequest(0, 10), model);
    @SuppressWarnings("unchecked")
    Page<PerfTest> testPage = (Page<PerfTest>) model.get("testListPage");
    List<PerfTest> testList = testPage.getContent();
    boolean success = false;
    for (PerfTest perfTest : testList) {
        if (perfTest.getTestName().equals(testName)) {
            success = true;/*  w  ww . j av  a 2  s . c  o m*/
        }
    }
    assertTrue(success);
}

From source file:com.Voxce.Controllers.TrialsController.java

public ModelAndView ShowTrainingType(HttpServletRequest request, HttpServletResponse response)
        throws Exception {

    CurrentUser = (Users) request.getSession().getAttribute("CurrentUser");
    if (CurrentUser == null) {
        response.sendRedirect("login.htm");
    }/* ww  w . ja  v  a2 s. co  m*/

    List<Training> traininglist;

    try {

        int studyid = Integer.parseInt(request.getParameter("studyid"));

        List<studies> li = studiesdao.getStudyDetail(studyid);
        currentstudy = li.get(0);
        traininglist = trainingdao.listtrainings(currentstudy.getStudy_id());
        CurrentUser = (Users) request.getSession().getAttribute("CurrentUser");
        ModelMap modelMap = new ModelMap();
        modelMap.addAttribute("currentstudy", currentstudy);
        modelMap.addAttribute("traininglist", traininglist);
        int form = Integer.parseInt(request.getParameter("train_type_form"));
        if (form == 1)
            modelMap.addAttribute("CurrentFormTrainingType", "View_Training_div");
        else
            modelMap.addAttribute("CurrentFormTrainingType", "Create_Training_div");

        return new ModelAndView("training_type", modelMap);
    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
        response.sendRedirect("login.htm");
    }

    return new ModelAndView("training_type", new ModelMap());
}