GoogleGeofenceAdapter implements CTGeofenceAdapter { @SuppressWarnings("unchecked") @WorkerThread @Override public void removeAllGeofence(@Nullable List<String> fenceIdList, @NonNull final OnSuccessListener onSuccessListener) { if (fenceIdList == null || fenceIdList.isEmpty()) { return; } Void aVoid = null; try { Task<Void> removeGeofenceTask = geofencingClient.removeGeofences(fenceIdList); aVoid = Tasks.await(removeGeofenceTask); CTGeofenceAPI.getLogger().debug(CTGeofenceAPI.GEOFENCE_LOG_TAG, "Geofence removed successfully"); } catch (Exception e) { CTGeofenceAPI.getLogger().debug(CTGeofenceAPI.GEOFENCE_LOG_TAG, "Failed to remove registered geofences"); e.printStackTrace(); } finally { onSuccessListener.onSuccess(aVoid); } } GoogleGeofenceAdapter(@NonNull Context context); @SuppressWarnings("unchecked") @WorkerThread @Override void addAllGeofence(@Nullable List<CTGeofence> fenceList,
            @NonNull final OnSuccessListener onSuccessListener); @SuppressWarnings("unchecked") @WorkerThread @Override void removeAllGeofence(@Nullable List<String> fenceIdList,
            @NonNull final OnSuccessListener onSuccessListener); @WorkerThread @Override void stopGeofenceMonitoring(@Nullable final PendingIntent pendingIntent);  }
@Test public void testRemoveAllGeofenceTC3() { List<String> ctGeofenceIds = Arrays.asList("111", "222"); GoogleGeofenceAdapter geofenceAdapter = new GoogleGeofenceAdapter(application); when(geofencingClient.removeGeofences(ctGeofenceIds)).thenReturn(task); geofenceAdapter.removeAllGeofence(ctGeofenceIds, onSuccessListener); try { verifyStatic(Tasks.class); Tasks.await(task); verify(onSuccessListener).onSuccess(null); } catch (ExecutionException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } }
@Test public void testRemoveAllGeofenceTC1() { GoogleGeofenceAdapter geofenceAdapter = new GoogleGeofenceAdapter(application); geofenceAdapter.removeAllGeofence(null, onSuccessListener); verify(geofencingClient, never()).removeGeofences(ArgumentMatchers.<String>anyList()); }
@Test public void testRemoveAllGeofenceTC2() { GoogleGeofenceAdapter geofenceAdapter = new GoogleGeofenceAdapter(application); geofenceAdapter.removeAllGeofence(new ArrayList<String>(), onSuccessListener); verify(geofencingClient, never()).removeGeofences(ArgumentMatchers.<String>anyList()); }