use of org.candlepin.model.ProductCertificate in project candlepin by candlepin.
the class ProductResource method getProductCertificate.
@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
public ProductCertificateDTO getProductCertificate(@PathParam("product_uuid") String productUuid) {
// TODO:
// Should this be enabled globally? This will create a cert if it hasn't yet been created.
Product product = this.fetchProduct(productUuid);
ProductCertificate productCertificate = this.productCertCurator.getCertForProduct(product);
return this.translator.translate(productCertificate, ProductCertificateDTO.class);
}
use of org.candlepin.model.ProductCertificate in project candlepin by candlepin.
the class ProductResourceTest method getProductCertificate.
@Test
public void getProductCertificate() {
Owner owner = this.createOwner("Example-Corporation");
Product entity = this.createProduct(owner);
// ensure we check SecurityHole
securityInterceptor.enable();
ProductCertificate cert = new ProductCertificate();
cert.setCert("some text");
cert.setKey("some key");
cert.setProduct(entity);
productCertificateCurator.create(cert);
ProductCertificateDTO cert1 = productResource.getProductCertificate(entity.getUuid());
ProductCertificateDTO expected = this.modelTranslator.translate(cert, ProductCertificateDTO.class);
assertEquals(cert1, expected);
}
Aggregations