@Test public void testAddLocalPost() throws DbException, FormatException { Transaction txn = new Transaction(null, false); BlogPost post = new BlogPost(message, null, localAuthor1); BdfDictionary meta = BdfDictionary.of( new BdfEntry(KEY_TYPE, POST.getInt()), new BdfEntry(KEY_TIMESTAMP, timestamp), new BdfEntry(KEY_AUTHOR, authorList1), new BdfEntry(KEY_READ, true), new BdfEntry(KEY_RSS_FEED, false) ); context.checking(new Expectations() {{ oneOf(db).startTransaction(false); will(returnValue(txn)); oneOf(db).getGroup(txn, blog1.getId()); will(returnValue(blog1.getGroup())); oneOf(blogFactory).parseBlog(blog1.getGroup()); will(returnValue(blog1)); oneOf(clientHelper).toList(localAuthor1); will(returnValue(authorList1)); oneOf(clientHelper).addLocalMessage(txn, message, meta, true); oneOf(clientHelper).parseAndValidateAuthor(authorList1); will(returnValue(localAuthor1)); oneOf(identityManager).getAuthorStatus(txn, localAuthor1.getId()); will(returnValue(OURSELVES)); oneOf(db).commitTransaction(txn); oneOf(db).endTransaction(txn); }}); blogManager.addLocalPost(post); context.assertIsSatisfied(); assertEquals(1, txn.getEvents().size()); assertTrue(txn.getEvents().get(0) instanceof BlogPostAddedEvent); BlogPostAddedEvent e = (BlogPostAddedEvent) txn.getEvents().get(0); assertEquals(blog1.getId(), e.getGroupId()); BlogPostHeader h = e.getHeader(); assertEquals(POST, h.getType()); assertEquals(timestamp, h.getTimestamp()); assertEquals(timestamp, h.getTimeReceived()); assertEquals(messageId, h.getId()); assertEquals(blog1.getId(), h.getGroupId()); assertNull(h.getParentId()); assertEquals(OURSELVES, h.getAuthorStatus()); assertEquals(localAuthor1, h.getAuthor()); }
@Override public void addLocalPost(BlogPost p) throws DbException { Transaction txn = db.startTransaction(false); try { addLocalPost(txn, p); db.commitTransaction(txn); } finally { db.endTransaction(txn); } }
BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
		ContactHook, Client { @Override public void addLocalPost(BlogPost p) throws DbException { Transaction txn = db.startTransaction(false); try { addLocalPost(txn, p); db.commitTransaction(txn); } finally { db.endTransaction(txn); } } }
BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
		ContactHook, Client { @Override public void addLocalPost(BlogPost p) throws DbException { Transaction txn = db.startTransaction(false); try { addLocalPost(txn, p); db.commitTransaction(txn); } finally { db.endTransaction(txn); } } @Inject  BlogManagerImpl(DatabaseComponent db, IdentityManager identityManager,
			ClientHelper clientHelper, MetadataParser metadataParser,
			BlogFactory blogFactory, BlogPostFactory blogPostFactory); }
BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
		ContactHook, Client { @Override public void addLocalPost(BlogPost p) throws DbException { Transaction txn = db.startTransaction(false); try { addLocalPost(txn, p); db.commitTransaction(txn); } finally { db.endTransaction(txn); } } @Inject  BlogManagerImpl(DatabaseComponent db, IdentityManager identityManager,
			ClientHelper clientHelper, MetadataParser metadataParser,
			BlogFactory blogFactory, BlogPostFactory blogPostFactory); @Override void createLocalState(Transaction txn); @Override void addingContact(Transaction txn, Contact c); @Override void removingContact(Transaction txn, Contact c); @Override void addBlog(Blog b); @Override void addBlog(Transaction txn, Blog b); @Override boolean canBeRemoved(Blog b); @Override void removeBlog(Blog b); @Override void removeBlog(Transaction txn, Blog b); @Override void addLocalPost(BlogPost p); @Override void addLocalPost(Transaction txn, BlogPost p); @Override void addLocalComment(LocalAuthor author, GroupId groupId,
			@Nullable String comment, BlogPostHeader parentHeader); @Override Blog getBlog(GroupId g); @Override Blog getBlog(Transaction txn, GroupId g); @Override Collection<Blog> getBlogs(LocalAuthor localAuthor); @Override Blog getPersonalBlog(Author author); @Override Collection<Blog> getBlogs(); @Override BlogPostHeader getPostHeader(GroupId g, MessageId m); @Override String getPostBody(MessageId m); @Override Collection<BlogPostHeader> getPostHeaders(GroupId g); @Override void setReadFlag(MessageId m, boolean read); @Override void registerRemoveBlogHook(RemoveBlogHook hook); }
BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
		ContactHook, Client { @Override public void addLocalPost(BlogPost p) throws DbException { Transaction txn = db.startTransaction(false); try { addLocalPost(txn, p); db.commitTransaction(txn); } finally { db.endTransaction(txn); } } @Inject  BlogManagerImpl(DatabaseComponent db, IdentityManager identityManager,
			ClientHelper clientHelper, MetadataParser metadataParser,
			BlogFactory blogFactory, BlogPostFactory blogPostFactory); @Override void createLocalState(Transaction txn); @Override void addingContact(Transaction txn, Contact c); @Override void removingContact(Transaction txn, Contact c); @Override void addBlog(Blog b); @Override void addBlog(Transaction txn, Blog b); @Override boolean canBeRemoved(Blog b); @Override void removeBlog(Blog b); @Override void removeBlog(Transaction txn, Blog b); @Override void addLocalPost(BlogPost p); @Override void addLocalPost(Transaction txn, BlogPost p); @Override void addLocalComment(LocalAuthor author, GroupId groupId,
			@Nullable String comment, BlogPostHeader parentHeader); @Override Blog getBlog(GroupId g); @Override Blog getBlog(Transaction txn, GroupId g); @Override Collection<Blog> getBlogs(LocalAuthor localAuthor); @Override Blog getPersonalBlog(Author author); @Override Collection<Blog> getBlogs(); @Override BlogPostHeader getPostHeader(GroupId g, MessageId m); @Override String getPostBody(MessageId m); @Override Collection<BlogPostHeader> getPostHeaders(GroupId g); @Override void setReadFlag(MessageId m, boolean read); @Override void registerRemoveBlogHook(RemoveBlogHook hook);  }