// ... and that it is in the correct position
assertEquals(expectedThreadID, threadRef.getThreadID());
// Verify that the thread Message object exists if it should.
Message thread;
try {
thread = threadRef.getMessage();
assertTrue(mFetchedStates.get(expectedThreadID));
} catch(MessageNotFetchedException e) {
thread = null;
assertFalse(mFetchedStates.get(expectedThreadID));
}
// Verify the replies of the thread
LinkedList<String> expectedRepliesList = mReplies.get(threadRef.getThreadID());
if(expectedRepliesList == null)
expectedRepliesList = new LinkedList<String>();
final Iterator<String> expectedReplies = expectedRepliesList.iterator();
for(final BoardMessageLink replyRef : mSubscribedBoard.getAllThreadReplies(threadRef.getThreadID(), true)) {
assertTrue(expectedReplies.hasNext());
try {
final String expectedReplyID = expectedReplies.next();
assertEquals(expectedReplyID, replyRef.getMessageID());
assertEquals(threadRef.getThreadID(), replyRef.getThreadID());
// Verify that the Message object exists if it should
Message reply;
try {
reply = replyRef.getMessage();
assertTrue(mFetchedStates.get(expectedReplyID));
} catch(MessageNotFetchedException e) {
reply = null;
try {
Message ignoredRealReply = mMessageManager.get(expectedReplyID);
// The reply was NOT set on this reply link because it does not belong to this thread...
try {
assertFalse(ignoredRealReply.getThreadID().equals(threadRef.getThreadID()));
} catch(NoSuchMessageException e2) { // is a thread itself
// BoardReplyLinks should NOT be created if the parent is the thread itself
assertFalse(ignoredRealReply.getID().equals(threadRef.getThreadID()));
}
} catch(NoSuchMessageException e3) {
assertFalse(mFetchedStates.get(expectedReplyID));
}
}
Message replyParent;
if(reply != null) {
assertFalse(reply.isThread());
assertEquals(expectedReplyID, reply.getID());
assertEquals(expectedThreadID, reply.getThreadID());
try {
assertEquals(thread, reply.getThread());
} catch(NoSuchMessageException e) {
assertNull(thread);
}
final String replyParentID = reply.getParentID();
try {
replyParent = reply.getParent();
assertTrue(mFetchedStates.get(replyParentID));
} catch(NoSuchMessageException e) {
replyParent = null;
assertFalse(mFetchedStates.get(replyParentID));
}
} else {
replyParent = null;
}
// We do not specify the parent message for some test messages, check whether its assigned correctly
if(replyParent != null) {
assertEquals(reply.getParentID(), replyParent.getID());
if(reply.getParentID().equals(expectedThreadID)) {
assertEquals(thread, replyParent);
}
}
} catch(MessageNotFetchedException e) {