DownloadMapDataTask extends DownloadTask<Void, Void, Map<String, Collection>> { @Override protected Map<String, Collection> doInBackground(final Void... params) { final Map<String, Collection> result = new HashMap<String, Collection>(); try { parser.parse(getXmlStream()); result.putAll(parser.getResults()); success = true; } catch (IOException e) { success = false; } catch (NicException e) { success = false; } return result; } DownloadMapDataTask(final DownloadListener<Map<String, Collection>> downloadListener,
                               final MapServerClient mapServerClient,
                               final String mapName,
                               final OsmParser parser);  DownloadMapDataTask(final MapServerClient mapServerClient,
                               final String mapName,
                               final OsmParser parser);   }
@Test public void testDoInBackground() throws IOException { OsmParser parser = mock(OsmParser.class); DownloadMapDataTask taskToTest = new DownloadMapDataTask(wayManager, mapServerClient, "test", parser); Map<String, Collection> results = new HashMap<String, Collection>(); when(parser.getResults()).thenReturn(results); Map<String, Collection> result = taskToTest.doInBackground(null); taskToTest.onPostExecute(result); verify(wayManager).onDownloadFinished(eq(taskToTest), eq(true), eq(results)); verify(parser, times(1)).parse(any(InputStream.class)); }