mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 12:19:54 +01:00
Show blog posts from RSS feeds with a dedicated icon
This adds a field to the post headers and some more tests.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package org.briarproject.briar.blog;
|
||||
|
||||
import org.briarproject.bramble.api.db.Transaction;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.bramble.test.TestDatabaseModule;
|
||||
import org.briarproject.briar.api.blog.Blog;
|
||||
@@ -32,7 +33,7 @@ public class BlogManagerIntegrationTest
|
||||
extends BriarIntegrationTest<BriarIntegrationTestComponent> {
|
||||
|
||||
private BlogManager blogManager0, blogManager1;
|
||||
private Blog blog0, blog1;
|
||||
private Blog blog0, blog1, rssBlog;
|
||||
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
@@ -50,6 +51,12 @@ public class BlogManagerIntegrationTest
|
||||
|
||||
blog0 = blogFactory.createBlog(author0);
|
||||
blog1 = blogFactory.createBlog(author1);
|
||||
|
||||
rssBlog = blogFactory.createFeedBlog(author0);
|
||||
Transaction txn = db0.startTransaction(false);
|
||||
blogManager0.addBlog(txn, rssBlog);
|
||||
db0.commitTransaction(txn);
|
||||
db0.endTransaction(txn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -393,4 +400,62 @@ public class BlogManagerIntegrationTest
|
||||
assertEquals(2, headers0.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFeedPost() throws Exception {
|
||||
assertTrue(rssBlog.isRssFeed());
|
||||
|
||||
// add a feed post to rssBlog
|
||||
final String body = getRandomString(42);
|
||||
BlogPost p = blogPostFactory
|
||||
.createBlogPost(rssBlog.getId(), clock.currentTimeMillis(),
|
||||
null, author0, body);
|
||||
blogManager0.addLocalPost(p);
|
||||
|
||||
// make sure it got saved as an RSS feed post
|
||||
Collection<BlogPostHeader> headers =
|
||||
blogManager0.getPostHeaders(rssBlog.getId());
|
||||
assertEquals(1, headers.size());
|
||||
BlogPostHeader header = headers.iterator().next();
|
||||
assertEquals(POST, header.getType());
|
||||
assertTrue(header.isRssFeed());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFeedReblog() throws Exception {
|
||||
// add a feed post to rssBlog
|
||||
final String body = getRandomString(42);
|
||||
BlogPost p = blogPostFactory
|
||||
.createBlogPost(rssBlog.getId(), clock.currentTimeMillis(),
|
||||
null, author0, body);
|
||||
blogManager0.addLocalPost(p);
|
||||
|
||||
// reblog feed post to own blog
|
||||
Collection<BlogPostHeader> headers =
|
||||
blogManager0.getPostHeaders(rssBlog.getId());
|
||||
assertEquals(1, headers.size());
|
||||
BlogPostHeader header = headers.iterator().next();
|
||||
blogManager0.addLocalComment(author0, blog0.getId(), null, header);
|
||||
|
||||
// make sure it got saved as an RSS feed post
|
||||
headers = blogManager0.getPostHeaders(blog0.getId());
|
||||
assertEquals(1, headers.size());
|
||||
BlogCommentHeader commentHeader =
|
||||
(BlogCommentHeader) headers.iterator().next();
|
||||
assertEquals(COMMENT, commentHeader.getType());
|
||||
assertTrue(commentHeader.getParent().isRssFeed());
|
||||
|
||||
// reblog reblogged post again to own blog
|
||||
blogManager0
|
||||
.addLocalComment(author0, blog0.getId(), null, commentHeader);
|
||||
|
||||
// make sure it got saved as an RSS feed post
|
||||
headers = blogManager0.getPostHeaders(blog0.getId());
|
||||
assertEquals(2, headers.size());
|
||||
for (BlogPostHeader h: headers) {
|
||||
assertTrue(h instanceof BlogCommentHeader);
|
||||
assertEquals(COMMENT, h.getType());
|
||||
assertTrue(((BlogCommentHeader) h).getParent().isRssFeed());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.briarproject.bramble.test.TestUtils;
|
||||
import org.briarproject.bramble.transport.TransportModule;
|
||||
import org.briarproject.briar.api.blog.Blog;
|
||||
import org.briarproject.briar.api.blog.BlogManager;
|
||||
import org.briarproject.briar.api.blog.BlogPostHeader;
|
||||
import org.briarproject.briar.api.feed.Feed;
|
||||
import org.briarproject.briar.api.feed.FeedManager;
|
||||
import org.briarproject.briar.blog.BlogModule;
|
||||
@@ -88,6 +89,13 @@ public class FeedManagerIntegrationTest extends BriarTestCase {
|
||||
assertEquals(feed.getTitle(), feed.getBlog().getName());
|
||||
assertEquals(feed.getTitle(), feed.getLocalAuthor().getName());
|
||||
|
||||
// check the feed entries have been added to the blog as expected
|
||||
Collection<BlogPostHeader> headers =
|
||||
blogManager.getPostHeaders(feedBlog.getId());
|
||||
for (BlogPostHeader header : headers) {
|
||||
assertTrue(header.isRssFeed());
|
||||
}
|
||||
|
||||
// now let's remove the feed's blog again
|
||||
blogManager.removeBlog(feedBlog);
|
||||
blogs = blogManager.getBlogs();
|
||||
|
||||
Reference in New Issue
Block a user