GetMapListTask extends AsyncTask { protected void makeMultilevelMaps(List<String> mapList) { final Map<String, List<String>> multiLevels = findMultiMapLevels(mapList); for (Map.Entry<String, List<String>> entry : multiLevels.entrySet()) { final String mapName = entry.getKey(); final List<String> levels = entry.getValue(); if (levels.size() > 1) { final StringBuilder multiMap = buildMapLevels(mapName, levels); mapList.add(multiMap.toString()); } } } GetMapListTask(final MapServerClient mapServerClient, final ProgressDialog progressDialog,
                          final ArrayAdapter<String> adapter); @Override void onPostExecute(final Object result);  }
@Test public void testMakeMultiLevelMaps() { GetMapListTask task = new GetMapListTask(null, null, null); List<String> mapList = new ArrayList<String>(); mapList.add("Meine Karte"); mapList.add("tarent-floor-1"); mapList.add("tarent-floor-3"); mapList.add("30c3-floor-4"); mapList.add("tarent-floor-2"); mapList.add("30c3-floor-2"); mapList.add("30c3-floor-3"); mapList.add("30c3-floor-0"); mapList.add("dance-floor"); mapList.add("30c3-floor-1"); mapList.add("foo-floor-9"); List<String> expectedMapList = new ArrayList<String>(mapList); expectedMapList.add("30c3 [0, 1, 2, 3, 4]"); expectedMapList.add("tarent [1, 2, 3]"); task.makeMultilevelMaps(mapList); assertEquals(expectedMapList.size(), mapList.size()); assertTrue(mapList.containsAll(expectedMapList)); }
@Test public void testEmptyMapList() { GetMapListTask task = new GetMapListTask(null, null, null); List<String> mapList = new ArrayList<String>(); task.makeMultilevelMaps(mapList); assertEquals(0, mapList.size()); }
@Test public void testNoMultiLevels() { GetMapListTask task = new GetMapListTask(null, null, null); List<String> mapList = new ArrayList<String>(); mapList.add("Meine Karte"); mapList.add("dance-floor"); List<String> expectedMapList = new ArrayList<String>(mapList); task.makeMultilevelMaps(mapList); assertEquals(expectedMapList.size(), mapList.size()); assertTrue(mapList.containsAll(expectedMapList)); }