@Test
public void requestOfflineMapDownloadShouldCreateValidIntentAndCallStartService() {

    String mapName = "kampala-map";
    String mapboxStyleUrl = "mapbox://some-map";
    String mapboxAccessToken = "access-token-here";
    LatLng topLeftBound = Mockito.mock(LatLng.class);
    LatLng topRightBound = Mockito.mock(LatLng.class);
    LatLng bottomRightBound = Mockito.mock(LatLng.class);
    LatLng bottomLeftBound = Mockito.mock(LatLng.class);
    double minZoom = 20;
    double maxZoom = 12;
    OfflineServiceHelper.ZoomRange zoomRange = new OfflineServiceHelper.ZoomRange(minZoom, maxZoom);
    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_STYLE_URL));
            results.add(intent.getStringExtra(Constants.PARCELABLE_KEY_MAPBOX_ACCESS_TOKEN));
            results.add(intent.getDoubleExtra(Constants.PARCELABLE_KEY_MIN_ZOOM, 0d));
            results.add(intent.getDoubleExtra(Constants.PARCELABLE_KEY_MAX_ZOOM, 0d));
            results.add((MapboxOfflineDownloaderService.SERVICE_ACTION) intent.getExtras().get(Constants.PARCELABLE_KEY_SERVICE_ACTION));
            results.add(intent.getParcelableExtra(Constants.PARCELABLE_KEY_BOTTOM_LEFT_BOUND));
            results.add(intent.getParcelableExtra(Constants.PARCELABLE_KEY_BOTTOM_RIGHT_BOUND));
            results.add(intent.getParcelableExtra(Constants.PARCELABLE_KEY_TOP_RIGHT_BOUND));
            results.add(intent.getParcelableExtra(Constants.PARCELABLE_KEY_TOP_LEFT_BOUND));
            return null;
        }
    })
            .when(context)
            .startService(Mockito.any(Intent.class));
    OfflineServiceHelper.requestOfflineMapDownload(context, mapName, mapboxStyleUrl, mapboxAccessToken
            , topLeftBound, topRightBound, bottomRightBound, bottomLeftBound, zoomRange);
    Mockito.verify(context, Mockito.times(1))
            .startService(Mockito.any(Intent.class));
    assertEquals(mapName, results.get(0));
    assertEquals(mapboxStyleUrl, results.get(1));
    assertEquals(mapboxAccessToken, results.get(2));
    assertEquals(minZoom, (double) results.get(3), 0d);
    assertEquals(maxZoom, (double) results.get(4), 0d);
    assertEquals(MapboxOfflineDownloaderService.SERVICE_ACTION.DOWNLOAD_MAP, results.get(5));
    assertEquals(bottomLeftBound, results.get(6));
    assertEquals(bottomRightBound, results.get(7));
    assertEquals(topRightBound, results.get(8));
    assertEquals(topLeftBound, results.get(9));
}