### Question:
WifiPeriodicReplicationReceiver extends PeriodicReplicationReceiver { @Override public void onReceive(Context context, Intent intent) { int command = ReplicationService.COMMAND_NONE; if (ConnectivityManager.CONNECTIVITY_ACTION.equals(intent.getAction())) { boolean isConnectedToWifi = isConnectedToWifi(context); if (isConnectedToWifi == wasOnWifi(context)) { return; } else if (isConnectedToWifi) { setWasOnWifi(context, true); if (PeriodicReplicationService.replicationsPending(context, clazz)) { command = ReplicationService.COMMAND_START_REPLICATION; } } else if (!isConnectedToWifi(context)) { setWasOnWifi(context, false); command = ReplicationService.COMMAND_STOP_REPLICATION; } } else if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) { super.onReceive(context, intent); setWasOnWifi(context, false); if (PeriodicReplicationService.isPeriodicReplicationEnabled(context, clazz)) { command = PeriodicReplicationService.COMMAND_START_PERIODIC_REPLICATION; } } else if (!ALARM_ACTION.equals(intent.getAction()) || isConnectedToWifi (context)) { super.onReceive(context, intent); } else { PeriodicReplicationService.setReplicationsPending(context, clazz, true); } if (command != ReplicationService.COMMAND_NONE) { Intent serviceIntent = new Intent(context.getApplicationContext(), clazz); serviceIntent.putExtra(PeriodicReplicationService.EXTRA_COMMAND, command); startWakefulService(context, serviceIntent); } } protected  WifiPeriodicReplicationReceiver(Class<T> clazz); @Override void onReceive(Context context, Intent intent); static boolean isConnectedToWifi(Context context);  }### Answer:
@Test public void testBootCompleted() { Intent intent = new Intent(Intent.ACTION_BOOT_COMPLETED); mMockPreferencesEditor = mock(SharedPreferences.Editor.class); when(mMockPreferences.edit()).thenReturn(mMockPreferencesEditor); mReceiver.onReceive(mMockContext, intent); verify(mMockPreferencesEditor, times(1)).putBoolean(ReplicationService.class.getName() + ".wasOnWifi", false); assertEquals(1, mMockContext.getIntentsReceived().size()); Intent receivedIntent = mMockContext.getIntentsReceived().get(0); assertEquals(ReplicationService.class.getName(), receivedIntent.getComponent().getClassName()); assertNull(receivedIntent.getAction()); assertEquals(PeriodicReplicationService.COMMAND_DEVICE_REBOOTED, receivedIntent.getIntExtra(ReplicationService.EXTRA_COMMAND, ReplicationService.COMMAND_NONE)); }