### Question:
DocumentChangeHandler { public void handleEvent(DocumentInfo info) { if (!settings.isSpywareEnabled()) { return; } Project project = projectDAO.getProjectByFile(info.getFullPath()); if (project == null) { return; } DocumentSendThread thread = new DocumentSendThread(receiver, info, project, documentCache, PATCH_GENERATOR); activeThreads.addThread(thread); thread.setDaemon(true); thread.start(); } DocumentChangeHandler(EventReceiver receiver, ActiveThreadSet set, Settings settings, ProjectDAO projectDAO); void handleEvent(DocumentInfo info);  }### Answer:
@Test public void handleEventIfSywareIsDisabled() { when(settings.isSpywareEnabled()).thenReturn(false); this.handler.handleEvent(new DocumentInfo("", "", "", "", 0, 1)); verify(projectDAO, times(0)).getProjectByFile(any(String.class)); }
@Test public void handleEventIfProjectIsNull() { when(projectDAO.getProjectByFile(any(String.class))).thenReturn(null); this.handler.handleEvent(new DocumentInfo("", "", "", "", 0, 1)); verify(set, times(0)).addThread(any(Thread.class)); }
@Test public void handleEventTest() { when(projectDAO.getProjectByFile(any(String.class))).thenReturn(new Project(new Exercise("name1", "course1"))); this.handler.handleEvent(new DocumentInfo("", "", "", "", 0, 1)); verify(set, times(1)).addThread(any(Thread.class)); }