PublicAPIs { @GET @Path("/api/policy/{id}") @Produces({ "application/json", "application/xml" }) public VXPolicy getPolicy(@PathParam("id") Long id) { if(logger.isDebugEnabled()) { logger.debug("==> PublicAPIs.getPolicy() " + id); } RangerPolicy policy = null; RangerService service = null; policy = serviceREST.getPolicy(id); if(policy != null) { service = serviceREST.getServiceByName(policy.getService()); } VXPolicy ret = serviceUtil.toVXPolicy(policy, service); if(logger.isDebugEnabled()) { logger.debug("<== PublicAPIs.getPolicy()" + ret); } return ret; }  @GET @Path("/api/repository/{id}") @Produces({ "application/json", "application/xml" }) VXRepository getRepository(@PathParam("id") Long id); @POST @Path("/api/repository/") @Produces({ "application/json", "application/xml" }) VXRepository createRepository(VXRepository vXRepository); @PUT @Path("/api/repository/{id}") @Produces({ "application/json", "application/xml" }) VXRepository updateRepository(VXRepository vXRepository,
			@PathParam("id") Long id); @DELETE @Path("/api/repository/{id}") @PreAuthorize("hasRole('ROLE_SYS_ADMIN')") @RangerAnnotationClassName(class_name = VXAsset.class) void deleteRepository(@PathParam("id") Long id,
			@Context HttpServletRequest request); @GET @Path("/api/repository/") @Produces({ "application/json", "application/xml" }) VXRepositoryList searchRepositories(
			@Context HttpServletRequest request); @GET @Path("/api/repository/count") @Produces({ "application/json", "application/xml" }) VXLong countRepositories(@Context HttpServletRequest request); @GET @Path("/api/policy/{id}") @Produces({ "application/json", "application/xml" }) VXPolicy getPolicy(@PathParam("id") Long id); @POST @Path("/api/policy") @Produces({ "application/json", "application/xml" }) VXPolicy createPolicy(VXPolicy vXPolicy); @PUT @Path("/api/policy/{id}") @Produces({ "application/json", "application/xml" }) VXPolicy updatePolicy(VXPolicy vXPolicy, @PathParam("id") Long id); @DELETE @Path("/api/policy/{id}") @PreAuthorize("hasRole('ROLE_SYS_ADMIN')") @RangerAnnotationClassName(class_name = VXResource.class) void deletePolicy(@PathParam("id") Long id,
			@Context HttpServletRequest request); @GET @Path("/api/policy") @Produces({ "application/json", "application/xml" }) VXPolicyList searchPolicies(@Context HttpServletRequest request); @GET @Path("/api/policy/count") @Produces({ "application/xml", "application/json" }) VXLong countPolicies(@Context HttpServletRequest request);  }
@Test public void test7getPolicy() throws Exception { RangerPolicy policy = rangerPolicy(); RangerService service = rangerService(); VXPolicy vXPolicy = vXPolicy(policy, service); Mockito.when(serviceREST.getPolicy(policy.getId())).thenReturn(policy); Mockito.when(serviceREST.getServiceByName(policy.getService())).thenReturn(service); Mockito.when(serviceUtil.toVXPolicy(policy, service)).thenReturn(vXPolicy); VXPolicy dbVXPolicy = publicAPIs.getPolicy(Id); Assert.assertNotNull(dbVXPolicy); Assert.assertEquals(dbVXPolicy, vXPolicy); Assert.assertEquals(dbVXPolicy.getPolicyName(), vXPolicy.getPolicyName()); Assert.assertEquals(dbVXPolicy.getRepositoryType(), vXPolicy.getRepositoryType()); Mockito.verify(serviceREST).getPolicy(Id); Mockito.verify(serviceREST).getServiceByName(policy.getService()); Mockito.verify(serviceUtil).toVXPolicy(policy, service); }