public void testRemoveRestoreThreadAfterObsoleteThreadDoesntDie() { WaveletBasedConversationBlip first = target.getRootThread().appendBlip(); WaveletBasedConversationThread reply11 = first.addReplyThread(); ConversationBlip blip1 = reply11.appendBlip(); String blip1Id = blip1.getId(); WaveletBasedConversationThread reply2 = first.addReplyThread(); // Make first thread empty by removing its blip. ManifestBlip manifestRootBlip = target.getManifest().getRootThread().getBlip(0); ManifestThread manifestReply1 = manifestRootBlip.getReply(0); manifestReply1.removeBlip(manifestReply1.getBlip(0)); assertThreadValid(reply11); // Remove and re-add second thread, as can happen in playback. String thread2Id = reply2.getId(); ManifestThread manifestReply2 = manifestRootBlip.getReply(1); manifestRootBlip.removeReply(manifestReply2); manifestRootBlip.appendReply(thread2Id, false); assertThreadInvalid(reply2); }
public void testConcrrentDeletionOfFinalBlipsLeavesEmptyThread() { WaveletBasedConversationBlip first = target.getRootThread().appendBlip(); WaveletBasedConversationThread replyThread = first.addReplyThread(); WaveletBasedConversationBlip b1 = replyThread.appendBlip(); WaveletBasedConversationBlip b2 = replyThread.appendBlip(); // Locally delete b1, remotely delete b2. b1.delete(); replyThread.addListener(threadListener); b2.addListener(blipListener); target.addListener(convListener); remoteRemoveBlip(b2); // Expect blip deletion events and it to be invalid. verify(blipListener).onDeleted(); verify(convListener).onBlipDeleted(b2); assertBlipInvalid(b2); assertThreadValid(replyThread); assertEquals(Arrays.asList(replyThread), CollectionUtils.newArrayList(first.getReplyThreads())); // The manifest now has a thread with no blips. assertEquals(1, first.getManifestBlip().numReplies()); assertEquals(0, first.getManifestBlip().getReply(0).numBlips()); // Still there after the next mutation. ObservableConversationBlip second = target.getRootThread().appendBlip(); assertThreadValid(replyThread); assertEquals(Arrays.asList(replyThread), CollectionUtils.newArrayList(first.getReplyThreads())); verify(convListener).onBlipAdded(second); verifyNoMoreInteractions(blipListener, threadListener, convListener); }
/** * Removes a thread from the manifest, as though a remote client had done so. */ private void remoteRemoveThread(WaveletBasedConversationThread thread) { ManifestBlip parentBlip = thread.getParentBlip().getManifestBlip(); ManifestThread manifestThread = thread.getManifestThread(); parentBlip.removeReply(manifestThread); }
/** * Very basic test to see that we can create the object with a document and use it. */ public void testSimpleUsageWithDocument() { ObservableManifestThread thread = buildThreadElement( ConversationTestUtils.createManifestDocument(), "t1"); ManifestBlip blip = thread.appendBlip("b+1"); assertNotNull(blip); assertEquals("b+1", blip.getId()); assertFalse(thread.isInline()); }
public void testObsoleteThreadThenRestoreRemoveBlipDoesntDie() { WaveletBasedConversationBlip first = target.getRootThread().appendBlip(); WaveletBasedConversationThread willBecomeEmpty = first.addReplyThread(); ConversationBlip toggleBlip = willBecomeEmpty.appendBlip(); String toggleBlipId = toggleBlip.getId(); // Make the thread empty by remotely removing its blip. ManifestBlip manifestRootBlip = target.getManifest().getRootThread().getBlip(0); ManifestThread manifestReply = manifestRootBlip.getReply(0); manifestReply.removeBlip(manifestReply.getBlip(0)); assertThreadValid(willBecomeEmpty); // Re-add then remove the blip, as can happen in playback. manifestReply.appendBlip(toggleBlipId); manifestReply.removeBlip(manifestReply.getBlip(0)); }
public void testConcurrentDeletionOfFinalThreadsLeavesEmptyBlip() { WaveletBasedConversationBlip first = target.getRootThread().appendBlip(); WaveletBasedConversationThread t1 = first.addReplyThread(); WaveletBasedConversationBlip t1b = t1.appendBlip(); WaveletBasedConversationThread t2 = first.addReplyThread(); WaveletBasedConversationBlip t2b = t2.appendBlip(); // Locally delete t1, remotely delete t2. t1b.delete(); first.addListener(blipListener); t2.addListener(threadListener); target.addListener(convListener); remoteRemoveBlip(t2b); remoteRemoveThread(t2); // Expect thread t2 deletion events and it to be invalid. verify(threadListener).onDeleted(); verify(convListener).onBlipDeleted(t2b); verify(convListener).onThreadDeleted(t2); assertBlipInvalid(t2b); assertThreadInvalid(t2); assertBlipValid(first); assertNotNull(target.getRootThread().getFirstBlip()); // The manifest now has an empty blip. assertEquals(0, first.getManifestBlip().numReplies()); // Still there after next write. WaveletBasedConversationBlip second = target.getRootThread().appendBlip(); assertBlipValid(first); verify(convListener).onBlipAdded(second); verifyNoMoreInteractions(blipListener, threadListener, convListener); }
public void testConcrrentDeletionOfFinalBlipsLeavesEmptyThread() { WaveletBasedConversationBlip first = target.getRootThread().appendBlip(); WaveletBasedConversationThread replyThread = first.addReplyThread(); WaveletBasedConversationBlip b1 = replyThread.appendBlip(); WaveletBasedConversationBlip b2 = replyThread.appendBlip(); // Locally delete b1, remotely delete b2. b1.delete(); replyThread.addListener(threadListener); b2.addListener(blipListener); target.addListener(convListener); remoteRemoveBlip(b2); // Expect blip deletion events and it to be invalid. verify(blipListener).onDeleted(); verify(convListener).onBlipDeleted(b2); assertBlipInvalid(b2); assertThreadValid(replyThread); assertEquals(Arrays.asList(replyThread), CollectionUtils.newArrayList(first.getReplyThreads())); // The manifest now has a thread with no blips. assertEquals(1, first.getManifestBlip().numReplies()); assertEquals(0, first.getManifestBlip().getReply(0).numBlips()); // Still there after the next mutation. ObservableConversationBlip second = target.getRootThread().appendBlip(); assertThreadValid(replyThread); assertEquals(Arrays.asList(replyThread), CollectionUtils.newArrayList(first.getReplyThreads())); verify(convListener).onBlipAdded(second); verifyNoMoreInteractions(blipListener, threadListener, convListener); }
/** * Removes a thread from the manifest, as though a remote client had done so. */ private void remoteRemoveThread(WaveletBasedConversationThread thread) { ManifestBlip parentBlip = thread.getParentBlip().getManifestBlip(); ManifestThread manifestThread = thread.getManifestThread(); parentBlip.removeReply(manifestThread); }
/** * Very basic test to see that we can create the object with a document and use it. */ public void testSimpleUsageWithDocument() { ObservableManifestThread thread = buildThreadElement( ConversationTestUtils.createManifestDocument(), "t1"); ManifestBlip blip = thread.appendBlip("b+1"); assertNotNull(blip); assertEquals("b+1", blip.getId()); assertFalse(thread.isInline()); }
public void testObsoleteThreadThenRestoreRemoveBlipDoesntDie() { WaveletBasedConversationBlip first = target.getRootThread().appendBlip(); WaveletBasedConversationThread willBecomeEmpty = first.addReplyThread(); ConversationBlip toggleBlip = willBecomeEmpty.appendBlip(); String toggleBlipId = toggleBlip.getId(); // Make the thread empty by remotely removing its blip. ManifestBlip manifestRootBlip = target.getManifest().getRootThread().getBlip(0); ManifestThread manifestReply = manifestRootBlip.getReply(0); manifestReply.removeBlip(manifestReply.getBlip(0)); assertThreadValid(willBecomeEmpty); // Re-add then remove the blip, as can happen in playback. manifestReply.appendBlip(toggleBlipId); manifestReply.removeBlip(manifestReply.getBlip(0)); }
public void testConcurrentDeletionOfFinalThreadsLeavesEmptyBlip() { WaveletBasedConversationBlip first = target.getRootThread().appendBlip(); WaveletBasedConversationThread t1 = first.addReplyThread(); WaveletBasedConversationBlip t1b = t1.appendBlip(); WaveletBasedConversationThread t2 = first.addReplyThread(); WaveletBasedConversationBlip t2b = t2.appendBlip(); // Locally delete t1, remotely delete t2. t1b.delete(); first.addListener(blipListener); t2.addListener(threadListener); target.addListener(convListener); remoteRemoveBlip(t2b); remoteRemoveThread(t2); // Expect thread t2 deletion events and it to be invalid. verify(threadListener).onDeleted(); verify(convListener).onBlipDeleted(t2b); verify(convListener).onThreadDeleted(t2); assertBlipInvalid(t2b); assertThreadInvalid(t2); assertBlipValid(first); assertNotNull(target.getRootThread().getFirstBlip()); // The manifest now has an empty blip. assertEquals(0, first.getManifestBlip().numReplies()); // Still there after next write. WaveletBasedConversationBlip second = target.getRootThread().appendBlip(); assertBlipValid(first); verify(convListener).onBlipAdded(second); verifyNoMoreInteractions(blipListener, threadListener, convListener); }
public void testRemoveRestoreThreadAfterObsoleteThreadDoesntDie() { WaveletBasedConversationBlip first = target.getRootThread().appendBlip(); WaveletBasedConversationThread reply11 = first.addReplyThread(); ConversationBlip blip1 = reply11.appendBlip(); String blip1Id = blip1.getId(); WaveletBasedConversationThread reply2 = first.addReplyThread(); // Make first thread empty by removing its blip. ManifestBlip manifestRootBlip = target.getManifest().getRootThread().getBlip(0); ManifestThread manifestReply1 = manifestRootBlip.getReply(0); manifestReply1.removeBlip(manifestReply1.getBlip(0)); assertThreadValid(reply11); // Remove and re-add second thread, as can happen in playback. String thread2Id = reply2.getId(); ManifestThread manifestReply2 = manifestRootBlip.getReply(1); manifestRootBlip.removeReply(manifestReply2); manifestRootBlip.appendReply(thread2Id, false); assertThreadInvalid(reply2); }