@Test
public void testOnReceiveWhenIntentNotNullTC2() {

    // when initCTGeofenceApiIfRequired return false
    CTGeofenceBootReceiver receiver = new CTGeofenceBootReceiver();
    CTGeofenceBootReceiver spy = Mockito.spy(receiver);
    when(spy.goAsync()).thenReturn(pendingResult);
    final Boolean[] isFinished = {false};
    doAnswer(new Answer() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            isFinished[0] = true;
            return null;
        }
    }).when(pendingResult).finish();
    PowerMockito.when(Utils.hasPermission(application, Manifest.permission.ACCESS_FINE_LOCATION))
            .thenReturn(true);
    PowerMockito.when(Utils.hasBackgroundLocationPermission(application)).thenReturn(true);
    PowerMockito.when(Utils.initCTGeofenceApiIfRequired(application)).thenReturn(false);
    Intent intent = new Intent(Intent.ACTION_BOOT_COMPLETED);
    spy.onReceive(application, intent);
    await().until(new Callable<Boolean>() {
        @Override
        public Boolean call() throws Exception {
            return isFinished[0];
        }
    });
    verify(pendingResult).finish();
}