@Override public boolean isRoot() { return parentThread == getConversation().getRootThread() && this == parentThread.getFirstBlip(); }
/** * Tests that empty threads are not ignored. */ public void testCreateWithEmptyManifestThreadNotIgnored() { ConversationBlip blip = target.getRootThread().appendBlip(); ConversationThread thread = blip.addReplyThread(); WaveletBasedConversation another = mirrorConversation(target); assertNotNull(another.getRootThread().getFirstBlip()); assertTrue(another.getRootThread().getFirstBlip().getReplyThreads().iterator().hasNext()); }
/** * Tests that empty threads are not ignored. */ public void testCreateWithEmptyManifestThreadNotIgnored() { ConversationBlip blip = target.getRootThread().appendBlip(); ConversationThread thread = blip.addReplyThread(); WaveletBasedConversation another = mirrorConversation(target); assertNotNull(another.getRootThread().getFirstBlip()); assertTrue(another.getRootThread().getFirstBlip().getReplyThreads().iterator().hasNext()); }
/** * Test that we can cope with blips being added to the manifest but not to the * wavelet. */ public void testAddingBlipMissingFromWavelet() { manifestDoc.with(new Action() { @Override public <N, E extends N, T extends N> void exec(MutableDocument<N, E, T> doc) { N rootThreadNode = doc.getFirstChild(doc.getDocumentElement()); E rootThread = doc.asElement(rootThreadNode); doc.createChildElement(rootThread, "blip", Collections.singletonMap( "id", idGenerator.newBlipId())); } }); assertNull(target.getRootThread().getFirstBlip()); assertEquals(Collections.emptyList(), getBlipList(target.getRootThread())); }
/** * Test that we can cope with blips being added to the manifest but not to the * wavelet. */ public void testAddingBlipMissingFromWavelet() { manifestDoc.with(new Action() { @Override public <N, E extends N, T extends N> void exec(MutableDocument<N, E, T> doc) { N rootThreadNode = doc.getFirstChild(doc.getDocumentElement()); E rootThread = doc.asElement(rootThreadNode); doc.createChildElement(rootThread, "blip", Collections.singletonMap( "id", idGenerator.newBlipId())); } }); assertNull(target.getRootThread().getFirstBlip()); assertEquals(Collections.emptyList(), getBlipList(target.getRootThread())); }
public void testAbstractBlipIdMatchesConcreteBlipId() { populate(target); WaveletBasedConversationBlip convBlip = target.getRootThread().getFirstBlip(); assertEquals(convBlip.getId(), convBlip.getBlip().getId()); }
public void testAbstractBlipIdMatchesConcreteBlipId() { populate(target); WaveletBasedConversationBlip convBlip = target.getRootThread().getFirstBlip(); assertEquals(convBlip.getId(), convBlip.getBlip().getId()); }
/** * Test that a conversation can be created on a manifest that contains blips * that are not backed by the wavelet. */ public void testBlipMissingFromWavelet() { WaveletBasedConversation empty = target; WaveletBasedConversation nonEmpty = makeConversation(); nonEmpty.getRootThread().appendBlip(); WaveletBasedConversation conversation = WaveletBasedConversation.create(conversationView, empty.getWavelet(), nonEmpty.getManifest(), idGenerator); assertNull(conversation.getRootThread().getFirstBlip()); assertEquals(Collections.emptyList(), getBlipList(conversation.getRootThread())); }
/** * Test that a conversation can be created on a manifest that contains blips * that are not backed by the wavelet. */ public void testBlipMissingFromWavelet() { WaveletBasedConversation empty = target; WaveletBasedConversation nonEmpty = makeConversation(); nonEmpty.getRootThread().appendBlip(); WaveletBasedConversation conversation = WaveletBasedConversation.create(conversationView, empty.getWavelet(), nonEmpty.getManifest(), idGenerator); assertNull(conversation.getRootThread().getFirstBlip()); assertEquals(Collections.emptyList(), getBlipList(conversation.getRootThread())); }
/** * Tests that the wavelet-based conversation reads meta-data from the * underlying wavelet structures. This test will go away when meta-data is * stored in the conversation documents. */ public void testConversationBlipMetadataMatchesWavelet() { populate(target); ConversationBlip convBlip = target.getRootThread().getFirstBlip(); Wavelet wavelet = target.getWavelet(); Blip blip = wavelet.getBlip(convBlip.getId()); assertEquals(blip.getId(), convBlip.getId()); assertEquals(blip.getLastModifiedVersion().longValue(), convBlip.getLastModifiedVersion()); assertEquals(blip.getLastModifiedTime().longValue(), convBlip.getLastModifiedTime()); assertEquals(blip.getAuthorId(), convBlip.getAuthorId()); assertEquals(blip.getContributorIds(), convBlip.getContributorIds()); }
/** * Tests that the wavelet-based conversation reads meta-data from the * underlying wavelet structures. This test will go away when meta-data is * stored in the conversation documents. */ public void testConversationBlipMetadataMatchesWavelet() { populate(target); ConversationBlip convBlip = target.getRootThread().getFirstBlip(); Wavelet wavelet = target.getWavelet(); Blip blip = wavelet.getBlip(convBlip.getId()); assertEquals(blip.getId(), convBlip.getId()); assertEquals(blip.getLastModifiedVersion().longValue(), convBlip.getLastModifiedVersion()); assertEquals(blip.getLastModifiedTime().longValue(), convBlip.getLastModifiedTime()); assertEquals(blip.getAuthorId(), convBlip.getAuthorId()); assertEquals(blip.getContributorIds(), convBlip.getContributorIds()); }
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 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); }
WaveletBasedConversationBlip rootWaveletRootBlip = rootConv.getRootThread().appendBlip(); target.setAnchor(rootConv.createAnchor(rootConv.getRootThread().getFirstBlip())); WaveletBasedConversationBlip firstBlip = target.getRootThread().appendBlip(); WaveletBasedConversationBlip secondBlip = target.getRootThread().appendBlip();
WaveletBasedConversationBlip rootWaveletRootBlip = rootConv.getRootThread().appendBlip(); target.setAnchor(rootConv.createAnchor(rootConv.getRootThread().getFirstBlip())); WaveletBasedConversationBlip firstBlip = target.getRootThread().appendBlip(); WaveletBasedConversationBlip secondBlip = target.getRootThread().appendBlip();