@Test public void checksAlarmRegistered() throws Exception { Context mockedContext = mock(Context.class); AlarmManager mockedAlarmManager = mock(AlarmManager.class); AlarmReceiver mockedAlarmReceiver = mock(AlarmReceiver.class); AlarmSchedulerFlusher theAlarmSchedulerFlusher = new AlarmSchedulerFlusher(mockedContext, mockedAlarmManager, mockedAlarmReceiver); theAlarmSchedulerFlusher.register(); IntentFilter expectedFilter = new IntentFilter("com.mapbox.scheduler_flusher"); verify(mockedContext, times(1)).registerReceiver( eq(mockedAlarmReceiver), refEq(expectedFilter) ); }
@Override public void register() { Intent alarmIntent = receiver.supplyIntent(); pendingIntent = PendingIntent.getBroadcast(context, 0, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT); IntentFilter filter = new IntentFilter(SCHEDULER_FLUSHER_INTENT); context.registerReceiver(receiver, filter); }
AlarmSchedulerFlusher implements SchedulerFlusher { @Override public void register() { Intent alarmIntent = receiver.supplyIntent(); pendingIntent = PendingIntent.getBroadcast(context, 0, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT); IntentFilter filter = new IntentFilter(SCHEDULER_FLUSHER_INTENT); context.registerReceiver(receiver, filter); } }
AlarmSchedulerFlusher implements SchedulerFlusher { @Override public void register() { Intent alarmIntent = receiver.supplyIntent(); pendingIntent = PendingIntent.getBroadcast(context, 0, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT); IntentFilter filter = new IntentFilter(SCHEDULER_FLUSHER_INTENT); context.registerReceiver(receiver, filter); } AlarmSchedulerFlusher(Context context, AlarmManager manager, AlarmReceiver receiver); }
AlarmSchedulerFlusher implements SchedulerFlusher { @Override public void register() { Intent alarmIntent = receiver.supplyIntent(); pendingIntent = PendingIntent.getBroadcast(context, 0, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT); IntentFilter filter = new IntentFilter(SCHEDULER_FLUSHER_INTENT); context.registerReceiver(receiver, filter); } AlarmSchedulerFlusher(Context context, AlarmManager manager, AlarmReceiver receiver); @Override void register(); @Override void schedule(long elapsedRealTime); @Override void unregister(); }
AlarmSchedulerFlusher implements SchedulerFlusher { @Override public void register() { Intent alarmIntent = receiver.supplyIntent(); pendingIntent = PendingIntent.getBroadcast(context, 0, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT); IntentFilter filter = new IntentFilter(SCHEDULER_FLUSHER_INTENT); context.registerReceiver(receiver, filter); } AlarmSchedulerFlusher(Context context, AlarmManager manager, AlarmReceiver receiver); @Override void register(); @Override void schedule(long elapsedRealTime); @Override void unregister();  }