DownloadXmlTask extends AsyncTask<String, Void, List<Project>> { @Override protected List<Project> doInBackground(String... urls) { ArrayList<Project> projects = new ArrayList<>(); try { for (String url: urls) { List<Project> projectList = projectParser.fetch(new URL(url)); projects.addAll(projectList); } } catch (IOException e) { e.printStackTrace(); } mProjectStorageController.clear(); mProjectStorageController.add(projects); return projects; } DownloadXmlTask(ProjectParser projectParser, ListViewController listViewController, ProjectStorageController
            projectStorageController);   }
@Test public void testThatProjectListIsFetchedInBackgroundThread() throws Exception { String url = "https: List<Project> expectedProjects = asList(new Project(), new Project()); when(parser.fetch(new URL(url))).thenReturn(expectedProjects); List<Project> projects = downloadXmlTask.doInBackground(url); assertThat(projects, is(expectedProjects)); }
@Test public void testThatProjectListIsStoredInLocalStorageInBackgroundThread() throws Exception { String url = "https: List<Project> expectedProjects = asList(new Project(), new Project()); when(parser.fetch(new URL(url))).thenReturn(expectedProjects); downloadXmlTask.doInBackground(url); verify(projectStorageController).add(expectedProjects); }