/** * Tests that setting a null anchor updates the manifest and makes the wavelet * un-anchored. */ public void testClearAnchorClearsManifest() { WaveletBasedConversation conversation2 = makeConversation(); populate(conversation2); Anchor anchor = conversation2.createAnchor(getFirstBlip(conversation2)); target.setAnchor(anchor); target.setAnchor(null); assertNull(getManifestAttribute(manifestDoc, "anchorWavelet")); assertNull(getManifestAttribute(manifestDoc, "anchorBlip")); }
/** * Tests that setting a null anchor updates the manifest and makes the wavelet * un-anchored. */ public void testClearAnchorClearsManifest() { WaveletBasedConversation conversation2 = makeConversation(); populate(conversation2); Anchor anchor = conversation2.createAnchor(getFirstBlip(conversation2)); target.setAnchor(anchor); target.setAnchor(null); assertNull(getManifestAttribute(manifestDoc, "anchorWavelet")); assertNull(getManifestAttribute(manifestDoc, "anchorBlip")); }
/** * 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())); }
/** * 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())); }
public void testGetBlipRetrievesBlip() { WaveletBasedConversationBlip blip = target.getRootThread().appendBlip(); WaveletBasedConversationThread reply = blip.addReplyThread(); WaveletBasedConversationBlip replyBlip = reply.appendBlip(); assertSame(blip, target.getBlip(blip.getId())); assertSame(replyBlip, target.getBlip(replyBlip.getId())); assertNull(target.getBlip("foobar")); }
public void testGetBlipRetrievesBlip() { WaveletBasedConversationBlip blip = target.getRootThread().appendBlip(); WaveletBasedConversationThread reply = blip.addReplyThread(); WaveletBasedConversationBlip replyBlip = reply.appendBlip(); assertSame(blip, target.getBlip(blip.getId())); assertSame(replyBlip, target.getBlip(replyBlip.getId())); assertNull(target.getBlip("foobar")); }
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>"); }