### Question:
ProjectScanner { public void updateProject(Project project) { if (project.getStatus() == ProjectStatus.DELETED) { return; } List<String> files = new ArrayList<String>(); traverse(files, io.newFile(project.getRootPath())); project.setProjectFiles(files); if (project.existsOnDisk()) { project.setStatus(ProjectStatus.DOWNLOADED); } else { project.setStatus(ProjectStatus.NOT_DOWNLOADED); } } ProjectScanner(ProjectDAO projectDAO, IOFactory io); void updateProject(Project project); void updateProjects();  }### Answer:
@Test public void updateProjectHasNoInteractionsIfStatusIsDeleted() { Project project = mock(Project.class); when(project.getStatus()).thenReturn(ProjectStatus.DELETED); scanner.updateProject(project); verify(project, times(1)).getStatus(); verifyNoMoreInteractions(dao); verifyNoMoreInteractions(project); }
@Test public void correctFilesAreAddedToProject() { when(io.directoryExists()).thenReturn(true); when(io.getPath()).thenReturn("path_1"); List<FileIO> list = new ArrayList<FileIO>(); FileIO childIO = mock(FileIO.class); list.add(childIO); when(io.getChildren()).thenReturn(list); when(childIO.getPath()).thenReturn("path_2"); when(childIO.getChildren()).thenReturn(new ArrayList<FileIO>()); when(childIO.fileExists()).thenReturn(true); when(io.getChildren()).thenReturn(list); Project project = mock(Project.class); doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { List<String> paths = (List<String>) invocation.getArguments()[0]; assertEquals(2, paths.size()); assertTrue(paths.contains("path_1")); assertTrue(paths.contains("path_2")); return null; } }).when(project).setProjectFiles(anyListOf(String.class)); scanner.updateProject(project); verify(project, times(1)).setProjectFiles(anyListOf(String.class)); }
@Test public void projectStatusIsSetAsNotDownloadedIfItDoesNotExistOnDisk() { Project project = mock(Project.class); when(project.existsOnDisk()).thenReturn(false); scanner.updateProject(project); verify(project, times(1)).setStatus(ProjectStatus.NOT_DOWNLOADED); }
@Test public void projectStatusIsSetAsDownloadedIfItDoesExistOnDisk() { Project project = mock(Project.class); when(project.existsOnDisk()).thenReturn(true); scanner.updateProject(project); verify(project, times(1)).setStatus(ProjectStatus.DOWNLOADED); }