@Test public void deleteOfflineMapShouldCreateValidIntentAndCallStartService() { String mapName = "kampala-map"; String mapboxAccessToken = "access-token-here"; ArrayList<Object> results = new ArrayList<>(); Mockito.doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { Intent intent = invocation.getArgument(0); results.add(intent.getStringExtra(Constants.PARCELABLE_KEY_MAP_UNIQUE_NAME)); results.add(intent.getStringExtra(Constants.PARCELABLE_KEY_MAPBOX_ACCESS_TOKEN)); results.add((MapboxOfflineDownloaderService.SERVICE_ACTION) intent.getExtras().get(Constants.PARCELABLE_KEY_SERVICE_ACTION)); return null; } }) .when(context) .startService(Mockito.any(Intent.class)); OfflineServiceHelper.deleteOfflineMap(context, mapName, mapboxAccessToken); Mockito.verify(context, Mockito.times(1)) .startService(Mockito.any(Intent.class)); assertEquals(mapName, results.get(0)); assertEquals(mapboxAccessToken, results.get(1)); assertEquals(MapboxOfflineDownloaderService.SERVICE_ACTION.DELETE_MAP, results.get(2)); }
public static void deleteOfflineMap(@NonNull Context context, @NonNull String mapName, @NonNull String mapBoxAccessToken) { Intent intent = new Intent(context, MapboxOfflineDownloaderService.class); intent.putExtra(Constants.PARCELABLE_KEY_SERVICE_ACTION, MapboxOfflineDownloaderService.SERVICE_ACTION.DELETE_MAP); intent.putExtra(Constants.PARCELABLE_KEY_MAP_UNIQUE_NAME, mapName); intent.putExtra(Constants.PARCELABLE_KEY_MAPBOX_ACCESS_TOKEN, mapBoxAccessToken); context.startService(intent); }
OfflineServiceHelper { public static void deleteOfflineMap(@NonNull Context context, @NonNull String mapName, @NonNull String mapBoxAccessToken) { Intent intent = new Intent(context, MapboxOfflineDownloaderService.class); intent.putExtra(Constants.PARCELABLE_KEY_SERVICE_ACTION, MapboxOfflineDownloaderService.SERVICE_ACTION.DELETE_MAP); intent.putExtra(Constants.PARCELABLE_KEY_MAP_UNIQUE_NAME, mapName); intent.putExtra(Constants.PARCELABLE_KEY_MAPBOX_ACCESS_TOKEN, mapBoxAccessToken); context.startService(intent); } }
OfflineServiceHelper { public static void deleteOfflineMap(@NonNull Context context, @NonNull String mapName, @NonNull String mapBoxAccessToken) { Intent intent = new Intent(context, MapboxOfflineDownloaderService.class); intent.putExtra(Constants.PARCELABLE_KEY_SERVICE_ACTION, MapboxOfflineDownloaderService.SERVICE_ACTION.DELETE_MAP); intent.putExtra(Constants.PARCELABLE_KEY_MAP_UNIQUE_NAME, mapName); intent.putExtra(Constants.PARCELABLE_KEY_MAPBOX_ACCESS_TOKEN, mapBoxAccessToken); context.startService(intent); }  }
OfflineServiceHelper { public static void deleteOfflineMap(@NonNull Context context, @NonNull String mapName, @NonNull String mapBoxAccessToken) { Intent intent = new Intent(context, MapboxOfflineDownloaderService.class); intent.putExtra(Constants.PARCELABLE_KEY_SERVICE_ACTION, MapboxOfflineDownloaderService.SERVICE_ACTION.DELETE_MAP); intent.putExtra(Constants.PARCELABLE_KEY_MAP_UNIQUE_NAME, mapName); intent.putExtra(Constants.PARCELABLE_KEY_MAPBOX_ACCESS_TOKEN, mapBoxAccessToken); context.startService(intent); }  static void requestOfflineMapDownload(@NonNull Context context, @NonNull String mapName,
                                          @NonNull String mapboxStyleUrl, @NonNull String mapBoxAccessToken,
                                          @NonNull LatLng topLeftBound, @NonNull LatLng topRightBound,
                                          @NonNull LatLng bottomRightBound, @NonNull LatLng bottomLeftBound,
                                          @NonNull ZoomRange zoomRange); static void requestOfflineMapDownload(@NonNull Context context, @NonNull String mapName,
                                                 @NonNull String mapboxStyleUrl, @NonNull String mapBoxAccessToken,
                                                 @NonNull LatLng topLeftBound, @NonNull LatLng topRightBound,
                                                 @NonNull LatLng bottomRightBound, @NonNull LatLng bottomLeftBound,
                                                 @NonNull ZoomRange zoomRange, @NonNull Long tileDownloadLimit); static void deleteOfflineMap(@NonNull Context context, @NonNull String mapName, @NonNull String mapBoxAccessToken); static void stopMapDownload(@NonNull Context context, @NonNull String mapName, @NonNull String mapBoxAccessToken); }
OfflineServiceHelper { public static void deleteOfflineMap(@NonNull Context context, @NonNull String mapName, @NonNull String mapBoxAccessToken) { Intent intent = new Intent(context, MapboxOfflineDownloaderService.class); intent.putExtra(Constants.PARCELABLE_KEY_SERVICE_ACTION, MapboxOfflineDownloaderService.SERVICE_ACTION.DELETE_MAP); intent.putExtra(Constants.PARCELABLE_KEY_MAP_UNIQUE_NAME, mapName); intent.putExtra(Constants.PARCELABLE_KEY_MAPBOX_ACCESS_TOKEN, mapBoxAccessToken); context.startService(intent); }  static void requestOfflineMapDownload(@NonNull Context context, @NonNull String mapName,
                                          @NonNull String mapboxStyleUrl, @NonNull String mapBoxAccessToken,
                                          @NonNull LatLng topLeftBound, @NonNull LatLng topRightBound,
                                          @NonNull LatLng bottomRightBound, @NonNull LatLng bottomLeftBound,
                                          @NonNull ZoomRange zoomRange); static void requestOfflineMapDownload(@NonNull Context context, @NonNull String mapName,
                                                 @NonNull String mapboxStyleUrl, @NonNull String mapBoxAccessToken,
                                                 @NonNull LatLng topLeftBound, @NonNull LatLng topRightBound,
                                                 @NonNull LatLng bottomRightBound, @NonNull LatLng bottomLeftBound,
                                                 @NonNull ZoomRange zoomRange, @NonNull Long tileDownloadLimit); static void deleteOfflineMap(@NonNull Context context, @NonNull String mapName, @NonNull String mapBoxAccessToken); static void stopMapDownload(@NonNull Context context, @NonNull String mapName, @NonNull String mapBoxAccessToken);  }