@Test public void attemptsToDownloadFromAllUrlsWhenFetchingMultipleExercises() { Exercise exercise1 = mock(Exercise.class); Exercise exercise2 = mock(Exercise.class); Exercise exercise3 = mock(Exercise.class); when(exercise1.getDownloadUrl()).thenReturn("url1"); when(exercise2.getDownloadUrl()).thenReturn("url2"); when(exercise3.getDownloadUrl()).thenReturn("url3"); List<Exercise> exercises = new ArrayList<Exercise>(); exercises.add(exercise1); exercises.add(exercise2); exercises.add(exercise3); ZippedProject mockZip1 = new ZippedProject(); ZippedProject mockZip2 = new ZippedProject(); ZippedProject mockZip3 = new ZippedProject(); when(server.getExerciseZip("url1")).thenReturn(mockZip1); when(server.getExerciseZip("url2")).thenReturn(mockZip2); when(server.getExerciseZip("url3")).thenReturn(mockZip3); List<ZippedProject> returnedList = downloader.downloadExercises(exercises); verify(server, times(1)).getExerciseZip("url1"); verify(server, times(1)).getExerciseZip("url2"); verify(server, times(1)).getExerciseZip("url3"); assertTrue(returnedList.contains(mockZip1)); assertTrue(returnedList.contains(mockZip2)); assertTrue(returnedList.contains(mockZip3)); }
public List<ZippedProject> downloadExercises(List<Exercise> exercises) { List<ZippedProject> projects = new ArrayList<ZippedProject>(); for (Exercise exercise : exercises) { projects.add(downloadExercise(exercise)); } return projects; }
ProjectDownloader { public List<ZippedProject> downloadExercises(List<Exercise> exercises) { List<ZippedProject> projects = new ArrayList<ZippedProject>(); for (Exercise exercise : exercises) { projects.add(downloadExercise(exercise)); } return projects; } }
ProjectDownloader { public List<ZippedProject> downloadExercises(List<Exercise> exercises) { List<ZippedProject> projects = new ArrayList<ZippedProject>(); for (Exercise exercise : exercises) { projects.add(downloadExercise(exercise)); } return projects; } ProjectDownloader(ServerManager server); }
ProjectDownloader { public List<ZippedProject> downloadExercises(List<Exercise> exercises) { List<ZippedProject> projects = new ArrayList<ZippedProject>(); for (Exercise exercise : exercises) { projects.add(downloadExercise(exercise)); } return projects; } ProjectDownloader(ServerManager server); List<ZippedProject> downloadExercises(List<Exercise> exercises); ZippedProject downloadExercise(Exercise exercise); }
ProjectDownloader { public List<ZippedProject> downloadExercises(List<Exercise> exercises) { List<ZippedProject> projects = new ArrayList<ZippedProject>(); for (Exercise exercise : exercises) { projects.add(downloadExercise(exercise)); } return projects; } ProjectDownloader(ServerManager server); List<ZippedProject> downloadExercises(List<Exercise> exercises); ZippedProject downloadExercise(Exercise exercise);  }