ProductCurator extends AbstractHibernateCurator<Product> { public boolean productHasSubscriptions(Owner owner, Product product) { return ((Long) currentSession().createCriteria(Pool.class) .createAlias("providedProducts", "providedProd", JoinType.LEFT_OUTER_JOIN) .createAlias("derivedProvidedProducts", "derivedProvidedProd", JoinType.LEFT_OUTER_JOIN) .add(Restrictions.eq("owner", owner)) .add(Restrictions.or( Restrictions.eq("product.uuid", product.getUuid()), Restrictions.eq("derivedProduct.uuid", product.getUuid()), Restrictions.eq("providedProd.uuid", product.getUuid()), Restrictions.eq("derivedProvidedProd.uuid", product.getUuid()))) .setProjection(Projections.count("id")) .uniqueResult()) > 0; } @Inject  ProductCurator(Configuration config,
        AttributeValidator attributeValidator); Product getByName(Owner owner, String name); CandlepinQuery<Product> listAllByUuids(Collection<? extends Serializable> uuids); Set<Product> getPoolDerivedProvidedProductsCached(Pool pool); Set<Product> getPoolDerivedProvidedProductsCached(String poolId); Set<Product> getPoolProvidedProductsCached(Pool pool); Set<Product> getPoolProvidedProductsCached(String poolId); Set<String> getPoolProvidedProductUuids(String poolId); Set<String> getDerivedPoolProvidedProductUuids(String poolId); Set<Product> getProductsByUuidCached(Set<String> productUuids); Map<String, Product> getHydratedProductsByUuid(Set<String> uuids); int hydratePoolProvidedProducts(Iterable<Pool> pools); @Transactional Product create(Product entity); @Transactional Product merge(Product entity); @Override @Transactional void delete(Product entity); boolean productHasSubscriptions(Owner owner, Product product); CandlepinQuery<Product> getProductsByContent(Owner owner, Collection<String> contentIds); @SuppressWarnings("unchecked") CandlepinQuery<Product> getProductsByContent(Owner owner, Collection<String> contentIds,
        Collection<String> productsToOmit); @SuppressWarnings("unchecked") CandlepinQuery<Product> getProductsByContentUuids(Collection<String> contentUuids); @SuppressWarnings("unchecked") CandlepinQuery<Product> getProductsByContentUuids(Owner owner, Collection<String> contentUuids);  }
@Test public void ensureProductHasSubscription() { assertTrue(productCurator.productHasSubscriptions(owner, product)); }
@Test public void ensureProvidedProductHasSubscription() { assertTrue(productCurator.productHasSubscriptions(owner, providedProduct)); }
@Test public void ensureDerivedProductHasSubscription() { assertTrue(productCurator.productHasSubscriptions(owner, derivedProduct)); }
@Test public void ensureDerivedProvidedProductHasSubscription() { assertTrue(productCurator.productHasSubscriptions(owner, derivedProvidedProduct)); }
@Test public void ensureDoesNotHaveSubscription() { Product noSub = this.createProduct("p1", "p1", owner); assertFalse(productCurator.productHasSubscriptions(owner, noSub)); }