CTGeofenceAPI implements GeofenceCallback { @SuppressWarnings("unused") public void deactivate() { if (ctLocationAdapter == null || ctGeofenceAdapter == null) { return; } CTGeofenceTaskManager.getInstance().postAsyncSafely("DeactivateApi", new Runnable() { @Override public void run() { PendingIntent geofencePendingIntent = PendingIntentFactory.getPendingIntent(context, PendingIntentFactory.PENDING_INTENT_GEOFENCE, FLAG_NO_CREATE); ctGeofenceAdapter.stopGeofenceMonitoring(geofencePendingIntent); PendingIntent locationPendingIntent = PendingIntentFactory.getPendingIntent(context, PendingIntentFactory.PENDING_INTENT_LOCATION, FLAG_NO_CREATE); ctLocationAdapter.removeLocationUpdates(locationPendingIntent); FileUtils.deleteDirectory(context, FileUtils.getCachedDirName(context)); GeofenceStorageHelper.putDouble(context , CTGeofenceConstants.KEY_LATITUDE, DEFAULT_LATITUDE); GeofenceStorageHelper.putDouble(context , CTGeofenceConstants.KEY_LONGITUDE, DEFAULT_LONGITUDE); GeofenceStorageHelper.putLong(context , CTGeofenceConstants.KEY_LAST_LOCATION_EP, 0); isActivated = false; } }); } private  CTGeofenceAPI(Context context); @SuppressWarnings("WeakerAccess") @NonNull static CTGeofenceAPI getInstance(@NonNull Context context); static Logger getLogger(); @SuppressWarnings("unused") void deactivate(); @Nullable CTGeofenceEventsListener getCtGeofenceEventsListener(); void setCtGeofenceEventsListener(@NonNull CTGeofenceEventsListener ctGeofenceEventsListener); @Nullable CTLocationUpdatesListener getCtLocationUpdatesListener(); void setCtLocationUpdatesListener(@NonNull CTLocationUpdatesListener ctLocationUpdatesListener); @SuppressWarnings("WeakerAccess") @Nullable CTGeofenceSettings getGeofenceSettings(); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @Override void handleGeoFences(JSONObject fenceList); void init(CTGeofenceSettings ctGeofenceSettings, @NonNull CleverTapAPI cleverTapAPI); @SuppressWarnings("WeakerAccess") void initBackgroundLocationUpdates(); @SuppressWarnings("unused") void setOnGeofenceApiInitializedListener(
            @NonNull OnGeofenceApiInitializedListener onGeofenceApiInitializedListener); @SuppressWarnings("unused") @Override void triggerLocation(); static final String GEOFENCE_LOG_TAG; }
@Test public void testDeactivate() { CTGeofenceAPI ctGeofenceAPI = CTGeofenceAPI.getInstance(application); CTGeofenceTaskManager.getInstance().setExecutorService(executorService); ctGeofenceAPI.deactivate(); ArgumentCaptor<Runnable> argumentCaptor = ArgumentCaptor.forClass(Runnable.class); verify(executorService).submit(argumentCaptor.capture()); PendingIntent geofenceMonitoring = PendingIntentFactory.getPendingIntent(application, PendingIntentFactory.PENDING_INTENT_GEOFENCE, FLAG_UPDATE_CURRENT); PendingIntent locationUpdates = PendingIntentFactory.getPendingIntent(application, PendingIntentFactory.PENDING_INTENT_LOCATION, FLAG_UPDATE_CURRENT); argumentCaptor.getValue().run(); verify(geofenceAdapter).stopGeofenceMonitoring(geofenceMonitoring); verify(locationAdapter).removeLocationUpdates(locationUpdates); PowerMockito.verifyStatic(FileUtils.class); FileUtils.deleteDirectory(any(Context.class), FileUtils.getCachedDirName(application)); assertFalse(ctGeofenceAPI.isActivated()); }