OwnerContentCurator extends AbstractHibernateCurator<OwnerContent> { public CandlepinQuery<Owner> getOwnersByContent(Content content) { return this.getOwnersByContent(content.getId()); } OwnerContentCurator(); Content getContentById(Owner owner, String contentId); @Transactional Content getContentById(String ownerId, String contentId); CandlepinQuery<Owner> getOwnersByContent(Content content); CandlepinQuery<Owner> getOwnersByContent(String contentId); Collection<String> getContentUuidsByOwner(Owner owner); Collection<String> getContentUuidsByOwner(String ownerId); CandlepinQuery<Content> getContentByOwner(Owner owner); CandlepinQuery<Content> getContentByOwner(String ownerId); CandlepinQuery<Content> getContentByIds(Owner owner, Collection<String> contentIds); CandlepinQuery<Content> getContentByIds(String ownerId, Collection<String> contentIds); @Transactional long getOwnerCount(Content content); @Transactional boolean contentExists(Owner owner, String contentId); @Transactional boolean isContentMappedToOwner(Content content, Owner owner); @Transactional boolean mapContentToOwner(Content content, Owner owner); @Transactional int mapContentToOwners(Content content, Owner... owners); @Transactional int mapOwnerToContent(Owner owner, Content... content); @Transactional boolean removeOwnerFromContent(Content content, Owner owner); @Transactional int clearOwnersForContent(Content content); @Transactional int clearContentForOwner(Owner owner); @SuppressWarnings("checkstyle:indentation") CandlepinQuery<Content> getContentByVersions(Owner owner, Map<String, Integer> contentVersions); CandlepinQuery<Content> getOrphanedContent(); @Transactional void updateOwnerContentReferences(Owner owner, Map<String, String> contentUuidMap); @Transactional void removeOwnerContentReferences(Owner owner, Collection<String> contentUuids);  }
@Test public void testGetOwnersByContent() { Owner owner1 = this.createOwner(); Owner owner2 = this.createOwner(); Owner owner3 = this.createOwner(); Content content = this.createContent(); this.createOwnerContentMapping(owner1, content); this.createOwnerContentMapping(owner2, content); Collection<Owner> ownersA = this.ownerContentCurator.getOwnersByContent(content).list(); Collection<Owner> ownersB = this.ownerContentCurator.getOwnersByContent(content.getId()).list(); assertTrue(ownersA.contains(owner1)); assertTrue(ownersA.contains(owner2)); assertFalse(ownersA.contains(owner3)); assertEquals(ownersA, ownersB); }
@Test public void testGetOwnersByContentWithUnmappedContent() { Owner owner1 = this.createOwner(); Owner owner2 = this.createOwner(); Owner owner3 = this.createOwner(); Content content = this.createContent(); Collection<Owner> ownersA = this.ownerContentCurator.getOwnersByContent(content).list(); Collection<Owner> ownersB = this.ownerContentCurator.getOwnersByContent(content.getId()).list(); assertTrue(ownersA.isEmpty()); assertTrue(ownersB.isEmpty()); }