PermissionReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (Nanny.CLOSE.equals(intent.getStringExtra(Nanny.CONNECTION))) { context.unregisterReceiver(this); } String server = intent.getStringExtra(Nanny.SERVER); mEventFilters.get(server).process(context, intent); }  PermissionReceiver addFilter(Event event); @Override void onReceive(Context context, Intent intent);  }
@Test public void onReceive() throws Exception { mIntent.putExtras(new NannyBundle.Builder().server("filter").build()); mReceiver.addFilter(mEventFilter); mReceiver.onReceive(mContext, mIntent); verify(mEventFilter).process(mContext, mIntent); }