RxWifiManager { @CheckResult @NonNull public static Observable<SupplicantStateChangedEvent> supplicantStateChanges(@NonNull final Context context) { checkNotNull(context, "context == null"); IntentFilter filter = new IntentFilter(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION); return RxBroadcastReceiver.create(context, filter) .map(new Func1<Intent, SupplicantStateChangedEvent>() { @Override public SupplicantStateChangedEvent call(Intent intent) { SupplicantState newState = intent.getParcelableExtra(WifiManager.EXTRA_NEW_STATE); int error = intent.getIntExtra(WifiManager.EXTRA_SUPPLICANT_ERROR, 0); return SupplicantStateChangedEvent.create(newState, error); } }); } private  RxWifiManager(); @CheckResult @NonNull // static Observable<Integer> wifiStateChanges(@NonNull final Context context); @CheckResult @NonNull // static Action1<? super Boolean> wifiState(@NonNull final WifiManager wifiManager); @CheckResult @NonNull // static Observable<NetworkStateChangedEvent> networkStateChanges(@NonNull final Context context); @CheckResult @NonNull // static Observable<Boolean> supplicantConnectionChanges(@NonNull final Context context); @CheckResult @NonNull // static Observable<SupplicantStateChangedEvent> supplicantStateChanges(@NonNull final Context context);  }
@SuppressWarnings("ResourceType") @Test public void supplicantStateChanges() throws IllegalAccessException, InstantiationException { Application application = RuntimeEnvironment.application; TestSubscriber<SupplicantStateChangedEvent> o = new TestSubscriber<>(); RxWifiManager.supplicantStateChanges(application).subscribe(o); o.assertValues(); Intent intent1 = new Intent(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION) .putExtra(EXTRA_NEW_STATE, (Parcelable) SupplicantState.INACTIVE) .putExtra(EXTRA_SUPPLICANT_ERROR, ERROR_AUTHENTICATING); application.sendBroadcast(intent1); SupplicantStateChangedEvent event1 = SupplicantStateChangedEvent.create(SupplicantState.INACTIVE, ERROR_AUTHENTICATING); o.assertValues(event1); Intent intent2 = new Intent(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION) .putExtra(EXTRA_NEW_STATE, (Parcelable) SupplicantState.ASSOCIATING) .putExtra(EXTRA_SUPPLICANT_ERROR, -1); application.sendBroadcast(intent2); SupplicantStateChangedEvent event2 = SupplicantStateChangedEvent.create(SupplicantState.ASSOCIATING, -1); o.assertValues(event1, event2); }