Spring MVC控制器的单元测试,日期值为@RequestParam

时间:2018-11-28 10:47:43

标签: java spring unit-testing date mockito

请帮助我将此Date对象传递给MVCMock。 由于param()仅接受String作为值。  我不确定如何在此处传递日期值

MockHttpServletRequestBuilder mvcBuilder = get("/pam/holdings/getholdings")
                                                   .accept(MediaType.ALL)
                                                   .flashAttr("holdingsFilterViewData", holdingsFilter)
                                                   .param("group","")
                                                   .param("account","")
                                                   .param("selectedHoldingsview","");




public String loadSelectedHoldings(
            @ModelAttribute("holdingsFilterViewData") HoldingsFilter holdingsFilter,
            @RequestParam(value = "account", required = false) String account,
            @RequestParam(value = "group", required = false) String group,
            @RequestParam(value = "asOfDate", required = false) Date asOfDate,
            @RequestParam(value = "selectedHoldingsview", required = false) String selectedViewName,
            Model model, HttpServletResponse servletResponse)
            throws NoUserLoggedInException, NoKeyOfTypeFoundException,
            ParseException, IOException {

0 个答案:

没有答案