PaymentPresenter extends PresenterWidget<PaymentPresenter.MyView> implements PaymentUiHandlers, PaymentDetailsUpdatedEventHandler, ShoppingCartChangedEventHandler { @Override protected void onBind() { addRegisteredHandler(PaymentDetailsUpdatedEvent.TYPE, this); addRegisteredHandler(ShoppingCartChangedEvent.TYPE, this); stripe.inject(new Callback<Void, Exception>() { @Override public void onFailure(Exception e) { getView().showErrorMessage("Failed to load stripe payment."); } @Override public void onSuccess(Void aVoid) { onStripeInjected(); } }); } @Inject  PaymentPresenter(
            EventBus eventBus,
            MyView view,
            Config config,
            Stripe stripe,
            ResourceDelegate<PaymentResource> paymentResource,
            CurrentOrder currentOrder); @Override void onShoppingCartChanged(ShoppingCartChangedEvent event); @Override void onSubmit(String name, String number, String cvc, int expMonth, int expYear); @Override void onValidUpdate(); @Override void onInvalidUpdate();  }
@Test public void onBind_givenInjectStripeSucceeds_setPublishableKeyAndEnablesPaymentInView(Config config) { String publishableKey = "pk_hello"; given(config.stripePublicKey()).willReturn(publishableKey); givenStripeInjectWillCallOnSuccess(); presenter.onBind(); verify(stripe).setPublishableKey(publishableKey); verify(view).enablePaymentSubmit(); }
@Test public void onBind_givenInjectStripeFails_showsErrorMessageAndDoesNotEnablePaymentInView() { givenStripeInjectWillCallOnFailure(); presenter.onBind(); verify(view).showErrorMessage(anyString()); verify(view, never()).enablePaymentSubmit(); }