### Question:
DocumentSendThread extends Thread { @Override public void run() { createAndSendPatch(); } DocumentSendThread(EventReceiver receiver, DocumentInfo info, Project project, Map<String, String> cache,
            diff_match_patch PATCH_GENERATOR); @Override void run();  }### Answer:
@Test public void insertEventTest() { Mockito.doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { LoggableEvent event = (LoggableEvent) invocation.getArguments()[0]; assertEquals("text_insert", event.getEventType()); return null; } }).when(receiver).receiveEvent(any(LoggableEvent.class)); thread.run(); verify(receiver, times(1)).receiveEvent(any(LoggableEvent.class)); }
@Test public void removeEventTest() { this.info = new DocumentInfo("", "", "", "", 0, 1); this.thread = new DocumentSendThread(receiver, info, project, cache, PATCH_GENERATOR); Mockito.doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { LoggableEvent event = (LoggableEvent) invocation.getArguments()[0]; assertEquals("text_remove", event.getEventType()); return null; } }).when(receiver).receiveEvent(any(LoggableEvent.class)); thread.run(); verify(receiver, times(1)).receiveEvent(any(LoggableEvent.class)); }
@Test public void pasteEventTest() { if ("true".equals(System.getenv("TRAVIS"))) { return; } StringSelection s = new StringSelection("a a"); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(s, s); this.info = new DocumentInfo("", "", "", "a a", 0, 3); this.thread = new DocumentSendThread(receiver, info, project, cache, PATCH_GENERATOR); Mockito.doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { LoggableEvent event = (LoggableEvent) invocation.getArguments()[0]; assertEquals("text_paste", event.getEventType()); return null; } }).when(receiver).receiveEvent(any(LoggableEvent.class)); thread.run(); verify(receiver, times(1)).receiveEvent(any(LoggableEvent.class)); }