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:fragment.web.ChannelControllerTest.java

@Before
public void init() throws Exception {
    map = new ModelMap();
    response = new MockHttpServletResponse();
    request = new MockHttpServletRequest();
}

From source file:org.openmrs.web.controller.encounter.EncounterRoleFormControllerTest.java

/**
 * @verifies add list of encounter role objects to the model
 * @see EncounterRoleFormController#getEncounterList(org.springframework.ui.ModelMap)
 *//*w w  w  .ja v a 2s .c o m*/
@Test
public void showEncounterList_shouldAddListOfEncounterRoleObjectsToTheModel() throws Exception {
    ModelMap modelMap = new ModelMap();
    executeDataSet(ENC_INITIAL_DATA_XML);
    EncounterRoleFormController controller = new EncounterRoleFormController();
    String viewName = controller.getEncounterList(modelMap);
    Assert.assertEquals("/module/legacyui/admin/encounters/encounterRoleList", viewName);
    Assert.assertEquals(3, ((List) modelMap.get("encounterRoles")).size());
}

From source file:org.ngrinder.user.controller.UserControllerTest.java

@Test
public void testSwitchOptions() {
    ModelMap model = new ModelMap();
    User currUser = getTestUser();//from   w w w  .  j av  a  2s  . c  o m
    User temp = new User("temp1", "temp1", "temp1", "temp@nhn.com", Role.USER);
    User admin = getAdminUser();
    userController.save(admin, temp, model);
    currUser.setOwners(Lists.newArrayList(temp));
    currUser.setOwnerUser(temp);
    userController.save(currUser, currUser, model);
    HttpEntity<String> shareUsersStr = userController.switchOptions(currUser, "");
    assertTrue(shareUsersStr.getBody().contains("id"));
}

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

@RequestMapping(value = "exchange_rates/latest_time/{byDate}", method = RequestMethod.GET)
public @ResponseBody ModelMap getLatestTime(@PathVariable(value = "byDate") Date byDate) {
    ModelMap map = new ModelMap();

    map.addAttribute("latestTime", exchangeRatesService.getLatestTime(byDate));
    return map;//from w  ww .  jav  a  2 s  .com
}

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

public void testEditPatient() {
    Integer patientId = 1, communityId = 11112, motherId = 2;
    String firstName = "FirstName", middleName = "MiddleName", lastName = "LastName", prefName = "PrefName";
    String region = "Region", district = "District", address = "Address", nhis = "1234DEF";
    String phoneNumber = "0123456789";
    Boolean birthDateEst = true, enroll = true, consent = true, insured = true;
    Date date = new Date();
    Gender sex = Gender.FEMALE;//from  ww  w  .ja  va2  s. co  m
    ContactNumberType phoneType = ContactNumberType.PERSONAL;
    MediaType mediaType = MediaType.TEXT;
    String language = "en";
    DayOfWeek dayOfWeek = DayOfWeek.FRIDAY;

    WebPatient patient = new WebPatient();
    patient.setId(patientId);
    patient.setFirstName(firstName);
    patient.setMiddleName(middleName);
    patient.setLastName(lastName);
    patient.setPrefName(prefName);
    patient.setBirthDate(date);
    patient.setBirthDateEst(birthDateEst);
    patient.setSex(sex);
    patient.setInsured(insured);
    patient.setNhis(nhis);
    patient.setNhisExpDate(date);
    patient.setMotherMotechId(motherId);
    patient.setRegion(region);
    patient.setDistrict(district);
    patient.setCommunityId(communityId);
    patient.setAddress(address);
    patient.setPhoneNumber(phoneNumber);
    patient.setPhoneType(phoneType);
    patient.setMediaType(mediaType);
    patient.setLanguage(language);
    patient.setDueDate(date);
    patient.setEnroll(enroll);
    patient.setConsent(consent);
    patient.setDayOfWeek(dayOfWeek);
    patient.setTimeOfDay(date);
    patient.setFacility(11117);

    Errors errors = new BeanPropertyBindingResult(patient, "patient");
    ModelMap model = new ModelMap();

    Patient openmrsPatient = new Patient(1);
    Patient motherPatient = new Patient(2);
    Community community = new Community();

    expect(registrarBean.getPatientById(patientId)).andReturn(openmrsPatient);
    expect(openmrsBean.getPatientByMotechId(motherId.toString())).andReturn(motherPatient);
    expect(registrarBean.getCommunityById(communityId)).andReturn(community);
    Facility facility = new Facility();
    facility.setFacilityId(11117);
    expect(registrarBean.getFacilityById(facility.getFacilityId())).andReturn(facility);
    JSONLocationSerializer.populateJavascriptMaps(model, patient.getPreferredLocation());
    expectLastCall();

    registrarBean.editPatient(openmrsPatient, firstName, middleName, lastName, prefName, date, birthDateEst,
            sex, insured, nhis, date, motherPatient, community, address, phoneNumber, date, enroll, consent,
            phoneType, mediaType, language, dayOfWeek, date, facility);

    status.setComplete();

    replay(registrarBean, status, contextService, motechService, openmrsBean, JSONLocationSerializer);

    controller.submitForm(patient, errors, model, status);

    verify(registrarBean, status, contextService, motechService, openmrsBean, JSONLocationSerializer);

    assertTrue("Missing success message in model", model.containsAttribute("successMsg"));
}

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

@RequestMapping(value = "/exchange_rates/bank_list", method = RequestMethod.GET)
public @ResponseBody ModelMap getBankList() {
    ModelMap map = new ModelMap();
    map.addAttribute("bankList", exchangeRatesService.getBankList());
    return map;/*ww  w .  java  2  s  .  c  o  m*/
}

From source file:gov.nyc.doitt.gis.geoclient.service.web.RestControllerTest.java

@Test
public void testDoc() {
    Documentation doc = new Documentation();
    ModelMap modelMap = new ModelMap();
    Mockito.when(this.geosupportServiceMock.getDocumentation()).thenReturn(doc);
    Version version = new Version();
    Mockito.when(this.geosupportServiceMock.version()).thenReturn(version);
    assertEquals("index", this.restController.doc(modelMap));
    assertSame(version, modelMap.get("version"));
    assertSame(doc, modelMap.get("doc"));
}

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

public void testRemoveTroubledPhone() {
    String phone = "378378373";
    TroubledPhone tp = new TroubledPhone();
    tp.setId(38903L);//from  w  ww.j  a v a2s  . c  o  m
    tp.setPhoneNumber(phone);

    expect(contextService.getMotechService()).andReturn(motechService);
    expect(motechService.getTroubledPhone(phone)).andReturn(tp);
    motechService.removeTroubledPhone(phone);

    replay(contextService, motechService);

    ModelMap model = new ModelMap();
    String path = controller.handleTroubledPhone(phone, true, model);

    verify(contextService, motechService);

    assertNull(model.get("troubledPhone"));
    assertEquals("redirect:/module/motechmodule/troubledphone.form", path);
}

From source file:fragment.web.SanityTestSuit.java

@Before
public void init() {
    map = new ModelMap();
    request = new MockHttpServletRequest();
    response = new MockHttpServletResponse();
    status = new MockSessionStatus();
}

From source file:fragment.web.RegistrationControllerTest.java

@Before
public void init() throws Exception {
    map = new ModelMap();
    status = new MockSessionStatus();
    request = new MockHttpServletRequest();
    response = new MockHttpServletResponse();
    session = new MockHttpSession();
    request.setSession(session);/*w  w w  .j ava 2  s .c  o m*/
    prepareMock(true, bootstrapActivator);
    if (!isMockInstanceCreated) {

        Service ossService = serviceDAO.find(7l);
        ossService.setEnabled(true);
        Service cloudService = serviceDAO.find(6l);
        connectorManagementService.getAllServiceInstances(cloudService);

        isMockInstanceCreated = true;
    }

    httpServletRequest = EasyMock.createMock(HttpServletRequest.class);
    httpServletResponse = EasyMock.createMock(HttpServletResponse.class);
    httpSession = EasyMock.createMock(HttpSession.class);
    themeResolver = new PortalSessionThemeResolverImpl();
    asRoot();
}