@Override public String render(ConversationThread thread, String threadR) { return "Anchor [ id: " + thread.getId() + (threadR != null ? "; thread: " + threadR : "") + " ]"; } }
@Override public String render(ConversationThread thread, String threadR) { return "Anchor [ id: " + thread.getId() + (threadR != null ? "; thread: " + threadR : "") + " ]"; } }
@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(); }
@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(); }
@Override public ThreadState getThreadState(ConversationThread thread) { Conversation c = thread.getConversation(); String id = c.getId(); return supplement.getThreadState(WaveletBasedConversation.widFor(id), thread.getId()); }
@Override public void setThreadState(ConversationThread thread, ThreadState state) { supplement.setThreadState(WaveletBasedConversation.widFor( thread.getConversation().getId()), thread.getId(), state); }
String threadId = thread.getId(); if (eventMessageBundle.hasThreadId(threadId)) { for (LocatedReplyThread<? extends ConversationThread> inlineReplyThread : parent.locateReplyThreads()) { if (thread.getId().equals(inlineReplyThread.getThread().getId())) { location = inlineReplyThread.getLocation(); break; blipIds.add(blip.getId()); eventMessageBundle.addThread(threadId, new BlipThread(thread.getId(), location, blipIds, null));
@Override public BlipData toBlipData(ConversationBlip blip, Wavelet wavelet, EventMessageBundle eventMessageBundle) { BlipData blipData = super.toBlipData(blip, wavelet, eventMessageBundle); String threadId = blip.getThread().getId(); blipData.setThreadId(threadId); // If it's the root thread, that doesn't have thread id, then skip. if (!threadId.isEmpty()) { ConversationThread thread = blip.getThread(); addThread(eventMessageBundle, thread, -1, wavelet); } // Add the inline reply threads. List<String> threadIds = Lists.newLinkedList(); for (LocatedReplyThread<? extends ConversationThread> thread : blip.locateReplyThreads()) { String replyThreadId = thread.getThread().getId(); threadIds.add(replyThreadId); addThread(eventMessageBundle, thread.getThread(), thread.getLocation(), wavelet); } blipData.setReplyThreadIds(threadIds); return blipData; }
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()); }
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()); }
/** * 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(); } }
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()); }
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()); }
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 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>"); }