PolicyValidationController extends RestrictedBaseController { @RequestMapping( value = {"/policyController/validate_policy.htm"}, method = {org.springframework.web.bind.annotation.RequestMethod.POST}) public ModelAndView validatePolicy(HttpServletRequest request, HttpServletResponse response) throws IOException { try { PolicyValidation validation = new PolicyValidation(); PolicyValidationRequestWrapper wrapper = new PolicyValidationRequestWrapper(); StringBuilder responseString; ObjectMapper mapper = new ObjectMapper(); PolicyRestAdapter policyData = wrapper.populateRequestParameters(request); responseString = validation.validatePolicy(policyData); response.getWriter().write(new JSONObject( new JsonMessage(mapper.writeValueAsString(responseString.toString()))).toString()); } catch (Exception e) { LOGGER.error("Exception Occured During Policy Validation" + e); response.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); request.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); response.getWriter().write(PolicyUtils.CATCH_EXCEPTION); } return null; }  @RequestMapping( value = {"/policyController/validate_policy.htm"}, method = {org.springframework.web.bind.annotation.RequestMethod.POST}) ModelAndView validatePolicy(HttpServletRequest request, HttpServletResponse response);  }
@Test public void testValidate() throws IOException { PolicyValidationController controller = new PolicyValidationController(); MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletResponse response = new MockHttpServletResponse(); ModelAndView model = controller.validatePolicy(request, response); assertNull(model); assertEquals(response.getStatusCode(), HttpServletResponse.SC_OK); }