ProductCertificateCurator extends AbstractHibernateCurator<ProductCertificate> { public ProductCertificate findForProduct(Product product) { log.debug("Finding cert for product: {}", product); return (ProductCertificate) currentSession() .createCriteria(ProductCertificate.class) .add(Restrictions.eq("product", product)) .uniqueResult(); } @Inject  ProductCertificateCurator(PKIUtility pki, X509ExtensionUtil extensionUtil); ProductCertificate findForProduct(Product product); ProductCertificate getCertForProduct(Product product);  }
@Test public void emptyFindForProduct() { assertNull(productCertificateCurator.findForProduct(product)); }
@Test public void nullForNull() { assertNull(productCertificateCurator.findForProduct(null)); }
@Test public void validFindForProduct() { ProductCertificate cert = new ProductCertificate(); cert.setProduct(product); cert.setKey("key"); cert.setCert("cert"); productCertificateCurator.create(cert); assertEquals(cert, productCertificateCurator.findForProduct(product)); }