PolicyRestController extends RestrictedBaseController { @RequestMapping(value = {"/policycreation/save_policy"}, method = {RequestMethod.POST}) public void policyCreationController(HttpServletRequest request, HttpServletResponse response) { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); try { updateAndSendToPap(request, response, UserUtils.getUserSession(request).getOrgUserId(), mapper); } catch (Exception e) { policyLogger.error("Exception Occured while saving policy", 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);  }
@Test public final void testPolicyCreationController() { assertNull(PolicyRestController.getCommonClassDao()); PolicyRestController.setCommonClassDao(commonClassDao); assertNotNull(PolicyRestController.getCommonClassDao()); PolicyRestController controller = new PolicyRestController(); BufferedReader reader = new BufferedReader(new StringReader(clRequestString)); try { Mockito.when(request.getReader()).thenReturn(reader); controller.policyCreationController(request, response); } catch (IOException e) { fail(); } PolicyRestController controller1 = new PolicyRestController(); CreateFirewallController.setCommonClassDao(commonClassDao); assertNotNull(CreateFirewallController.getCommonClassDao()); BufferedReader reader1 = new BufferedReader(new StringReader(fwRequestString)); try { Mockito.when(request.getReader()).thenReturn(reader1); controller1.policyCreationController(request, response); } catch (IOException e) { fail(); } CreateFirewallController fwController = new CreateFirewallController(); CreateFirewallController.setCommonClassDao(commonClassDao); BufferedReader reader2 = new BufferedReader(new StringReader(fwViewRequestString)); try { Mockito.when(request.getReader()).thenReturn(reader2); fwController.setFWViewRule(request, response); } catch (IOException e) { fail(); } }