private static void sampleReply(ConversationBlip blip) { ConversationThread thread = blip.addReplyThread(); thread.appendBlip(); thread.appendBlip(); }
/** * 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(); } }
public void testInsertBlipBetweenBlipsInserts() { ConversationThread thread = target.getRootThread(); ConversationBlip first = thread.appendBlip(); ConversationBlip last = thread.appendBlip(); ConversationBlip middle = thread.insertBlip(last); assertEquals(Arrays.asList(first, middle, last), getBlipList(thread)); }
@Override public ThreadState getThreadState(ConversationThread thread) { Conversation c = thread.getConversation(); String id = c.getId(); return supplement.getThreadState(WaveletBasedConversation.widFor(id), thread.getId()); }
@Override public String render(ConversationThread thread, IdentityMap<ConversationBlip, String> blips) { StringBuilder r = new StringBuilder("Thread ["); r.append(" id: " + thread.getId()); r.append("; blips: ["); for (ConversationBlip blip : thread.getBlips()) { r.append(" "); r.append(blips.get(blip)); } r.append(" ]"); return r.toString(); }
public void testAppendBlipAppendsBlipsToThread() { ConversationThread thread = target.getRootThread(); ConversationBlip b1 = thread.appendBlip(); ConversationBlip b2 = thread.appendBlip(); ConversationBlip b3 = thread.appendBlip(); assertSame(b1, thread.getFirstBlip()); assertSame(target, b1.getConversation()); assertSame(thread, b1.getThread()); assertSame(b1, target.getBlip(b1.getId())); assertEquals(Arrays.asList(b1, b2, b3), getBlipList(thread)); }
private static void assertThreadsEquivalent(ConversationThread expected, ConversationThread actual) { assertEquals("Mismatched id in constructed conversation thread", expected.getId(), actual.getId()); assertEquals("Mismatched first blip in constructed conversation thread", expected.getFirstBlip() == null, actual.getFirstBlip() == null); Iterator<? extends ConversationBlip> expectedBlips = expected.getBlips().iterator(); Iterator<? extends ConversationBlip> actualBlips = actual.getBlips().iterator(); while (expectedBlips.hasNext()) { assertTrue("Missing blip in reconstructed conversation", actualBlips.hasNext()); ConversationBlip expectedBlip = expectedBlips.next(); ConversationBlip actualBlip = actualBlips.next(); assertBlipsEquivalent(expectedBlip, actualBlip); } assertFalse("Extra blip in reconstructed conversation", actualBlips.hasNext()); }
String threadId = thread.getId(); if (eventMessageBundle.hasThreadId(threadId)) { ConversationBlip parent = thread.getParentBlip(); for (LocatedReplyThread<? extends ConversationThread> inlineReplyThread : parent.locateReplyThreads()) { if (thread.getId().equals(inlineReplyThread.getThread().getId())) { location = inlineReplyThread.getLocation(); break; for (ConversationBlip blip : thread.getBlips()) { blipIds.add(blip.getId()); eventMessageBundle.addThread(threadId, new BlipThread(thread.getId(), location, blipIds, null));
public void testInsetBlipBeforeFirstBlipCreatesNewFirstBlip() { ConversationThread thread = target.getRootThread(); ConversationBlip oldFirst = thread.appendBlip(); ConversationBlip newFirst = thread.insertBlip(oldFirst); assertSame(thread.getFirstBlip(), newFirst); assertSame(newFirst, target.getBlip(newFirst.getId())); assertSame(oldFirst, target.getBlip(oldFirst.getId())); assertEquals(Arrays.asList(newFirst, oldFirst), 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)); }
ConversationBlip rootBlip = conversation.getRootThread().getFirstBlip(); if (rootBlip != requiredBlip) { ContextResolver.addBlipToEventMessages( for (ConversationBlip blip : containingThread.getBlips()) { if (blip != requiredBlip) { ContextResolver.addBlipToEventMessages(
public void testDeleteRootThreadRemovesAllBlips() { ConversationThread rootThread = target.getRootThread(); ConversationBlip first = rootThread.appendBlip(); ConversationBlip second = rootThread.appendBlip(); rootThread.delete(); assertBlipInvalid(first); assertBlipInvalid(second); assertEquals(CollectionUtils.newArrayList(), getBlipList(rootThread)); assertThreadValid(rootThread); }
BlipIterator(ConversationThread thread, Predicate<ConversationBlip> acceptor) { this.acceptsBlip = acceptor; this.currentThreadItr = thread.getBlips().iterator(); this.nextBlip = findNextBlip(); }
/** * Finds the children of a blip, defined as the next sibling blip and the * first blip in each reply thread. * * @param blip the blip. * @return the children of the given blip. */ @Override public List<ConversationBlip> findBlipChildren(ConversationBlip blip) { List<ConversationBlip> siblings = Lists.newArrayList(); ConversationBlip nextSibling = findNextSibling(blip); if (nextSibling != null) { siblings.add(nextSibling); } for (ConversationThread reply : blip.getReplyThreads()) { if (reply.getFirstBlip() != null) { siblings.add(reply.getFirstBlip()); } } return siblings; }
public void testDeleteLastBlipInThreadRemovesThread() { ConversationBlip rootBlip = target.getRootThread().appendBlip(); ConversationThread topThread = rootBlip.addReplyThread(); ConversationBlip topBlip = topThread.appendBlip(); ConversationThread firstReply = topBlip.addReplyThread(); firstReply.appendBlip().delete(); assertNull(topBlip.getReplyThread(firstReply.getId())); assertManifestXml("<blip id=\"" + rootBlip.getId() + "\">" + "<thread id=\"" + topThread.getId() + "\">" + "<blip id=\"" + topBlip.getId() + "\"></blip>" + "</thread>" + "</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 testToBlipData() throws Exception { Wavelet wavelet = mock(Wavelet.class); when(wavelet.getWaveId()).thenReturn(WAVE_ID); when(wavelet.getId()).thenReturn(WAVELET_ID); ConversationBlip blip = conversation.getRootThread().getFirstBlip(); String replyThreadId = blip.addReplyThread(3).getId(); EventDataConverterV22 converter = new EventDataConverterV22(); EventMessageBundle eventMessageBundle = new EventMessageBundle(null, null); BlipData blipData = converter.toBlipData(blip, wavelet, eventMessageBundle); assertEquals(blip.getThread().getId(), blipData.getThreadId()); assertEquals(Lists.newArrayList(replyThreadId), blipData.getReplyThreadIds()); Map<String, BlipThread> threads = eventMessageBundle.getThreads(); assertEquals(1, threads.size()); assertEquals(1, threads.get(replyThreadId).getLocation()); }
/** * 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); }
public void testLiveRenderingCommutesOnBlipInsert() { ConversationThread root = wave.getRoot().getRootThread(); root.insertBlip(Iterables.get(root.getBlips(), 1)); assertEquals(render().toString(), rendering.toString()); }
/** * 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(); }