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 testUpdateExisting() throws Exception { Content content = addContent(); byte[] bytes = new byte[1024]; Blob data = new OutputBlob(new ByteArrayInputStream(bytes), bytes.length); Content newContent = new Content( content.getContentId(), nextLong(), randomString(), nextLong(), nextLong(), randomString(), randomString(), data, data.length()); _persistence.update(newContent); Content existingContent = _persistence.findByPrimaryKey(newContent.getContentId()); assertTrue(existingContent.equals(newContent)); }
public void testFindByPrimaryKeyExisting() throws Exception { Content content = addContent(); Content existingContent = _persistence.findByPrimaryKey(content.getContentId()); assertTrue(existingContent.equals(content)); }
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 testRemove() throws Exception { Content content = addContent(); Content existingContent = _persistence.fetchByPrimaryKey(content.getContentId()); assertNotNull(existingContent); assertTrue(existingContent.equals(content)); _persistence.remove(content.getContentId()); 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) { } }