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:com.callcenter.controller.RecordingLibraryServiceControllerTest.java

@Test
public void shouldSetAllFieldsInTheModel() {
    final ArrayList<Field> fields = new ArrayList<Field>();
    new NonStrictExpectations() {
        @Mocked//from   www . j  a va2 s.  co  m
        Field field = null;
        @Mocked
        RecordingLibraryService recordingLibraryService = null;
        {
            Field.findAllFields();
            returns(fields);
        }
    };
    final ModelMap modelMap = new ModelMap();
    controller.createForm(modelMap);
    assertSame(fields, modelMap.get("fields"));
}

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

@RequestMapping(value = "banks/all_banks", method = RequestMethod.GET)
public @ResponseBody ModelMap allBanks() {
    ModelMap mv = new ModelMap();

    mv.addAttribute("allBanks", bankService.getAll());

    return mv;//from   w ww.  ja v a 2  s .c  om
}

From source file:fragment.web.AbstractProfilesControllerTest.java

/**
 * Author: vinayv Description: Test to get ServiceProvider and Customer users profiles with profileId
 *//*from   www .  j  av a2 s. c om*/
@SuppressWarnings("unchecked")
@Test
public void testShowProfilesWithProfileId() {

    map = new ModelMap();
    String result = profilesController.showProfiles("2", null, map);
    Assert.assertNotNull(result);
    Assert.assertEquals("profiles.show", result);
    List<ProfileForm> allProfileList = (List<ProfileForm>) map.get("allProfileList");
    Assert.assertNotNull(allProfileList);
    Assert.assertEquals(profileDAO.count(), allProfileList.size());
    List<Profile> globalProfileList = (List<Profile>) profileService.listAllProfilesOfClass(Scope.GLOBAL);
    List<ProfileForm> opsProfileList = (List<ProfileForm>) map.get("opsProfileList");
    Assert.assertEquals(globalProfileList.size(), opsProfileList.size());
    List<Profile> tenantProfileList = (List<Profile>) profileService.listAllProfilesOfClass(Scope.TENANT);
    List<ProfileForm> nonOpsProfileList = (List<ProfileForm>) map.get("nonOpsProfileList");
    Assert.assertEquals(tenantProfileList.size(), nonOpsProfileList.size());
    String profileID = (String) map.get("selectedProfile");
    Assert.assertEquals("2", profileID);
}

From source file:com.pkrete.locationservice.admin.controller.mvc.AddShelfController.java

@RequestMapping(method = RequestMethod.POST)
public ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response,
        @ModelAttribute("shelf") Shelf shelf, BindingResult result) throws Exception {

    shelf.setAreas(parseAreas(request, shelf));
    super.parseSubjectMatters(request, shelf);
    validator.validate(shelf, result);/*from  ww w .  j  a v  a2 s  .c om*/

    if (result.hasErrors()) {
        ModelMap model = new ModelMap();
        super.setReferenceData(request, model);
        return new ModelAndView("add_shelf", model);
    }

    String libraryId = request.getParameter("select_library");
    String collectionId = request.getParameter("select_collection");
    shelf.setCreator(getUser(request).getUsername());
    if (!locationsService.create(shelf)) {
        throw new Exception("Creating shelf failed.");
    }

    return new ModelAndView(
            "redirect:locations.htm?" + "select_library=" + libraryId + "&select_collection=" + collectionId);
}

From source file:ask.springboot.controller.CityController.java

@RequestMapping(value = "/save", method = RequestMethod.POST)
public ModelMap save(City city) {
    ModelMap result = new ModelMap();
    String msg = city.getId() == null ? "?!" : "?!";
    cityService.save(city);/*from   w w w.j  ava 2  s .c o m*/
    result.put("city", city);
    result.put("msg", msg);
    return result;
}

From source file:org.ngrinder.agent.controller.AgentManagerControllerTest.java

@SuppressWarnings("unchecked")
@Test/*www.  j av  a2s.c o m*/
public void testGetAgentList() {

    ModelMap model = new ModelMap();
    agentController.getAll("", model);

    // create a temp download dir and file for this function
    File directory = config.getHome().getDownloadDirectory();
    if (!directory.exists()) {
        try {
            FileUtils.forceMkdir(directory);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    File tmpDownFile;
    try {
        tmpDownFile = File.createTempFile("ngrinder", "zip", directory);
        FileUtils.writeStringToFile(tmpDownFile, "test data");
        tmpDownFile.deleteOnExit();
    } catch (IOException e) {
        e.printStackTrace();
    }

    model.clear();
    agentController.getAll("", model);
    Collection<AgentInfo> agents = (Collection<AgentInfo>) model.get("agents");
}

From source file:org.ahp.vinavidai.test.controller.TakeTest.java

@RequestMapping(method = RequestMethod.POST, params = "submitAction=Next Question")
public ModelAndView nextQuestion(@ModelAttribute("takeTest") TakeTestCommand pTakeTestCommand) {
    System.out.println("hi");
    int lCurrentQuestionNumber = pTakeTestCommand.getCurrentQuestionNumber() + 1;
    Question lCurrentQuestion = pTakeTestCommand.getQuestionList().get(lCurrentQuestionNumber);
    ModelMap lModelMap = new ModelMap();
    return new ModelAndView("/test/TakeTest.jsp", "testModel", lModelMap);
}

From source file:org.openmrs.web.controller.patient.PatientDashboardControllerTest.java

/**
 * @see PatientDashboardController#renderDashboard(Integer,ModelMap,HttpServletRequest)
 * @verifies render patient dashboard if given patient id is an existing id
 *///from   ww  w  .j  a va  2s. c o  m
@Test
public void renderDashboard_shouldRenderPatientDashboardIfGivenPatientIdIsAnExistingId() throws Exception {

    MockHttpServletRequest request = new MockHttpServletRequest();
    ModelMap map = new ModelMap();

    String view = patientDashboardController.renderDashboard(EXISTING_PATIENT_ID, map, request);

    assertThat(view, is(PATIENT_DASHBOARD_VIEW));

    assertThat(map, hasKey("patient"));
    Patient patient = (Patient) map.get("patient");
    assertThat(patient.getPatientId(), is(Integer.valueOf(EXISTING_PATIENT_ID)));

    assertNull(request.getSession().getAttribute(WebConstants.OPENMRS_ERROR_ATTR));
    assertNull(request.getSession().getAttribute(WebConstants.OPENMRS_ERROR_ARGS));
}

From source file:se.vgregion.portal.medcontrol.MedControlViewControllerTest.java

@Test
public void testNullUserId() {
    // PortletPreferences
    mockPortletConfig.setResourceBundle(new Locale("sv"), null);
    ModelMap model = new ModelMap();
    assertEquals("medcontrol",
            medControlViewController.showMedControlNotifications(model, mockRenderRequest, mockRenderResponse));
    assertEquals(0, ((List) model.get("mine")).size());
}

From source file:com.mtt.myapp.home.controller.HomeControllerTest.java

@Test
public void testLogin() {
    ModelMap model = new ModelMap();
    String viewName = homeController.loginForm(model);
    assertThat(viewName).isEqualTo("redirect:/");
}