@Test public void createSource_shouldLogSourceCreation_andReturnSource() { try { TestLoggingListener testLoggingListener = new TestLoggingListener(true); StripeNetworkUtils.UidProvider provider = new StripeNetworkUtils.UidProvider() { @Override public String getUid() { return "abc123"; } @Override public String getPackageName() { return "com.example.main"; } }; Card card = new Card("4242424242424242", 1, 2050, "123"); Source source = StripeApiHandler.createSource( provider, RuntimeEnvironment.application.getApplicationContext(), SourceParams.createCardParams(card), FUNCTIONAL_SOURCE_PUBLISHABLE_KEY, null, testLoggingListener); assertNotNull(source); assertNull(testLoggingListener.mStripeException); assertNotNull(testLoggingListener.mStripeResponse); Assert.assertEquals(200, testLoggingListener.mStripeResponse.getResponseCode()); } catch (AuthenticationException authEx) { fail("Unexpected error: " + authEx.getLocalizedMessage()); } catch (StripeException stripeEx) { fail("Unexpected error when connecting to Stripe API: " + stripeEx.getLocalizedMessage()); } }
@Nullable static Source createSource( @Nullable StripeNetworkUtils.UidProvider uidProvider, @NonNull Context context, @NonNull SourceParams sourceParams, @NonNull String publishableKey, @Nullable String stripeAccount, @Nullable LoggingResponseListener loggingResponseListener) throws AuthenticationException, InvalidRequestException, APIConnectionException, APIException { return createSource( uidProvider, context, sourceParams, publishableKey, stripeAccount, loggingResponseListener, null); }
StripeApiHandler { @Nullable static Source createSource( @Nullable StripeNetworkUtils.UidProvider uidProvider, @NonNull Context context, @NonNull SourceParams sourceParams, @NonNull String publishableKey, @Nullable String stripeAccount, @Nullable LoggingResponseListener loggingResponseListener) throws AuthenticationException, InvalidRequestException, APIConnectionException, APIException { return createSource( uidProvider, context, sourceParams, publishableKey, stripeAccount, loggingResponseListener, null); } }
StripeApiHandler { @Nullable static Source createSource( @Nullable StripeNetworkUtils.UidProvider uidProvider, @NonNull Context context, @NonNull SourceParams sourceParams, @NonNull String publishableKey, @Nullable String stripeAccount, @Nullable LoggingResponseListener loggingResponseListener) throws AuthenticationException, InvalidRequestException, APIConnectionException, APIException { return createSource( uidProvider, context, sourceParams, publishableKey, stripeAccount, loggingResponseListener, null); }  }
StripeApiHandler { @Nullable static Source createSource( @Nullable StripeNetworkUtils.UidProvider uidProvider, @NonNull Context context, @NonNull SourceParams sourceParams, @NonNull String publishableKey, @Nullable String stripeAccount, @Nullable LoggingResponseListener loggingResponseListener) throws AuthenticationException, InvalidRequestException, APIConnectionException, APIException { return createSource( uidProvider, context, sourceParams, publishableKey, stripeAccount, loggingResponseListener, null); }   }
StripeApiHandler { @Nullable static Source createSource( @Nullable StripeNetworkUtils.UidProvider uidProvider, @NonNull Context context, @NonNull SourceParams sourceParams, @NonNull String publishableKey, @Nullable String stripeAccount, @Nullable LoggingResponseListener loggingResponseListener) throws AuthenticationException, InvalidRequestException, APIConnectionException, APIException { return createSource( uidProvider, context, sourceParams, publishableKey, stripeAccount, loggingResponseListener, null); }    }