ProductResource { @ApiOperation(notes = "Retrieves a list of Owners by Product", value = "getProductOwners", response = OwnerDTO.class, responseContainer = "list") @ApiResponses({ @ApiResponse(code = 400, message = "") }) @GET @Path("/owners") @Produces(MediaType.APPLICATION_JSON) public CandlepinQuery<OwnerDTO> getProductOwners( @ApiParam(value = "Multiple product UUIDs", required = true) @QueryParam("product") List<String> productUuids) { if (productUuids.isEmpty()) { throw new BadRequestException(i18n.tr("No product IDs specified")); } return this.translator.translateQuery( this.ownerCurator.getOwnersWithProducts(productUuids), OwnerDTO.class); } @Inject  ProductResource(ProductCurator productCurator, OwnerCurator ownerCurator,
        ProductCertificateCurator productCertCurator, Configuration config, I18n i18n,
        ModelTranslator translator, JobManager jobManager); @ApiOperation(notes = "Retrieves a single Product", value = "getProduct") @ApiResponses({ @ApiResponse(code = 404, message = "") }) @GET @Path("/{product_uuid}") @Produces(MediaType.APPLICATION_JSON) @SecurityHole ProductDTO getProduct(@PathParam("product_uuid") String productUuid); @ApiOperation(notes = "Retreives a Certificate for a Product", value = "getProductCertificate") @ApiResponses({ @ApiResponse(code = 404, message = "") }) @GET @Path("/{product_uuid}/certificate") @Produces(MediaType.APPLICATION_JSON) @SecurityHole ProductCertificateDTO getProductCertificate(
        @PathParam("product_uuid") String productUuid); @ApiOperation(notes = "Creates a Product. Returns either the new created " + "Product or the Product that already existed. @deprecated Use per-org" + " version", value = "createProduct") @POST @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Deprecated ProductDTO createProduct(ProductDTO product); @ApiOperation(notes = "Updates a Product @deprecated Use per-org version", value = "updateProduct") @ApiResponses({ @ApiResponse(code = 400, message = "") }) @PUT @Path("/{product_uuid}") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.WILDCARD) @Deprecated ProductDTO updateProduct(
        @PathParam("product_uuid") String productUuid,
        @ApiParam(name = "product", required = true) ProductDTO product); @ApiOperation(notes = "Adds Content to a Product Batch mode @deprecated Use per-org version", value = "addBatchContent") @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Path("/{product_uuid}/batch_content") @Deprecated ProductDTO addBatchContent(
        @PathParam("product_uuid") String productUuid,
        Map<String, Boolean> contentMap); @ApiOperation(notes = "Adds Content to a Product. Single mode @deprecated Use " + "per-org version", value = "addContent") @ApiResponses({ }) @POST @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.WILDCARD) @Path("/{product_uuid}/content/{content_id}") @Deprecated ProductDTO addContent(
        @PathParam("product_uuid") String productUuid,
        @PathParam("content_id") String contentId,
        @QueryParam("enabled") Boolean enabled); @ApiOperation(notes = "Removes Content from a Product @deprecated Use per-org version", value = "removeContent") @DELETE @Produces(MediaType.APPLICATION_JSON) @Path("/{product_uuid}/content/{content_id}") @Deprecated void removeContent(
        @PathParam("product_uuid") String productUuid,
        @PathParam("content_id") String contentId); @ApiOperation(notes = "Removes a Product @deprecated Use per-org version", value = "deleteProduct") @ApiResponses({ @ApiResponse(code = 400, message = ""), @ApiResponse(code = 404, message = "") }) @DELETE @Produces(MediaType.APPLICATION_JSON) @Path("/{product_uuid}") @Deprecated void deleteProduct(
        @PathParam("product_uuid") String productUuid); @ApiOperation(notes = "Retrieves a list of Owners by Product", value = "getProductOwners", response = OwnerDTO.class, responseContainer = "list") @ApiResponses({ @ApiResponse(code = 400, message = "") }) @GET @Path("/owners") @Produces(MediaType.APPLICATION_JSON) CandlepinQuery<OwnerDTO> getProductOwners(
        @ApiParam(value = "Multiple product UUIDs", required = true)
        @QueryParam("product") List<String> productUuids); @ApiOperation(notes = "Refreshes Pools by Product", value = "refreshPoolsForProduct", response = AsyncJobStatusDTO.class, responseContainer = "List") @PUT @Path("/subscriptions") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.WILDCARD) Stream<AsyncJobStatusDTO> refreshPoolsForProduct(
        @ApiParam(value = "Multiple product UUIDs", required = true)
        @QueryParam("product") List<String> productUuids,
        @QueryParam("lazy_regen") @DefaultValue("true") Boolean lazyRegen);  }
@Test public void testGetOwnersForProducts() { List<Owner> owners = this.setupDBForOwnerProdTests(); Owner owner1 = owners.get(0); Owner owner2 = owners.get(1); Owner owner3 = owners.get(2); OwnerDTO ownerDTO1 = this.modelTranslator.translate(owner1, OwnerDTO.class); OwnerDTO ownerDTO2 = this.modelTranslator.translate(owner2, OwnerDTO.class); OwnerDTO ownerDTO3 = this.modelTranslator.translate(owner3, OwnerDTO.class); List<OwnerDTO> ownersReturned = null; ownersReturned = productResource.getProductOwners(Arrays.asList("p1")).list(); assertEquals(Arrays.asList(ownerDTO1, ownerDTO2), ownersReturned); ownersReturned = productResource.getProductOwners(Arrays.asList("p1", "p2")).list(); assertEquals(Arrays.asList(ownerDTO1, ownerDTO2, ownerDTO3), ownersReturned); ownersReturned = productResource.getProductOwners(Arrays.asList("p3")).list(); assertEquals(Arrays.asList(ownerDTO3), ownersReturned); ownersReturned = productResource.getProductOwners(Arrays.asList("nope")).list(); assertEquals(0, ownersReturned.size()); }
@Test public void testGetOwnersForProductsInputValidation() { assertThrows(BadRequestException.class, () -> productResource.getProductOwners(new LinkedList<>())); }