@Test public void onShippingInfoSave_whenShippingPopulated_sendsCorrectIntent() { Intent intent = new Intent(); PaymentSessionConfig paymentSessionConfig = new PaymentSessionConfig.Builder() .setPrepopulatedShippingInfo(getExampleShippingInfo()) .build(); intent.putExtra(PAYMENT_SESSION_CONFIG, paymentSessionConfig); PaymentSessionData paymentSessionData = new PaymentSessionData(); intent.putExtra(PAYMENT_SESSION_DATA_KEY, paymentSessionData); mActivityController = Robolectric.buildActivity(PaymentFlowActivity.class, intent) .create().start().resume().visible(); mShippingInfoWidget = mActivityController.get().findViewById(R.id.shipping_info_widget); assertNotNull(mShippingInfoWidget); PaymentFlowActivity paymentFlowActivity = mActivityController.get(); paymentFlowActivity.onActionSave(); ArgumentCaptor<Intent> intentArgumentCaptor = ArgumentCaptor.forClass(Intent.class); verify(mBroadcastReceiver).onReceive(any(Context.class), intentArgumentCaptor.capture()); Intent captured = intentArgumentCaptor.getValue(); assertNotNull(captured); assertEquals( captured.getParcelableExtra(EXTRA_SHIPPING_INFO_DATA), getExampleShippingInfo()); }
@Override protected void onActionSave() { if (mPaymentFlowPagerAdapter.getPageAt( mViewPager.getCurrentItem()).equals(PaymentFlowPagerEnum.SHIPPING_INFO)) { onShippingInfoSubmitted(); } else { onShippingMethodSave(); } }
PaymentFlowActivity extends StripeActivity { @Override protected void onActionSave() { if (mPaymentFlowPagerAdapter.getPageAt( mViewPager.getCurrentItem()).equals(PaymentFlowPagerEnum.SHIPPING_INFO)) { onShippingInfoSubmitted(); } else { onShippingMethodSave(); } } }
PaymentFlowActivity extends StripeActivity { @Override protected void onActionSave() { if (mPaymentFlowPagerAdapter.getPageAt( mViewPager.getCurrentItem()).equals(PaymentFlowPagerEnum.SHIPPING_INFO)) { onShippingInfoSubmitted(); } else { onShippingMethodSave(); } }  }
PaymentFlowActivity extends StripeActivity { @Override protected void onActionSave() { if (mPaymentFlowPagerAdapter.getPageAt( mViewPager.getCurrentItem()).equals(PaymentFlowPagerEnum.SHIPPING_INFO)) { onShippingInfoSubmitted(); } else { onShippingMethodSave(); } }  @Override void onBackPressed(); }
PaymentFlowActivity extends StripeActivity { @Override protected void onActionSave() { if (mPaymentFlowPagerAdapter.getPageAt( mViewPager.getCurrentItem()).equals(PaymentFlowPagerEnum.SHIPPING_INFO)) { onShippingInfoSubmitted(); } else { onShippingMethodSave(); } }  @Override void onBackPressed(); static final String EXTRA_DEFAULT_SHIPPING_METHOD; static final String EXTRA_IS_SHIPPING_INFO_VALID; static final String EXTRA_SHIPPING_INFO_DATA; static final String EXTRA_SHIPPING_INFO_ERROR; static final String EVENT_SHIPPING_INFO_PROCESSED; static final String EVENT_SHIPPING_INFO_SUBMITTED; static final String EXTRA_VALID_SHIPPING_METHODS; }