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.impalaframework.extension.mvc.flash.FlashHelperTest.java

@SuppressWarnings("unchecked")
public void testMergeFlashState() throws Exception {
    final ModelMap modelMap = new ModelMap();
    modelMap.put("one", "existingOne");

    HashMap<String, String> setMap = new HashMap<String, String>();
    setMap.put("one", "v1");
    setMap.put("two", "v2");
    expect(request.getAttribute("flashState")).andReturn(setMap);
    request.removeAttribute("flashState");

    replay(request, session);/* w  ww . j av  a  2 s  .  co  m*/
    adapter.mergeFlashState(request, modelMap);

    assertEquals("existingOne", modelMap.get("one"));
    assertEquals("v2", modelMap.get("two"));

    verify(request, session);
}

From source file:org.energyos.espi.thirdparty.web.AuthorizationControllerTests.java

@Test
public void index_returnsAuthorizationList() {
    List<Authorization> authorizations = new ArrayList<>();
    authorizations.add(new Authorization());
    when(service.findAllByRetailCustomerId(anyLong())).thenReturn(authorizations);
    ModelMap model = new ModelMap();

    controller.index(model, principal);//from   ww w .jav a  2  s.c  om

    assertEquals(authorizations, model.get("authorizationList"));
}

From source file:com.gvmax.web.api.WebAppAPI.java

/**
 * Returns the currently logged in user.
 *
 * @param pin/* ww  w.j  a  v  a 2 s.c om*/
 *            Pin for api access
 * @param session
 *            HTTP Session
 * @param resp
 *            HTTP Response
 * @return The user or 'response' = 'nouser'
 */
@RequestMapping(value = "/user", method = RequestMethod.GET)
@Timed
@ExceptionMetered
public ModelMap user(@RequestParam(value = "email", required = false) String email,
        @RequestParam(value = "pin", required = false) String pin, HttpSession session,
        HttpServletResponse resp) {
    try {
        User user = service.getUser(email, pin);
        if (user == null) {
            user = getUser(service, session, pin);
        }
        if (user != null) {
            user.setPassword(null);
            user.setgTalkPassword(HIDDEN_PASSWORD);
            user.setHowlPassword(HIDDEN_PASSWORD);
            Stats stats = service.getStats(user.getEmail());
            ModelMap retVal = new ModelMap();
            retVal.put("user", user);
            retVal.put("stats", stats);
            return retVal;
        }
        return new ModelMap("response", "nouser");
    } catch (DataAccessException e) {
        internalError(e, resp);
        return null;
    }
}

From source file:org.esupportail.filex.web.WebController.java

@RequestMapping("HELP")
public ModelAndView renderHelpView(RenderRequest request, RenderResponse response) throws Exception {
    ModelMap model = new ModelMap();
    return new ModelAndView("help", model);
}

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

@RequestMapping(value = "/exchange_rates/{byCurrencyId}/{byDate}/{byTime}", method = RequestMethod.GET)
public @ResponseBody ModelMap ExchangeRatesByCurrencyDateTime(
        @PathVariable(value = "byCurrencyId") int byCurrencyId, @PathVariable(value = "byDate") Date byDate,
        @PathVariable(value = "byTime") Time byTime) {
    ModelMap map = new ModelMap();
    //System.out.println(byCurrencyId + "" + byDate + "" + byTime);
    map.addAttribute("exchangeRatesByCurrencyDateTime",
            exchangeRatesService.getByCurrencyDateTime(byCurrencyId, byDate, byTime));
    return map;/*  ww  w .  j a  v a  2  s  . c o  m*/
}

From source file:com.callcenter.controller.RecordingLibraryServiceControllerTest.java

@Test
public void shouldReturnTheListView(final @NonStrict RecordingLibraryService recordingLibraryService) {
    assertEquals("recordinglibrary/list", controller.list(new ModelMap()));
}

From source file:br.com.edo.atmlist.controller.ATMControllerTest.java

/**
 * Test of home method, of class ATMController.
 *//*from   w  w  w  .java  2s . c  o  m*/
@Test
public void testHome() {
    System.out.println("home");
    ModelMap model = new ModelMap();
    ATMController instance = new ATMController();
    String expResult = "home";
    String result = instance.home(model);
    assertEquals(expResult, result);

}

From source file:com.trenako.web.controllers.admin.AdminOptionsControllerTests.java

@Test
public void shouldRedirectAfterIOExceptionCreatingNewOptions() throws IOException {
    ModelMap model = new ModelMap();
    when(bindingResult.hasErrors()).thenReturn(false);
    OptionForm mockForm = mock(OptionForm.class);
    doThrow(new IOException()).when(mockForm).buildOption();

    String viewName = controller.create(mockForm, bindingResult, model, redirectAtts);

    assertEquals("option/new", viewName);
    assertTrue(model.containsAttribute("newForm"));
    verify(service, times(0)).save(isA(Option.class));
}

From source file:org.energyos.espi.thirdparty.web.AuthorizationControllerTests.java

@Test
public void index_displaysIndexView() throws Exception {
    assertEquals("/RetailCustomer/AuthorizationList/index", controller.index(new ModelMap(), principal));
}

From source file:org.motechproject.server.omod.web.controller.MotechModuleFormControllerTest.java

public void testSaveBlackoutSettings() throws ParseException {

    String startTime = "07:00:00", endTime = "19:00:00";

    Capture<Blackout> boCap = new Capture<Blackout>();

    expect(contextService.getMotechService()).andReturn(motechService);

    expect(motechService.getBlackoutSettings()).andReturn(null);
    motechService.setBlackoutSettings(capture(boCap));

    replay(contextService, motechService);

    ModelMap model = new ModelMap();
    String path = controller.saveBlackoutSettings(startTime, endTime, model);

    verify(contextService, motechService);

    assertEquals("/module/motechmodule/blackout", path);
    assertEquals(startTime, model.get("startTime").toString());
    assertEquals(endTime, model.get("endTime").toString());
    assertEquals(startTime, boCap.getValue().getStartTime().toString());
    assertEquals(endTime, boCap.getValue().getEndTime().toString());
}