NannyRequest { protected void startRequest(Context context) { if (!Nanny.isPermissionNannyInstalled(context)) { if (mReceiver != null) { mReceiver.onReceive(context, newNotFoundIntent()); } return; } if (mPaylaod == null) { throw new IllegalStateException("No payload."); } if (mReceiver != null) { context.registerReceiver(mReceiver, new IntentFilter(mClientAddr)); } context.sendBroadcast(mPaylaod); } NannyRequest();   }
@Test public void startRequest() throws Exception { when(Nanny.isPermissionNannyInstalled(mContext)).thenReturn(true); mNannyRequest.addFilter(mEvent); mNannyRequest.setPayload(mIntent); mNannyRequest.startRequest(mContext); verify(mContext).registerReceiver((BroadcastReceiver) notNull(), mIntentFilterCaptor.capture()); assertThat(mIntentFilterCaptor.getValue().countActions(), is(1)); assertThat(mIntentFilterCaptor.getValue().getAction(0), is(mNannyRequest.mClientAddr)); verify(mContext).sendBroadcast(mIntent); }