PolicyUserInfoController extends RestrictedBaseController { @RequestMapping(value = "/get_PolicyUserInfo", method = RequestMethod.GET) public void getPolicyUserInfo(HttpServletRequest request, HttpServletResponse response) { try { String userId = UserUtils.getUserSession(request).getOrgUserId(); Map<String, Object> model = new HashMap<>(); model.put("userid", userId); response.getWriter().write(new JSONObject(new JsonMessage( new ObjectMapper().writeValueAsString(model))).toString()); } catch (Exception e) { LOGGER.error("Exception Occurred" + e); } }  @RequestMapping(value = "/get_PolicyUserInfo", method = RequestMethod.GET) void getPolicyUserInfo(HttpServletRequest request, HttpServletResponse response);  }
@Test public final void testGetPolicyUserInfo() { PolicyUserInfoController controller = new PolicyUserInfoController(); controller.getPolicyUserInfo(request, response); try { assertTrue(response.getStatus() == 200); } catch (Exception e) { fail(); } }
@SuppressWarnings("unchecked") @Test public void testGetPolicyUserInfoException() throws IOException { HttpServletResponse mockResponse = Mockito.mock(HttpServletResponse.class); when(mockResponse.getWriter()).thenThrow(IOException.class); PolicyUserInfoController controller = new PolicyUserInfoController(); controller.getPolicyUserInfo(request, mockResponse); verify(mockResponse, atLeast(1)).getWriter(); }