### Question:
ProjectScanner { public void updateProjects() { for (Project project : projectDAO.getProjects()) { updateProject(project); } } ProjectScanner(ProjectDAO projectDAO, IOFactory io); void updateProject(Project project); void updateProjects();  }### Answer:
@Test public void updateProjectIsCalledOnAllProjectsWhenCallingUpdateProjects() { List<Project> projects = new ArrayList<Project>(); Project project = mock(Project.class); when(project.getStatus()).thenReturn(ProjectStatus.DELETED); projects.add(project); project = mock(Project.class); when(project.existsOnDisk()).thenReturn(false); projects.add(project); project = mock(Project.class); when(project.existsOnDisk()).thenReturn(true); projects.add(project); when(dao.getProjects()).thenReturn(projects); scanner.updateProjects(); verify(projects.get(0), times(1)).getStatus(); verifyNoMoreInteractions(projects.get(0)); verify(projects.get(1), times(1)).getStatus(); verify(projects.get(1), times(1)).setProjectFiles(anyListOf(String.class)); verify(projects.get(1), times(1)).setStatus(ProjectStatus.NOT_DOWNLOADED); verify(projects.get(2), times(1)).getStatus(); verify(projects.get(2), times(1)).setProjectFiles(anyListOf(String.class)); verify(projects.get(2), times(1)).setStatus(ProjectStatus.DOWNLOADED); }