PolicyRestController extends RestrictedBaseController { @RequestMapping(value = {"/deleteDictionary/*/*"}, method = {RequestMethod.POST}) public void deletetDictionaryController(HttpServletRequest request, HttpServletResponse response) throws IOException { String uri = request.getRequestURI().replace("/deleteDictionary", ""); if (uri.startsWith("/")) { uri = uri.substring(uri.indexOf('/') + 1); } uri = ONAP + uri.substring(uri.indexOf('/')); String userId = UserUtils.getUserSession(request).getOrgUserId(); policyLogger.info( "**********************Logging UserID while Deleting Dictionary*************************************"); policyLogger.info(USER_ID + userId); policyLogger.info( "***************************************************************************************************"); String body = callPap(request, "POST", uri.replaceFirst("/", "").trim()); if (body != null && !body.isEmpty()) { response.getWriter().write(body); } else { response.getWriter().write("Failed"); } } 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);  }
@PrepareForTest(UserUtils.class) @Test public void testdeletetDictionaryController() throws IOException { HttpServletRequest mockRequest = Mockito.mock(HttpServletRequest.class); HttpServletResponse mockResponse = Mockito.mock(HttpServletResponse.class); PolicyRestController controller = new PolicyRestController(); User mockUser = Mockito.mock(User.class); PowerMockito.mockStatic(UserUtils.class); PrintWriter mockPrintWriter = Mockito.mock(PrintWriter.class); when(mockRequest.getRequestURI()).thenReturn(" when(mockResponse.getWriter()).thenReturn(mockPrintWriter); when(UserUtils.getUserSession(mockRequest)).thenReturn(mockUser); when(mockUser.getOrgUserId()).thenReturn("testUserId"); controller.deletetDictionaryController(mockRequest, mockResponse); verify(mockRequest).getRequestURI(); verify(mockResponse).getWriter(); verify(mockUser).getOrgUserId(); when(mockRequest.getRequestURI()).thenReturn("testRequestURI controller.deletetDictionaryController(mockRequest, mockResponse); verify(mockRequest, atLeast(1)).getRequestURI(); }