BaseInterstitialActivity extends Activity { Long getBroadcastIdentifier() { return mBroadcastIdentifier; }  abstract View getAdView();  }
@Test public void getBroadcastIdentifier_shouldReturnBroadcastIdFromIntent() throws Exception { Context context = Robolectric.buildActivity(Activity.class).create().get(); Intent intent = new Intent(context, TestInterstitialActivity.class); intent.putExtra(BROADCAST_IDENTIFIER_KEY, broadcastIdentifier); subject = Robolectric.buildActivity(TestInterstitialActivity.class) .withIntent(intent) .create().get(); assertThat(subject.getBroadcastIdentifier()).isEqualTo(2222L); }
@Test public void getBroadcastIdentifier_withMissingBroadCastId_shouldReturnNull() throws Exception { Context context = Robolectric.buildActivity(Activity.class).create().get(); Intent intent = new Intent(context, TestInterstitialActivity.class); subject = Robolectric.buildActivity(TestInterstitialActivity.class) .withIntent(intent) .create().get(); assertThat(subject.getBroadcastIdentifier()).isNull(); }