XKeyREST { @GET @Path("/keys") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.SEARCH_KEYS + "\")") public VXKmsKeyList searchKeys(@Context HttpServletRequest request, @QueryParam("provider") String provider) { VXKmsKeyList vxKmsKeyList = new VXKmsKeyList(); try{ vxKmsKeyList = keyMgr.searchKeys(request, provider); }catch(Exception e){ handleError(e); } return vxKmsKeyList; }  @GET @Path("/keys") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.SEARCH_KEYS + "\")") VXKmsKeyList searchKeys(@Context HttpServletRequest request, @QueryParam("provider") String provider); @PUT @Path("/key") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.ROLLOVER_KEYS + "\")") VXKmsKey rolloverKey(@QueryParam("provider") String provider, VXKmsKey vXKey); @DELETE @Path("/key/{alias}") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.DELETE_KEY + "\")") void deleteKey(@PathParam("alias") String name, @QueryParam("provider") String provider, @Context HttpServletRequest request); @POST @Path("/key") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.CREATE_KEY + "\")") VXKmsKey createKey(@QueryParam("provider") String provider, VXKmsKey vXKey); @GET @Path("/key/{alias}") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_KEY + "\")") VXKmsKey getKey(@PathParam("alias") String name,@QueryParam("provider") String provider);  }
@Test public void Test1Searchkeys() throws Exception { VXKmsKeyList vxKeyListExp = new VXKmsKeyList(); Mockito.when(keyMgr.searchKeys(request, provider)).thenReturn(vxKeyListExp); VXKmsKeyList vxKeyListAct = keyREST.searchKeys(request, provider); Assert.assertNotNull(vxKeyListAct); Assert.assertEquals(vxKeyListExp, vxKeyListAct); Mockito.verify(keyMgr).searchKeys(request, provider); }