AutoPushController extends RestrictedBaseController { public synchronized void refreshGroups() { synchronized (this.groups) { this.groups.clear(); try { PolicyController controller = getPolicyControllerInstance(); this.groups.addAll(controller.getPapEngine().getOnapPDPGroups()); } catch (PAPException e) { String message = "Unable to retrieve Groups from server: " + e; logger.error(XACMLErrorConstants.ERROR_DATA_ISSUE + message); } } }  PolicyController getPolicyController(); void setPolicyController(PolicyController policyController); synchronized void refreshGroups(); @RequestMapping( value = {"/get_AutoPushPoliciesContainerData"}, method = {RequestMethod.GET}, produces = MediaType.APPLICATION_JSON_VALUE) void getPolicyGroupContainerData(HttpServletRequest request, HttpServletResponse response); @RequestMapping(value = {"/auto_Push/PushPolicyToPDP.htm"}, method = {RequestMethod.POST}) ModelAndView pushPolicyToPDPGroup(HttpServletRequest request, HttpServletResponse response); @SuppressWarnings("unchecked") @RequestMapping(value = {"/auto_Push/remove_GroupPolicies.htm"}, method = {RequestMethod.POST}) ModelAndView removePDPGroup(HttpServletRequest request, HttpServletResponse response);  }
@Test(expected = NullPointerException.class) public void testRefreshGroupsNull() throws IOException { apController.refreshGroups(); }
@SuppressWarnings("unchecked") @Test public void testRefreshGroups() throws PAPException { PolicyController mockPolicyController = Mockito.mock(PolicyController.class); PAPPolicyEngine mockPAPPolicyEngine = Mockito.mock(PAPPolicyEngine.class); when(mockPolicyController.getPapEngine()).thenReturn(mockPAPPolicyEngine); when(mockPAPPolicyEngine.getOnapPDPGroups()).thenThrow(PAPException.class); apController.setPolicyController(mockPolicyController); apController.refreshGroups(); verify(mockPolicyController).getPapEngine(); verify(mockPAPPolicyEngine).getOnapPDPGroups(); }