public void testCountByC_R_P_V() throws Exception { Content content = createContent(); int count = _persistence.countByC_R_P_V( content.getCompanyId(), content.getRepositoryId(), content.getPath(), content.getVersion()); assertEquals(0, count); _persistence.update(content); count = _persistence.countByC_R_P_V( content.getCompanyId(), content.getRepositoryId(), content.getPath(), content.getVersion()); assertEquals(1, count); _persistence.remove(content.getContentId()); count = _persistence.countByC_R_P_V( content.getCompanyId(), content.getRepositoryId(), content.getPath(), content.getVersion()); assertEquals(0, count); }
public void testFindByC_R_P() throws Exception { Content content1 = addContent(); long contentId2 = content1.getContentId() + 1; String version2 = content1.getVersion().concat("-2"); int size = (int) content1.getSize(); Blob data = new OutputBlob(new ByteArrayInputStream(new byte[size]), size); Content content2 = new Content( contentId2, content1.getCompanyId(), content1.getPortletId(), content1.getGroupId(), content1.getRepositoryId(), content1.getPath(), version2, data, size); _persistence.update(content2); Content existingContent2 = _persistence.findByC_R_P( content1.getCompanyId(), content1.getRepositoryId(), content1.getPath()); assertTrue(existingContent2.equals(content2)); _persistence.remove(existingContent2.getContentId()); Content existingContent1 = _persistence.findByC_R_P( content1.getCompanyId(), content1.getRepositoryId(), content1.getPath()); assertTrue(existingContent1.equals(content1)); _persistence.remove(existingContent1.getContentId()); try { _persistence.findByC_R_P( content1.getCompanyId(), content1.getRepositoryId(), content1.getPath()); fail("Missing entity did not throw NoSuchContentException"); } catch (NoSuchContentException nsce) { } }
public void testFetchByC_R_P() throws Exception { Content content1 = addContent(); long contentId2 = content1.getContentId() + 1; String version2 = content1.getVersion().concat("-2"); int size = (int) content1.getSize(); Blob data = new OutputBlob(new ByteArrayInputStream(new byte[size]), size); Content content2 = new Content( contentId2, content1.getCompanyId(), content1.getPortletId(), content1.getGroupId(), content1.getRepositoryId(), content1.getPath(), version2, data, size); _persistence.update(content2); Content existingContent2 = _persistence.fetchByC_R_P( content1.getCompanyId(), content1.getRepositoryId(), content1.getPath()); assertTrue(existingContent2.equals(content2)); _persistence.remove(existingContent2.getContentId()); Content existingContent1 = _persistence.fetchByC_R_P( content1.getCompanyId(), content1.getRepositoryId(), content1.getPath()); assertTrue(existingContent1.equals(content1)); _persistence.remove(existingContent1.getContentId()); Content missingContent = _persistence.fetchByC_R_P( content1.getCompanyId(), content1.getRepositoryId(), content1.getPath()); assertNull(missingContent); }
public void testRemoveByC_R_P_V() throws Exception { Content content = addContent(); Content existingContent = _persistence.fetchByPrimaryKey(content.getContentId()); assertNotNull(existingContent); boolean removed = _persistence.removeByC_R_P_V( existingContent.getCompanyId(), existingContent.getRepositoryId(), existingContent.getPath(), existingContent.getVersion()); assertTrue(removed); existingContent = _persistence.fetchByPrimaryKey(content.getContentId()); assertNull(existingContent); }
public void testFetchByC_R_P_V() throws Exception { Content content = addContent(); Content existingContent = _persistence.fetchByC_R_P_V( content.getCompanyId(), content.getRepositoryId(), content.getPath(), content.getVersion()); assertTrue(existingContent.equals(content)); _persistence.remove(existingContent.getContentId()); Content missingContent = _persistence.fetchByC_R_P_V( content.getCompanyId(), content.getRepositoryId(), content.getPath(), randomString()); assertNull(missingContent); }
public void testFindByC_R_P_V() throws Exception { Content content = addContent(); Content existingContent = _persistence.findByC_R_P_V( content.getCompanyId(), content.getRepositoryId(), content.getPath(), content.getVersion()); assertTrue(existingContent.equals(content)); _persistence.remove(existingContent.getContentId()); try { _persistence.findByC_R_P_V( content.getCompanyId(), content.getRepositoryId(), content.getPath(), randomString()); fail("Missing entity did not throw NoSuchContentException"); } catch (NoSuchContentException nsce) { } }