OwnerProductCurator extends AbstractHibernateCurator<OwnerProduct> { public Product getProductById(Owner owner, String productId) { return this.getProductById(owner.getId(), productId); } OwnerProductCurator(); @Transactional OwnerProduct getOwnerProductByProductId(Owner owner, String productId); Product getProductById(Owner owner, String productId); @Transactional Product getProductById(String ownerId, String productId); @Transactional Product getProductByIdUsingOwnerKey(String ownerKey, String productId); CandlepinQuery<Owner> getOwnersByProduct(Product product); CandlepinQuery<Owner> getOwnersByProduct(String productId); Collection<String> getProductUuidsByOwner(Owner owner); Collection<String> getProductUuidsByOwner(String ownerId); CandlepinQuery<Product> getProductsByOwner(Owner owner); CandlepinQuery<Product> getProductsByOwner(String ownerId); CandlepinQuery<Product> getProductsByIds(Owner owner, Collection<String> productIds); CandlepinQuery<Product> getProductsByIds(String ownerId, Collection<String> productIds); CandlepinQuery<Product> getProductsByIdsUsingOwnerKey(String ownerKey,
        Collection<String> productIds); @Transactional long getOwnerCount(Product product); @Transactional boolean productExists(Owner owner, String productId); @Transactional Set<String> filterUnknownProductIds(Owner owner, Collection<String> productIds); @Transactional boolean isProductMappedToOwner(Product product, Owner owner); @Transactional boolean mapProductToOwner(Product product, Owner owner); @Transactional int mapProductToOwners(Product product, Owner... owners); @Transactional int mapOwnerToProducts(Owner owner, Product... products); @Transactional boolean removeOwnerFromProduct(Product product, Owner owner); @Transactional int clearOwnersForProduct(Product product); @Transactional int clearProductsForOwner(Owner owner); CandlepinQuery<Product> getOrphanedProducts(); @SuppressWarnings("checkstyle:indentation") CandlepinQuery<Product> getProductsByVersions(Owner owner, Map<String, Integer> productVersions); @Transactional void updateOwnerProductReferences(Owner owner, Map<String, String> productUuidMap); @Transactional @SuppressWarnings("checkstyle:indentation") void removeOwnerProductReferences(Owner owner, Collection<String> productUuids);  }
@Test public void testGetProductById() { Owner owner = this.createOwner(); Product product = this.createProduct(); this.createOwnerProductMapping(owner, product); Product resultA = this.ownerProductCurator.getProductById(owner, product.getId()); assertEquals(resultA, product); Product resultB = this.ownerProductCurator.getProductById(owner.getId(), product.getId()); assertEquals(resultB, product); assertSame(resultA, resultB); }
@Test public void testGetProductByIdNoMapping() { Owner owner = this.createOwner(); Product product = this.createProduct(); Product resultA = this.ownerProductCurator.getProductById(owner, product.getId()); assertNull(resultA); Product resultB = this.ownerProductCurator.getProductById(owner.getId(), product.getId()); assertNull(resultB); }
@Test public void testGetProductByIdWrongProductId() { Owner owner = this.createOwner(); Product product1 = this.createProduct(); Product product2 = this.createProduct(); this.createOwnerProductMapping(owner, product1); Product resultA = this.ownerProductCurator.getProductById(owner, product2.getId()); assertNull(resultA); Product resultB = this.ownerProductCurator.getProductById(owner.getId(), product2.getId()); assertNull(resultB); }