@Test public void checksOnPeriodRaisedCall() throws Exception { Context mockedContext = mock(Context.class); Intent mockedIntent = mock(Intent.class); when(mockedIntent.getAction()).thenReturn("com.mapbox.scheduler_flusher"); SchedulerCallback mockedSchedulerCallback = mock(SchedulerCallback.class); AlarmReceiver theAlarmReceiver = new AlarmReceiver(mockedSchedulerCallback); theAlarmReceiver.onReceive(mockedContext, mockedIntent); verify(mockedSchedulerCallback, times(1)).onPeriodRaised(); }
@Override public void onReceive(Context context, Intent intent) { try { if (SCHEDULER_FLUSHER_INTENT.equals(intent.getAction())) { callback.onPeriodRaised(); } } catch (Throwable throwable) { Log.e(TAG, throwable.toString()); } }
AlarmReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { try { if (SCHEDULER_FLUSHER_INTENT.equals(intent.getAction())) { callback.onPeriodRaised(); } } catch (Throwable throwable) { Log.e(TAG, throwable.toString()); } } }
AlarmReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { try { if (SCHEDULER_FLUSHER_INTENT.equals(intent.getAction())) { callback.onPeriodRaised(); } } catch (Throwable throwable) { Log.e(TAG, throwable.toString()); } } AlarmReceiver(@NonNull SchedulerCallback callback); }
AlarmReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { try { if (SCHEDULER_FLUSHER_INTENT.equals(intent.getAction())) { callback.onPeriodRaised(); } } catch (Throwable throwable) { Log.e(TAG, throwable.toString()); } } AlarmReceiver(@NonNull SchedulerCallback callback); @Override void onReceive(Context context, Intent intent); }
AlarmReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { try { if (SCHEDULER_FLUSHER_INTENT.equals(intent.getAction())) { callback.onPeriodRaised(); } } catch (Throwable throwable) { Log.e(TAG, throwable.toString()); } } AlarmReceiver(@NonNull SchedulerCallback callback); @Override void onReceive(Context context, Intent intent);  }