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:se.vgregion.portal.iframe.controller.CSViewControllerTest.java

@Test
public void testChangeVaultCredentials_NoUserSiteCredential() throws ReadOnlyException {
    PortletPreferences prefs = new MockPortletPreferences();
    initPortletPreferences(prefs);//from   ww w .  j a va  2  s  .co  m

    MockRenderRequest mockReq = new MockRenderRequest(PortletMode.VIEW);
    RenderRequest req = (RenderRequest) initPortletRequest(mockReq);
    ModelMap model = new ModelMap();

    String response = controller.changeVaultCredentials(prefs, req, model);
    assertEquals("userCredentialForm", response);

    PortletConfig portletConfig = (se.vgregion.portal.iframe.model.PortletConfig) model.get("portletConfig");
    assertNotNull(portletConfig);
    assertEquals("test-key", portletConfig.getSiteKey());
    assertEquals("test-src", portletConfig.getSrc());
    assertEquals(Boolean.FALSE, portletConfig.isRelative());
    assertEquals(Boolean.TRUE, portletConfig.isAuth());
    assertEquals("form", portletConfig.getAuthType());
    assertEquals("post", portletConfig.getFormMethod());
    assertEquals("username", portletConfig.getSiteUserNameField());
    assertEquals("password", portletConfig.getSitePasswordField());
    assertEquals("test1=hidden1&test2=hidden2", portletConfig.getHiddenVariables());
    assertEquals("html1=apa\nhtml2=bepa", portletConfig.getHtmlAttributes());

    UserSiteCredential siteCredential = (UserSiteCredential) model.get("siteCredential");
    assertNotNull(siteCredential);
    assertEquals("test-user", siteCredential.getUid());
    assertEquals("test-key", siteCredential.getSiteKey());
    assertEquals("test-user", siteCredential.getSiteUser());
    assertNull(siteCredential.getSitePassword());
}

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

public ModelAndView ShowFinancialDisc(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    CurrentUser = (Users) request.getSession().getAttribute("CurrentUser");
    if (CurrentUser == null) {
        response.sendRedirect("login.htm");
    }//from  w  w w.  j  av  a2s .co m

    List<ApprovalStatusType> approvalstatustypelist;

    List<Users> userslist;
    List<Sites> siteslist;

    List<FinancialDisc> financialdisclist;

    List<ProtocolVersion> versionlist;

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

        List<studies> li = studiesdao.getStudyDetail(studyid);
        currentstudy = li.get(0);
        approvalstatustypelist = approvalstatustypedao.listapprovals(currentstudy.getStudy_id());
        financialdisclist = financialdiscdao.listfinancialdisc(currentstudy.getStudy_id());
        versionlist = traininguserdao.listprotocolversions(currentstudy.getStudy_id());
        userslist = userdao.listusers(CurrentUser);
        siteslist = sitedao.SitesList(CurrentUser);
        CurrentUser = (Users) request.getSession().getAttribute("CurrentUser");
        ModelMap modelMap = new ModelMap();
        modelMap.addAttribute("currentstudy", currentstudy);
        modelMap.addAttribute("approvalstatustypelist", approvalstatustypelist);
        modelMap.addAttribute("siteslist", siteslist);
        modelMap.addAttribute("userslist", userslist);
        modelMap.addAttribute("versionlist", versionlist);
        modelMap.addAttribute("financialdisclist", financialdisclist);
        int form = Integer.parseInt(request.getParameter("financial_disc_form"));
        if (form == 1)
            modelMap.addAttribute("CurrentFormFinancial", "View_Financial_Disclosure_div");
        else
            modelMap.addAttribute("CurrentFormFinancial", "Create_Financial_Disclosure_div");

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

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

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

@Test
public void shouldShowErrorMessageAfterDatabaseErrorsDuringSave() {
    doThrow(new RecoverableDataAccessException("Database error")).when(service).save(eq(rollingStock()));

    when(mockResult.hasErrors()).thenReturn(false);
    when(mockFile.isEmpty()).thenReturn(true);
    RollingStockForm form = rsForm(mockFile);

    ModelMap model = new ModelMap();

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

    assertEquals("rollingstock/edit", viewName);
    assertNotNull("Form is null", model.get("rollingStockForm"));
    assertEquals(RollingStocksController.ROLLING_STOCK_DATABASE_ERROR_MSG,
            (ControllerMessage) model.get("message"));
}

From source file:fragment.web.AbstractConnectorControllerTest.java

@Test
public void testSaveInstanceInvalidJson() throws Exception {
    map = new ModelMap();
    String classType = "com.citrix.cpbm.platform.spi.CloudServiceConnector";
    String filter = "(org.springframework.osgi.bean.name=OsgiServiceRef1)";
    prepareMock(classType, filter, true);
    String configProperties = "[{\"name\":\"instancename\",\"value\":\"MyCPIN\",{\"name\":\"instancedescription\",\"value\":\"Test\"},{\"name\":\"country\",\"value\":\"India\"},{\"name\":\"password\",\"value\":\"password\"},{\"name\":\"accountid\",\"value\":\"456783\"},{\"name\":\"username\",\"value\":\"cpbm\"},{\"name\":\"endpoint\",\"value\":\"http://google.com\"}]";
    map = controller.saveInstance("b1c9fbb0-8dab-42dc-ae0a-ce1384a1e6", "add", configProperties, null, map,
            new MockHttpServletRequest());
    EasyMock.reset(mockServiceRef, bc);//from w  w w.j  a  va  2s. com
}

From source file:org.esupportail.papercut.webportlet.EsupPapercutPortletController.java

@RequestMapping(params = "action=myhistory")
public ModelAndView myhistoryList(@RequestParam(value = "page", required = false) Integer page,
        @RequestParam(value = "size", required = false) Integer size,
        @RequestParam(value = "sortFieldName", required = false) String sortFieldName,
        @RequestParam(value = "sortOrder", required = false) String sortOrder, RenderRequest request) {

    String uid = getUid(request);
    String paperCutContext = request.getPreferences().getValue(PREF_PAPERCUT_CONTEXT, null);

    if (sortFieldName == null) {
        sortFieldName = "transactionDate";
        sortOrder = "desc";
    }/*www  .  j  av  a  2s.  co m*/

    if (size == null) {
        size = 10;
    }

    ModelMap model = new ModelMap();
    if (page != null || size != null) {
        int sizeNo = size == null ? 10 : size.intValue();
        final int firstResult = page == null ? 0 : (page.intValue() - 1) * sizeNo;
        model.put("payboxpapercuttransactionlogs",
                PayboxPapercutTransactionLog
                        .findPayboxPapercutTransactionLogsByUidEqualsAndPaperCutContextEquals(uid,
                                paperCutContext, sortFieldName, sortOrder)
                        .setFirstResult(firstResult).setMaxResults(sizeNo).getResultList());
        float nrOfPages = (float) PayboxPapercutTransactionLog
                .countFindPayboxPapercutTransactionLogsByUidEqualsAndPaperCutContextEquals(uid, paperCutContext)
                / sizeNo;
        model.put("maxPages",
                (int) ((nrOfPages > (int) nrOfPages || nrOfPages == 0.0) ? nrOfPages + 1 : nrOfPages));
    } else {
        model.put("payboxpapercuttransactionlogs",
                PayboxPapercutTransactionLog
                        .findPayboxPapercutTransactionLogsByUidEqualsAndPaperCutContextEquals(uid,
                                paperCutContext, sortFieldName, sortOrder)
                        .getResultList());
    }
    addDateTimeFormatPatterns(model);

    model.put("isAdmin", isAdmin(request));
    model.put("isManager", isManager(request));
    model.put("active", "history");

    model.put("sortFieldName", sortFieldName);
    model.put("sortOrder", sortOrder);

    return new ModelAndView(getViewName(request, "history"), model);
}

From source file:fragment.web.AbstractManageResourceControllerTest.java

/**
 * @author Abhaik/*from  ww w  . j  a  v  a 2  s.c  om*/
 * @description : Test to get the SSO Cmd for an Active Tenant through the same Tenant only
 */
@Test
public void testSSOFromTenantForSelf() {

    setSSOHandler();
    User user = userDAO.find(3L);
    asUser(user);
    request = new MockHttpServletRequest();
    response = new MockHttpServletResponse();
    map = new ModelMap();
    Tenant tenant = tenantdao.find(2L);
    ServiceInstance instance = serviceInstanceDao.find(1L);
    request.setAttribute("effectiveTenant", tenant);
    request.setAttribute("isSurrogatedTenant", isSurrogatedTenant(tenant, tenant.getParam()));

    Map<String, String> resultMap = controller.getSSOCmdString(tenant, 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.assertNotNull(cmdString);
    Assert.assertEquals(cmdString, tenant.getOwner().getName());

}

From source file:fragment.web.AbstractConnectorControllerTest.java

@Test
public void testUpdateInstance() throws Exception {
    map = new ModelMap();
    String classType = "com.citrix.cpbm.platform.spi.CloudServiceConnector";
    String filter = "(org.springframework.osgi.bean.name=OsgiServiceRef1)";
    prepareMock(classType, filter, true);
    String configProperties = "[{\"name\":\"instancename\",\"value\":\"MyCPIN\"},{\"name\":\"instancecode\",\"value\":\"InstanceCode-999\"},{\"name\":\"instancedescription\",\"value\":\"Test\"},{\"name\":\"country\",\"value\":\"India\"},{\"name\":\"password\",\"value\":\"password\"},{\"name\":\"accountid\",\"value\":\"456783\"},{\"name\":\"username\",\"value\":\"cpbm\"},{\"name\":\"endpoint\",\"value\":\"http://google.com\"}]";
    map = controller.saveInstance("4847df70-63bb-4273-a8db-30662b32d098", "update", configProperties, null, map,
            new MockHttpServletRequest());
    Assert.assertTrue(map.containsAttribute("validationResult"));
    Assert.assertTrue(map.containsAttribute("instanceid"));
    Assert.assertTrue(map.containsAttribute("result"));
}

From source file:fragment.web.AbstractSubscriptionControllerTest.java

@Test
public void testUtilityrates_tableForPublicCatalog() {
    ModelMap anonymousMap = new ModelMap();
    ServiceInstance instance = serviceInstanceDAO.find(1L);
    controller.utilityratesTable(null, instance.getUuid(), "VirtualMachine", "PSI_UD1=10", "USD", "false", null,
            null, null, null, anonymousMap, request);
    Assert.assertNotNull(anonymousMap.get(UserContextInterceptor.MIN_FRACTION_DIGITS));
    Assert.assertNotNull(anonymousMap.get(UserContextInterceptor.CURRENCY_PRECISION));
    Assert.assertNotNull(anonymousMap.get(UserContextInterceptor.CURRENCY_FORMAT));
}

From source file:fragment.web.SanityTestSuit.java

/**
 * Description: Test to add and enable payment gateway Instance
 * // w w w . java2 s. c  om
 * @author vinayv
 */
@Test
public void testAddAndEnablePaymentGatewayInstance() {

    Service service = servicedao.find("7");
    int serviceInstancesCount = serviceInstanceDao.count();
    String configProperties = "[{\"name\":\"serverurl\",\"value\":\"https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor\"},{\"name\":\"merchantName\",\"value\":\"citrix_cpbm\"},{\"name\":\"transactionKey\",\"value\":\"h03g5h+quEOQUE8YPDrAugUAwaZZeo5qm6BCAOhuzBTPxKYD4DHHJq5rFPSIgLodymo5uJyM02bP+NjJKO0ua+RHPkJPyo96RuzWN05qWd17bGNVNIZWiVayp5LvdZgag8SbqZl2UUme4mcauNOBCUGlWxiMNRTnRquu+XSGc7CONzEz7PqrZy5qTxg8OsC6BQDBpll6jmqboEIA6G7MFM/EpgPgMccmrmsU9IiAuh3Kajm4nIzTZs/42Mko7S5r5Ec+Qk/Kj3pG7NY3TmpZ3XtsY1U0hlaJVrKnku91mBqDxJupmXZRSZ7iZxq404EJQaVbGIw1FOdGq675dIZzsA==\"}]";
    String quickProducts = null;

    connectorController.saveInstance(service.getUuid(), "save", configProperties, quickProducts, map, request);
    Assert.assertEquals(serviceInstancesCount + 1, serviceInstanceDao.count());
    Assert.assertEquals(CssdkConstants.SUCCESS, map.get("validationResult"));
    String instanceMessage = (String) map.get("message");
    Assert.assertEquals("Instance Added Successfully.", instanceMessage);

    // Enabling Payment Gateway
    Assert.assertEquals(Boolean.FALSE, service.getEnabled());
    map = new ModelMap();
    connectorController.enable(service.getUuid(), true, map, request);
    Assert.assertEquals(Boolean.TRUE, service.getEnabled());
    String message = (String) map.get("message");
    Assert.assertEquals("Service enabled successfully", message);

}

From source file:se.vgregion.portal.iframe.controller.CSViewControllerTest.java

@Test
@Ignore/*from w  w  w .  jav  a 2  s .  c  om*/
public void testChangeVaultCredentials_NoUserSiteCredential_NotSuggestScreenName() throws ReadOnlyException {
    PortletPreferences prefs = new MockPortletPreferences();
    initPortletPreferences(prefs);
    prefs.setValue("suggestScreenName", "false");

    MockRenderRequest mockReq = new MockRenderRequest(PortletMode.VIEW);
    RenderRequest req = (RenderRequest) initPortletRequest(mockReq);
    ModelMap model = new ModelMap();

    String response = controller.changeVaultCredentials(prefs, req, model);
    assertEquals("userCredentialForm", response);

    PortletConfig portletConfig = (se.vgregion.portal.iframe.model.PortletConfig) model.get("portletConfig");
    assertNotNull(portletConfig);
    assertEquals("test-key", portletConfig.getSiteKey());
    assertEquals("test-src", portletConfig.getSrc());
    assertEquals(Boolean.FALSE, portletConfig.isRelative());
    assertEquals(Boolean.TRUE, portletConfig.isAuth());
    assertEquals("form", portletConfig.getAuthType());
    assertEquals("post", portletConfig.getFormMethod());
    assertEquals("username", portletConfig.getSiteUserNameField());
    assertEquals("password", portletConfig.getSitePasswordField());
    assertEquals("test1=hidden1&test2=hidden2", portletConfig.getHiddenVariables());
    assertEquals("html1=apa\nhtml2=bepa", portletConfig.getHtmlAttributes());

    UserSiteCredential siteCredential = (UserSiteCredential) model.get("siteCredential");
    assertNotNull(siteCredential);
    assertEquals("test-user", siteCredential.getUid());
    assertEquals("test-key", siteCredential.getSiteKey());
    assertNull(siteCredential.getSiteUser());
    assertNull(siteCredential.getSitePassword());
}