@Test public void test6countRepositories() throws Exception { HttpServletRequest request = Mockito.mock(HttpServletRequest.class); VXLong vXLong = new VXLong(); List<RangerService> ret = new ArrayList<RangerService>(); RangerService rangerService = rangerService(); VXRepository vXRepository = vXRepository(rangerService); List<VXRepository> repoList = new ArrayList<VXRepository>(); repoList.add(vXRepository); VXRepositoryList vXRepositoryList = new VXRepositoryList(repoList); SearchFilter filter = new SearchFilter(); filter.setParam(SearchFilter.POLICY_NAME, "policyName"); filter.setParam(SearchFilter.SERVICE_NAME, "serviceName"); Mockito.when(searchUtil.getSearchFilterFromLegacyRequestForRepositorySearch(request, xAssetService.sortFields)).thenReturn(filter); Mockito.when(serviceREST.getServices(filter)).thenReturn(ret); Mockito.when(serviceUtil.rangerServiceListToPublicObjectList(ret)).thenReturn(vXRepositoryList); VXRepositoryList dbVXRepositoryList = publicAPIs.searchRepositories(request); vXLong.setValue(dbVXRepositoryList.getResultSize()); Assert.assertNotNull(vXLong); Assert.assertEquals(vXLong.getValue(), 1); Mockito.verify(searchUtil).getSearchFilterFromLegacyRequestForRepositorySearch(request, xAssetService.sortFields); Mockito.verify(serviceREST).getServices(filter); Mockito.verify(serviceUtil).rangerServiceListToPublicObjectList(ret); }
@GET @Path("/api/repository/") @Produces({ "application/json", "application/xml" }) public VXRepositoryList searchRepositories( @Context HttpServletRequest request) { if(logger.isDebugEnabled()) { logger.debug("==> PublicAPIs.searchRepositories()"); } SearchFilter filter = searchUtil.getSearchFilterFromLegacyRequestForRepositorySearch(request, xAssetService.sortFields); List<RangerService> serviceList = serviceREST.getServices(filter); VXRepositoryList ret = null; if (serviceList != null) { ret = serviceUtil.rangerServiceListToPublicObjectList(serviceList); } if(logger.isDebugEnabled()) { logger.debug("<== PublicAPIs.searchRepositories(): count=" + (ret == null ? 0 : ret.getListSize())); } return ret; }
PublicAPIs { @GET @Path("/api/repository/") @Produces({ "application/json", "application/xml" }) public VXRepositoryList searchRepositories( @Context HttpServletRequest request) { if(logger.isDebugEnabled()) { logger.debug("==> PublicAPIs.searchRepositories()"); } SearchFilter filter = searchUtil.getSearchFilterFromLegacyRequestForRepositorySearch(request, xAssetService.sortFields); List<RangerService> serviceList = serviceREST.getServices(filter); VXRepositoryList ret = null; if (serviceList != null) { ret = serviceUtil.rangerServiceListToPublicObjectList(serviceList); } if(logger.isDebugEnabled()) { logger.debug("<== PublicAPIs.searchRepositories(): count=" + (ret == null ? 0 : ret.getListSize())); } return ret; } }
PublicAPIs { @GET @Path("/api/repository/") @Produces({ "application/json", "application/xml" }) public VXRepositoryList searchRepositories( @Context HttpServletRequest request) { if(logger.isDebugEnabled()) { logger.debug("==> PublicAPIs.searchRepositories()"); } SearchFilter filter = searchUtil.getSearchFilterFromLegacyRequestForRepositorySearch(request, xAssetService.sortFields); List<RangerService> serviceList = serviceREST.getServices(filter); VXRepositoryList ret = null; if (serviceList != null) { ret = serviceUtil.rangerServiceListToPublicObjectList(serviceList); } if(logger.isDebugEnabled()) { logger.debug("<== PublicAPIs.searchRepositories(): count=" + (ret == null ? 0 : ret.getListSize())); } return ret; }  }
PublicAPIs { @GET @Path("/api/repository/") @Produces({ "application/json", "application/xml" }) public VXRepositoryList searchRepositories( @Context HttpServletRequest request) { if(logger.isDebugEnabled()) { logger.debug("==> PublicAPIs.searchRepositories()"); } SearchFilter filter = searchUtil.getSearchFilterFromLegacyRequestForRepositorySearch(request, xAssetService.sortFields); List<RangerService> serviceList = serviceREST.getServices(filter); VXRepositoryList ret = null; if (serviceList != null) { ret = serviceUtil.rangerServiceListToPublicObjectList(serviceList); } if(logger.isDebugEnabled()) { logger.debug("<== PublicAPIs.searchRepositories(): count=" + (ret == null ? 0 : ret.getListSize())); } 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); }
PublicAPIs { @GET @Path("/api/repository/") @Produces({ "application/json", "application/xml" }) public VXRepositoryList searchRepositories( @Context HttpServletRequest request) { if(logger.isDebugEnabled()) { logger.debug("==> PublicAPIs.searchRepositories()"); } SearchFilter filter = searchUtil.getSearchFilterFromLegacyRequestForRepositorySearch(request, xAssetService.sortFields); List<RangerService> serviceList = serviceREST.getServices(filter); VXRepositoryList ret = null; if (serviceList != null) { ret = serviceUtil.rangerServiceListToPublicObjectList(serviceList); } if(logger.isDebugEnabled()) { logger.debug("<== PublicAPIs.searchRepositories(): count=" + (ret == null ? 0 : ret.getListSize())); } 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);  }