OwnerContentCurator extends AbstractHibernateCurator<OwnerContent> { public Content getContentById(Owner owner, String contentId) { return this.getContentById(owner.getId(), contentId); } 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 testGetContentById() { Owner owner = this.createOwner(); Content content = this.createContent(); this.createOwnerContentMapping(owner, content); Content resultA = this.ownerContentCurator.getContentById(owner, content.getId()); assertEquals(resultA, content); Content resultB = this.ownerContentCurator.getContentById(owner.getId(), content.getId()); assertEquals(resultB, content); assertSame(resultA, resultB); }
@Test public void testGetContentByIdNoMapping() { Owner owner = this.createOwner(); Content content = this.createContent(); Content resultA = this.ownerContentCurator.getContentById(owner, content.getId()); assertNull(resultA); Content resultB = this.ownerContentCurator.getContentById(owner.getId(), content.getId()); assertNull(resultB); }
@Test public void testGetContentByIdWrongContentId() { Owner owner = this.createOwner(); Content content1 = this.createContent(); Content content2 = this.createContent(); this.createOwnerContentMapping(owner, content1); Content resultA = this.ownerContentCurator.getContentById(owner, content2.getId()); assertNull(resultA); Content resultB = this.ownerContentCurator.getContentById(owner.getId(), content2.getId()); assertNull(resultB); }