OfflineServiceHelper { public static void stopMapDownload(@NonNull Context context, @NonNull String mapName, @NonNull String mapBoxAccessToken) { Intent stopDownloadIntent = new Intent(context, MapboxOfflineDownloaderService.class); stopDownloadIntent.putExtra(Constants.PARCELABLE_KEY_SERVICE_ACTION, MapboxOfflineDownloaderService.SERVICE_ACTION.STOP_CURRENT_DOWNLOAD); stopDownloadIntent.putExtra(Constants.PARCELABLE_KEY_MAP_UNIQUE_NAME, mapName); stopDownloadIntent.putExtra(Constants.PARCELABLE_KEY_MAPBOX_ACCESS_TOKEN, mapBoxAccessToken); stopDownloadIntent.putExtra(Constants.PARCELABLE_KEY_DELETE_TASK_TYPE, MapBoxOfflineQueueTask.TASK_TYPE_DOWNLOAD); context.startService(stopDownloadIntent); }  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);  }
@Test public void stopMapDownloadShouldCreateValidIntentAndCallStartService() { 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(intent.getExtras().get(Constants.PARCELABLE_KEY_SERVICE_ACTION)); results.add(intent.getExtras().get(Constants.PARCELABLE_KEY_DELETE_TASK_TYPE)); return null; } }) .when(context) .startService(Mockito.any(Intent.class)); OfflineServiceHelper.stopMapDownload(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.STOP_CURRENT_DOWNLOAD, results.get(2)); assertEquals(MapBoxOfflineQueueTask.TASK_TYPE_DOWNLOAD, results.get(3)); }