public void testBlipAppendReplyFiresEvent() { ObservableConversation mirror = mirrorConversation(target); ObservableConversationBlip b1 = target.getRootThread().appendBlip(); ObservableConversationBlip b1mirror = mirror.getRootThread().getFirstBlip(); mirror.addListener(convListener); b1.addReplyThread(); ObservableConversationThread t1mirror = b1mirror.getReplyThreads().iterator().next(); verify(convListener).onThreadAdded(t1mirror); verifyNoMoreInteractions(convListener); }
public void testBlipAppendReplyFiresEvent() { ObservableConversation mirror = mirrorConversation(target); ObservableConversationBlip b1 = target.getRootThread().appendBlip(); ObservableConversationBlip b1mirror = mirror.getRootThread().getFirstBlip(); mirror.addListener(convListener); b1.addReplyThread(); ObservableConversationThread t1mirror = b1mirror.getReplyThreads().iterator().next(); verify(convListener).onThreadAdded(t1mirror); verifyNoMoreInteractions(convListener); }
public void testBlipRemovalFiresEvent() { ObservableConversation mirror = mirrorConversation(target); ObservableConversationBlip b1 = target.getRootThread().appendBlip(); ObservableConversationBlip b1mirror = mirror.getRootThread().getFirstBlip(); mirror.addListener(convListener); b1.delete(); verify(convListener).onBlipDeleted(b1mirror); allowBlipTimestampChanged(convListener); verifyNoMoreInteractions(convListener); }
public void testBlipRemovalFiresEvent() { ObservableConversation mirror = mirrorConversation(target); ObservableConversationBlip b1 = target.getRootThread().appendBlip(); ObservableConversationBlip b1mirror = mirror.getRootThread().getFirstBlip(); mirror.addListener(convListener); b1.delete(); verify(convListener).onBlipDeleted(b1mirror); allowBlipTimestampChanged(convListener); verifyNoMoreInteractions(convListener); }
public void testParticipantChangesFireEvents() { ParticipantId p1 = new ParticipantId("someone@example.com"); ParticipantId p2 = new ParticipantId("else@example.com"); ObservableConversation mirror = mirrorConversation(target); mirror.addListener(convListener); target.addParticipant(p1); target.addParticipant(p2); verify(convListener).onParticipantAdded(p1); verify(convListener).onParticipantAdded(p2); target.addParticipant(p1); verifyNoMoreInteractions(convListener); target.removeParticipant(p2); verify(convListener).onParticipantRemoved(p2); }
public void testParticipantChangesFireEvents() { ParticipantId p1 = new ParticipantId("someone@example.com"); ParticipantId p2 = new ParticipantId("else@example.com"); ObservableConversation mirror = mirrorConversation(target); mirror.addListener(convListener); target.addParticipant(p1); target.addParticipant(p2); verify(convListener).onParticipantAdded(p1); verify(convListener).onParticipantAdded(p2); target.addParticipant(p1); verifyNoMoreInteractions(convListener); target.removeParticipant(p2); verify(convListener).onParticipantRemoved(p2); }
public void testRootThreadRemovalDoesntFireEvent() { ObservableConversation mirror = mirrorConversation(target); target.getRootThread().appendBlip(); ObservableConversationBlip b1mirror = mirror.getRootThread().getFirstBlip(); mirror.addListener(convListener); // Trigger thread deletion. target.getRootThread().delete(); verify(convListener).onBlipDeleted(b1mirror); allowBlipTimestampChanged(convListener); verifyNoMoreInteractions(convListener); }
public void testRemovedListenersReceiveNoEvents() { ObservableConversation mirror = mirrorConversation(target); ObservableConversationBlip b1 = target.getRootThread().appendBlip(); ObservableConversationThread t1 = b1.addReplyThread(); ObservableConversationBlip b2 = t1.appendBlip(); ObservableConversationBlip b1mirror = mirror.getRootThread().getFirstBlip(); ObservableConversationThread t1mirror = b1mirror.getReplyThreads().iterator().next(); t1mirror.getFirstBlip(); mirror.addListener(convListener); mirror.removeListener(convListener); b1.delete(); verifyNoMoreInteractions(convListener); }
public void testThreadRemovalFiresEvent() { ObservableConversation mirror = mirrorConversation(target); ObservableConversationBlip b1 = target.getRootThread().appendBlip(); ObservableConversationThread t1 = b1.addReplyThread(); ObservableConversationThread t1mirror = mirror.getRootThread().getFirstBlip() .getReplyThreads().iterator().next(); t1.appendBlip(); ObservableConversationBlip b3mirror = t1mirror.getFirstBlip(); mirror.addListener(convListener); // Trigger thread deletion. t1.delete(); verify(convListener).onBlipDeleted(b3mirror); verify(convListener).onThreadDeleted(t1mirror); allowBlipTimestampChanged(convListener); verifyNoMoreInteractions(convListener); }
public void testRemovedListenersReceiveNoEvents() { ObservableConversation mirror = mirrorConversation(target); ObservableConversationBlip b1 = target.getRootThread().appendBlip(); ObservableConversationThread t1 = b1.addReplyThread(); ObservableConversationBlip b2 = t1.appendBlip(); ObservableConversationBlip b1mirror = mirror.getRootThread().getFirstBlip(); ObservableConversationThread t1mirror = b1mirror.getReplyThreads().iterator().next(); t1mirror.getFirstBlip(); mirror.addListener(convListener); mirror.removeListener(convListener); b1.delete(); verifyNoMoreInteractions(convListener); }
public void testRootThreadRemovalDoesntFireEvent() { ObservableConversation mirror = mirrorConversation(target); target.getRootThread().appendBlip(); ObservableConversationBlip b1mirror = mirror.getRootThread().getFirstBlip(); mirror.addListener(convListener); // Trigger thread deletion. target.getRootThread().delete(); verify(convListener).onBlipDeleted(b1mirror); allowBlipTimestampChanged(convListener); verifyNoMoreInteractions(convListener); }
public void testThreadAppendInsertBlipFiresEvent() { ObservableConversation mirror = mirrorConversation(target); mirror.addListener(convListener); ObservableConversationBlip b1 = target.getRootThread().appendBlip(); ObservableConversationBlip b1mirror = mirror.getRootThread().getFirstBlip(); verify(convListener).onBlipAdded(b1mirror); target.getRootThread().insertBlip(b1); ObservableConversationBlip b2mirror = mirror.getRootThread().getFirstBlip(); verify(convListener).onBlipAdded(b2mirror); allowBlipTimestampChanged(convListener); verifyNoMoreInteractions(convListener); }
public void testThreadRemovalFiresEvent() { ObservableConversation mirror = mirrorConversation(target); ObservableConversationBlip b1 = target.getRootThread().appendBlip(); ObservableConversationThread t1 = b1.addReplyThread(); ObservableConversationThread t1mirror = mirror.getRootThread().getFirstBlip() .getReplyThreads().iterator().next(); t1.appendBlip(); ObservableConversationBlip b3mirror = t1mirror.getFirstBlip(); mirror.addListener(convListener); // Trigger thread deletion. t1.delete(); verify(convListener).onBlipDeleted(b3mirror); verify(convListener).onThreadDeleted(t1mirror); allowBlipTimestampChanged(convListener); verifyNoMoreInteractions(convListener); }
public void testThreadAppendInsertBlipFiresEvent() { ObservableConversation mirror = mirrorConversation(target); mirror.addListener(convListener); ObservableConversationBlip b1 = target.getRootThread().appendBlip(); ObservableConversationBlip b1mirror = mirror.getRootThread().getFirstBlip(); verify(convListener).onBlipAdded(b1mirror); target.getRootThread().insertBlip(b1); ObservableConversationBlip b2mirror = mirror.getRootThread().getFirstBlip(); verify(convListener).onBlipAdded(b2mirror); allowBlipTimestampChanged(convListener); verifyNoMoreInteractions(convListener); }
public void testCompoundEventsFireBottomUp() { ObservableConversation mirror = mirrorConversation(target); // Build tall structure. // rootThread // |- b1 (deleted) // |- t1 // |- b2 ObservableConversationBlip b1 = target.getRootThread().appendBlip(); ObservableConversationThread t1 = b1.addReplyThread(); ObservableConversationBlip b2 = t1.appendBlip(); ObservableConversationBlip b1mirror = mirror.getRootThread().getFirstBlip(); ObservableConversationThread t1mirror = b1mirror.getReplyThreads().iterator().next(); ObservableConversationBlip b2mirror = t1mirror.getFirstBlip(); mirror.addListener(convListener); // Trigger cascading deletion. b1.delete(); // Timestamp changed events may have also occurred on the blip listeners. // Mockito doesn't support atMost on inOrder verifications, hence we cannot // verify those events then verifyNoMoreInteractions on the blip listeners. // TODO(anorth): verifyNoMoreInteractions when the CWM injects a clock. InOrder order = inOrder(convListener); order.verify(convListener).onBlipDeleted(b2mirror); order.verify(convListener).onThreadDeleted(t1mirror); order.verify(convListener).onBlipDeleted(b1mirror); allowBlipTimestampChanged(convListener); verifyNoMoreInteractions(convListener); }
public void testCompoundEventsFireBottomUp() { ObservableConversation mirror = mirrorConversation(target); // Build tall structure. // rootThread // |- b1 (deleted) // |- t1 // |- b2 ObservableConversationBlip b1 = target.getRootThread().appendBlip(); ObservableConversationThread t1 = b1.addReplyThread(); ObservableConversationBlip b2 = t1.appendBlip(); ObservableConversationBlip b1mirror = mirror.getRootThread().getFirstBlip(); ObservableConversationThread t1mirror = b1mirror.getReplyThreads().iterator().next(); ObservableConversationBlip b2mirror = t1mirror.getFirstBlip(); mirror.addListener(convListener); // Trigger cascading deletion. b1.delete(); // Timestamp changed events may have also occurred on the blip listeners. // Mockito doesn't support atMost on inOrder verifications, hence we cannot // verify those events then verifyNoMoreInteractions on the blip listeners. // TODO(anorth): verifyNoMoreInteractions when the CWM injects a clock. InOrder order = inOrder(convListener); order.verify(convListener).onBlipDeleted(b2mirror); order.verify(convListener).onThreadDeleted(t1mirror); order.verify(convListener).onBlipDeleted(b1mirror); allowBlipTimestampChanged(convListener); verifyNoMoreInteractions(convListener); }