Search in sources :

Example 61 with ModelAndView

use of org.springframework.web.servlet.ModelAndView in project head by mifos.

the class ViewLoanAccountDetailsController method showLoanAccountAllActivity.

@RequestMapping(value = "/viewLoanAccountAllActivity", method = RequestMethod.GET)
public ModelAndView showLoanAccountAllActivity(HttpServletRequest request, HttpServletResponse response) {
    ModelAndView modelAndView = new ModelAndView();
    sitePreferenceHelper.resolveSiteType(modelAndView, "viewLoanAccountAllActivity", request);
    modelAndView.addObject("include_page", new IncludePage(request, response));
    String globalAccountNum = request.getParameter("globalAccountNum");
    LoanInformationDto loanInformationDto = loanAccountServiceFacade.retrieveLoanInformation(globalAccountNum);
    modelAndView.addObject("loanInformationDto", loanInformationDto);
    modelAndView.addObject("currentDate", new Date());
    List<LoanActivityDto> allLoanAccountActivities = this.loanAccountServiceFacade.retrieveAllLoanAccountActivities(globalAccountNum);
    request.setAttribute("loanAllActivityView", allLoanAccountActivities);
    this.loanAccountServiceFacade.putLoanBusinessKeyInSession(globalAccountNum, request);
    return modelAndView;
}
Also used : LoanActivityDto(org.mifos.dto.domain.LoanActivityDto) ModelAndView(org.springframework.web.servlet.ModelAndView) IncludePage(freemarker.ext.servlet.IncludePage) LoanInformationDto(org.mifos.dto.screen.LoanInformationDto) Date(java.util.Date) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 62 with ModelAndView

use of org.springframework.web.servlet.ModelAndView in project head by mifos.

the class DefineProductCategoryPreviewControllerTest method cancelShouldRedirectToAdminView.

@Test
public void cancelShouldRedirectToAdminView() throws Exception {
    // setup
    ProductCategoryFormBean expectedFormBean = new ProductCategoryFormBean();
    // exercise test
    ModelAndView returnedView = productCategoryPreviewController.processFormSubmit("Cancel", "", expectedFormBean, bindingResult);
    // verification
    Assert.assertThat(returnedView.getViewName(), is(ADMIN_VIEW));
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) Test(org.junit.Test)

Example 63 with ModelAndView

use of org.springframework.web.servlet.ModelAndView in project head by mifos.

the class RedirectionControllerTest method testHandleRequest.

@Test
public void testHandleRequest() throws ServletException, IOException {
    String expectedPageToRedirectTo = "foopage";
    RedirectionController controller = new RedirectionController();
    controller.setViewToRedirectTo(expectedPageToRedirectTo);
    MockHttpServletRequest mockRequest = new MockHttpServletRequest();
    MockHttpServletResponse mockResponse = new MockHttpServletResponse();
    ModelAndView modelAndView = controller.handleRequest(mockRequest, mockResponse);
    Assert.assertEquals(expectedPageToRedirectTo, modelAndView.getViewName());
    Assert.assertNotNull(modelAndView.getModel());
    Map<String, Object> modelMap = (Map<String, Object>) modelAndView.getModel().get("model");
    Object response = modelMap.get("response");
    Assert.assertNotNull(response);
    Assert.assertEquals(MockHttpServletResponse.class, response.getClass());
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ModelAndView(org.springframework.web.servlet.ModelAndView) Map(java.util.Map) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 64 with ModelAndView

use of org.springframework.web.servlet.ModelAndView in project head by mifos.

the class ViewOrganizationSettingsController method handleRequestInternal.

@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "NP_UNWRITTEN_FIELD", justification = "request is not null")
@RequestMapping(method = RequestMethod.GET)
public ModelAndView handleRequestInternal(HttpServletRequest request) {
    ModelAndView modelAndView = new ModelAndView("viewOrganizationSettings");
    Properties p = viewOrganizationSettingsServiceFacade.getOrganizationSettings(request.getSession());
    modelAndView.addObject("properties", p);
    modelAndView.addObject("pluginsPropsMap", viewOrganizationSettingsServiceFacade.getDisplayablePluginsProperties());
    modelAndView.addObject("breadcrumbs", new AdminBreadcrumbBuilder().withLink("admin.viewOrganizationSettings", "viewOrganizationSettings.ftl").build());
    return modelAndView;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) Properties(java.util.Properties) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 65 with ModelAndView

use of org.springframework.web.servlet.ModelAndView in project head by mifos.

the class ViewProductCategoriesController method showProductCategories.

@RequestMapping(method = RequestMethod.GET)
public ModelAndView showProductCategories() {
    ModelAndView modelAndView = new ModelAndView("viewProductCategories");
    ProductCategoryDisplayDto dto = adminServiceFacade.retrieveAllProductCategories();
    modelAndView.addObject("dto", dto);
    modelAndView.addObject("breadcrumbs", new AdminBreadcrumbBuilder().withLink("admin.viewproductcategories", "viewProductCategories.ftl").build());
    return modelAndView;
}
Also used : ProductCategoryDisplayDto(org.mifos.dto.screen.ProductCategoryDisplayDto) ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ModelAndView (org.springframework.web.servlet.ModelAndView)1576 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)669 Test (org.junit.jupiter.api.Test)195 Test (org.junit.Test)188 HashMap (java.util.HashMap)166 ArrayList (java.util.ArrayList)140 RedirectView (org.springframework.web.servlet.view.RedirectView)90 Map (java.util.Map)85 List (java.util.List)69 IOException (java.io.IOException)62 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)60 Date (java.util.Date)57 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)50 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)49 MockHttpServletResponse (org.springframework.web.testfixture.servlet.MockHttpServletResponse)49 MockHttpServletRequest (org.springframework.web.testfixture.servlet.MockHttpServletRequest)47 GetMapping (org.springframework.web.bind.annotation.GetMapping)45 HandlerMethod (org.springframework.web.method.HandlerMethod)45 IPerson (org.apereo.portal.security.IPerson)43 ExceptionHandler (org.springframework.web.bind.annotation.ExceptionHandler)35