@SuppressWarnings("unchecked") @Test public void testGetDictionaryController() throws IOException { PolicyRestController controller = new PolicyRestController(); HttpServletRequest mockRequest = Mockito.mock(HttpServletRequest.class); HttpServletResponse mockResponse = Mockito.mock(HttpServletResponse.class); PrintWriter mockPrintWriter = Mockito.mock(PrintWriter.class); when(mockRequest.getRequestURI()).thenReturn(" when(mockResponse.getWriter()).thenThrow(IOException.class); controller.getDictionaryController(mockRequest, mockResponse); verify(mockRequest, atLeast(1)).getRequestURI(); verify(mockResponse, atLeast(1)).getWriter(); reset(mockResponse); when(mockRequest.getRequestURI()).thenReturn("testRequestURI when(mockResponse.getWriter()).thenReturn(mockPrintWriter); controller.getDictionaryController(mockRequest, mockResponse); verify(mockRequest, atLeast(1)).getRequestURI(); verify(mockResponse, atLeast(1)).getWriter(); }
@RequestMapping(value = {"/getDictionary/*"}, method = {RequestMethod.GET}) public void getDictionaryController(HttpServletRequest request, HttpServletResponse response) { String body; ResponseEntity<?> responseEntity = sendToPap(null, request.getRequestURI().replace("/getDictionary", ""), HttpMethod.GET); if (responseEntity != null) { body = responseEntity.getBody().toString(); } else { body = ""; } try { response.getWriter().write(body); } catch (IOException e) { policyLogger.error("Exception occured while getting Dictionary entries", e); } }
PolicyRestController extends RestrictedBaseController { @RequestMapping(value = {"/getDictionary/*"}, method = {RequestMethod.GET}) public void getDictionaryController(HttpServletRequest request, HttpServletResponse response) { String body; ResponseEntity<?> responseEntity = sendToPap(null, request.getRequestURI().replace("/getDictionary", ""), HttpMethod.GET); if (responseEntity != null) { body = responseEntity.getBody().toString(); } else { body = ""; } try { response.getWriter().write(body); } catch (IOException e) { policyLogger.error("Exception occured while getting Dictionary entries", e); } } }
PolicyRestController extends RestrictedBaseController { @RequestMapping(value = {"/getDictionary/*"}, method = {RequestMethod.GET}) public void getDictionaryController(HttpServletRequest request, HttpServletResponse response) { String body; ResponseEntity<?> responseEntity = sendToPap(null, request.getRequestURI().replace("/getDictionary", ""), HttpMethod.GET); if (responseEntity != null) { body = responseEntity.getBody().toString(); } else { body = ""; } try { response.getWriter().write(body); } catch (IOException e) { policyLogger.error("Exception occured while getting Dictionary entries", e); } } PolicyRestController(); @Autowired private  PolicyRestController(CommonClassDao commonClassDao); }
PolicyRestController extends RestrictedBaseController { @RequestMapping(value = {"/getDictionary/*"}, method = {RequestMethod.GET}) public void getDictionaryController(HttpServletRequest request, HttpServletResponse response) { String body; ResponseEntity<?> responseEntity = sendToPap(null, request.getRequestURI().replace("/getDictionary", ""), HttpMethod.GET); if (responseEntity != null) { body = responseEntity.getBody().toString(); } else { body = ""; } try { response.getWriter().write(body); } catch (IOException e) { policyLogger.error("Exception occured while getting Dictionary entries", e); } } PolicyRestController(); @Autowired private  PolicyRestController(CommonClassDao commonClassDao); static CommonClassDao getCommonClassDao(); static void setCommonClassDao(CommonClassDao commonClassDao); @RequestMapping(value = {"/policycreation/save_policy"}, method = {RequestMethod.POST}) void policyCreationController(HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = {"/getDictionary/*"}, method = {RequestMethod.GET}) void getDictionaryController(HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = {"/saveDictionary/*/*"}, method = {RequestMethod.POST}) void saveDictionaryController(HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = {"/deleteDictionary/*/*"}, method = {RequestMethod.POST}) void deletetDictionaryController(HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = {"/searchDictionary"}, method = {RequestMethod.POST}) ModelAndView searchDictionaryController(HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = {"/searchPolicy"}, method = {RequestMethod.POST}) ModelAndView searchPolicy(HttpServletRequest request, HttpServletResponse response); void deleteElasticData(String fileName); String notifyOtherPapsToUpdateConfigurations(String mode, String newName, String oldName); }
PolicyRestController extends RestrictedBaseController { @RequestMapping(value = {"/getDictionary/*"}, method = {RequestMethod.GET}) public void getDictionaryController(HttpServletRequest request, HttpServletResponse response) { String body; ResponseEntity<?> responseEntity = sendToPap(null, request.getRequestURI().replace("/getDictionary", ""), HttpMethod.GET); if (responseEntity != null) { body = responseEntity.getBody().toString(); } else { body = ""; } try { response.getWriter().write(body); } catch (IOException e) { policyLogger.error("Exception occured while getting Dictionary entries", e); } } PolicyRestController(); @Autowired private  PolicyRestController(CommonClassDao commonClassDao); static CommonClassDao getCommonClassDao(); static void setCommonClassDao(CommonClassDao commonClassDao); @RequestMapping(value = {"/policycreation/save_policy"}, method = {RequestMethod.POST}) void policyCreationController(HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = {"/getDictionary/*"}, method = {RequestMethod.GET}) void getDictionaryController(HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = {"/saveDictionary/*/*"}, method = {RequestMethod.POST}) void saveDictionaryController(HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = {"/deleteDictionary/*/*"}, method = {RequestMethod.POST}) void deletetDictionaryController(HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = {"/searchDictionary"}, method = {RequestMethod.POST}) ModelAndView searchDictionaryController(HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = {"/searchPolicy"}, method = {RequestMethod.POST}) ModelAndView searchPolicy(HttpServletRequest request, HttpServletResponse response); void deleteElasticData(String fileName); String notifyOtherPapsToUpdateConfigurations(String mode, String newName, String oldName);  }