/** * Finds the parent of a blip. * * @param blip the blip. * @return the blip's parent, or {@code null} if the blip is the first blip * in a conversation. */ @Override public ConversationBlip findBlipParent(ConversationBlip blip) { return blip.getThread().getParentBlip(); }
/** * Finds the parent of a blip. The parent is the preceding blip in the thread, * or the blip to which the thread is a reply for the first blip in a thread. * The first blip of the root thread has no parent. * * @param blip the blip. * @return the blip's parent, or {@code null} if the blip is the first blip * in a conversation. */ @Override public ConversationBlip findBlipParent(ConversationBlip blip) { ConversationThread containingThread = blip.getThread(); if (containingThread.getFirstBlip() == blip && containingThread != blip.getConversation().getRootThread()) { return containingThread.getParentBlip(); } return findPreviousSibling(blip); }
/** * Asserts that the state-querying methods on a thread can be called. */ protected static void assertThreadAccessible(ConversationThread thread) { thread.getBlips(); thread.getConversation(); thread.getFirstBlip(); thread.getId(); thread.getParentBlip(); } }
/** * Asserts that the state-querying methods on a thread can be called. */ protected static void assertThreadAccessible(ConversationThread thread) { thread.getBlips(); thread.getConversation(); thread.getFirstBlip(); thread.getId(); thread.getParentBlip(); } }
ConversationBlip parent = thread.getParentBlip();
public void testAppendInlineReplyCreatesInlineThread() { ConversationBlip blip = target.getRootThread().appendBlip(); MutableDocument<?, ?, ?> doc = blip.getContent(); int location = locateAfterLineElement(doc); ConversationThread thread = blip.addReplyThread(location); assertSame(blip, thread.getParentBlip()); assertEquals(Collections.singletonList(LocatedReplyThread.of(thread, location)), blip.locateReplyThreads()); assertThreadChildrenConsistent(blip); }
public void testAppendInlineReplyCreatesInlineThread() { ConversationBlip blip = target.getRootThread().appendBlip(); MutableDocument<?, ?, ?> doc = blip.getContent(); int location = locateAfterLineElement(doc); ConversationThread thread = blip.addReplyThread(location); assertSame(blip, thread.getParentBlip()); assertEquals(Collections.singletonList(LocatedReplyThread.of(thread, location)), blip.locateReplyThreads()); assertThreadChildrenConsistent(blip); }
/** * Tests that methods which access the state of a thread without changing it * are correct after thread deletion. */ public void testThreadCanBeAccessedAfterDeletion() { ConversationBlip blip = target.getRootThread().appendBlip(); ConversationThread thread = blip.addReplyThread(); ConversationBlip replyBlip = thread.appendBlip(); thread.delete(); assertBlipInvalid(replyBlip); assertBlipAccessible(replyBlip); assertThreadInvalid(thread); assertThreadAccessible(thread); assertEquals(blip, thread.getParentBlip()); assertFalse(blip.getReplyThreads().iterator().hasNext()); assertEquals(thread, replyBlip.getThread()); assertEquals(Collections.emptyList(), getBlipList(thread)); }
/** * Tests that methods which access the state of a thread without changing it * are correct after thread deletion. */ public void testThreadCanBeAccessedAfterDeletion() { ConversationBlip blip = target.getRootThread().appendBlip(); ConversationThread thread = blip.addReplyThread(); ConversationBlip replyBlip = thread.appendBlip(); thread.delete(); assertBlipInvalid(replyBlip); assertBlipAccessible(replyBlip); assertThreadInvalid(thread); assertThreadAccessible(thread); assertEquals(blip, thread.getParentBlip()); assertFalse(blip.getReplyThreads().iterator().hasNext()); assertEquals(thread, replyBlip.getThread()); assertEquals(Collections.emptyList(), getBlipList(thread)); }
/** * Tests that methods which access the state of a blip (this time with a * child thread) without changing it are correct after blip deletion. */ public void testBlipWithThreadCanBeAccessedAfterDeletion() { ConversationBlip blip = target.getRootThread().appendBlip(); ConversationThread thread = blip.addReplyThread(); blip.delete(); assertBlipInvalid(blip); assertBlipAccessible(blip); assertEquals(target.getRootThread(), blip.getThread()); assertEquals(Collections.emptyList(), getBlipList(target.getRootThread())); assertEquals(blip, thread.getParentBlip()); assertEquals(Collections.emptyList(), getAllReplyList(blip)); }
/** * Tests that methods which access the state of a blip (this time with a * child thread) without changing it are correct after blip deletion. */ public void testBlipWithThreadCanBeAccessedAfterDeletion() { ConversationBlip blip = target.getRootThread().appendBlip(); ConversationThread thread = blip.addReplyThread(); blip.delete(); assertBlipInvalid(blip); assertBlipAccessible(blip); assertEquals(target.getRootThread(), blip.getThread()); assertEquals(Collections.emptyList(), getBlipList(target.getRootThread())); assertEquals(blip, thread.getParentBlip()); assertEquals(Collections.emptyList(), getAllReplyList(blip)); }
public void testAppendRepliesAppendsRepliesToBlip() { ConversationBlip blip = target.getRootThread().appendBlip(); ConversationThread t1 = blip.addReplyThread(); // Append blips to get a new ID for the next thread. t1.appendBlip(); ConversationThread t2 = blip.addReplyThread(); t2.appendBlip(); ConversationThread t3 = blip.addReplyThread(); t3.appendBlip(); assertSame(blip, t1.getParentBlip()); assertEquals(Arrays.asList(t1, t2, t3), CollectionUtils.newArrayList(blip.getReplyThreads())); assertThreadChildrenConsistent(blip); }
public void testAppendRepliesAppendsRepliesToBlip() { ConversationBlip blip = target.getRootThread().appendBlip(); ConversationThread t1 = blip.addReplyThread(); // Append blips to get a new ID for the next thread. t1.appendBlip(); ConversationThread t2 = blip.addReplyThread(); t2.appendBlip(); ConversationThread t3 = blip.addReplyThread(); t3.appendBlip(); assertSame(blip, t1.getParentBlip()); assertEquals(Arrays.asList(t1, t2, t3), CollectionUtils.newArrayList(blip.getReplyThreads())); assertThreadChildrenConsistent(blip); }