PushGeofenceEventTask implements CTGeofenceTask { @Override public void setOnCompleteListener(@NonNull OnCompleteListener onCompleteListener) { this.onCompleteListener = onCompleteListener; } PushGeofenceEventTask(Context context, @NonNull Intent intent); @WorkerThread @Override void execute(); @Override void setOnCompleteListener(@NonNull OnCompleteListener onCompleteListener);  }
@Test public void testSendOnCompleteEventWhenListenerIsNull() { PushGeofenceEventTask task = new PushGeofenceEventTask(application, intent); task.setOnCompleteListener(null); try { WhiteboxImpl.invokeMethod(task, "sendOnCompleteEvent"); } catch (Exception e) { e.printStackTrace(); } Mockito.verify(onCompleteListener, times(0)).onComplete(); }
@Test public void testSendOnCompleteEventWhenListenerNotNull() { PushGeofenceEventTask task = new PushGeofenceEventTask(application, intent); task.setOnCompleteListener(onCompleteListener); try { WhiteboxImpl.invokeMethod(task, "sendOnCompleteEvent"); } catch (Exception e) { e.printStackTrace(); } Mockito.verify(onCompleteListener).onComplete(); }