use of com.braintreepayments.api.models.Configuration in project braintree_android by braintree.
the class VenmoUnitTest method performAppSwitch_sendsAnalyticsEventWhenStarted.
@Test
public void performAppSwitch_sendsAnalyticsEventWhenStarted() {
Configuration configuration = getConfigurationFromFixture();
BraintreeFragment fragment = new MockFragmentBuilder().context(VenmoInstalledContextFactory.venmoInstalledContext(true, RuntimeEnvironment.application)).configuration(configuration).build();
Venmo.authorizeAccount(fragment, false);
verify(fragment).sendAnalyticsEvent("pay-with-venmo.selected");
verify(fragment).sendAnalyticsEvent("pay-with-venmo.app-switch.started");
}
use of com.braintreepayments.api.models.Configuration in project braintree_android by braintree.
the class VenmoUnitTest method onActivityResult_withSuccessfulVaultCall_returnsVenmoAccountNonce.
@Test
public void onActivityResult_withSuccessfulVaultCall_returnsVenmoAccountNonce() throws InvalidArgumentException {
Configuration configuration = getConfigurationFromFixture();
Authorization clientToken = Authorization.fromString(stringFromFixture("base_64_client_token.txt"));
disableSignatureVerification();
BraintreeFragment fragment = new MockFragmentBuilder().context(VenmoInstalledContextFactory.venmoInstalledContext(true, RuntimeEnvironment.application)).configuration(configuration).authorization(clientToken).sessionId("session-id").successResponse(stringFromFixture("payment_methods/venmo_account_response.json")).build();
Venmo.authorizeAccount(fragment, true);
ArgumentCaptor<PaymentMethodNonce> responseCaptor = ArgumentCaptor.forClass(PaymentMethodNonce.class);
Intent responseIntent = new Intent().putExtra(Venmo.EXTRA_PAYMENT_METHOD_NONCE, "nonce");
Venmo.onActivityResult(fragment, Activity.RESULT_OK, responseIntent);
verify(fragment).postCallback(responseCaptor.capture());
PaymentMethodNonce capturedNonce = responseCaptor.getValue();
assertTrue(capturedNonce instanceof VenmoAccountNonce);
VenmoAccountNonce venmoAccountNonce = (VenmoAccountNonce) capturedNonce;
assertEquals("Venmo", venmoAccountNonce.getTypeLabel());
assertEquals("fake-venmo-nonce", venmoAccountNonce.getNonce());
assertEquals("venmojoe", venmoAccountNonce.getUsername());
}
use of com.braintreepayments.api.models.Configuration in project braintree_android by braintree.
the class VenmoUnitTest method performAppSwitch_sendsAnalyticsEvent.
@Test
public void performAppSwitch_sendsAnalyticsEvent() {
Configuration configuration = getConfigurationFromFixture();
BraintreeFragment fragment = new MockFragmentBuilder().configuration(configuration).build();
Venmo.authorizeAccount(fragment);
verify(fragment).sendAnalyticsEvent("pay-with-venmo.selected");
}
use of com.braintreepayments.api.models.Configuration in project braintree_android by braintree.
the class BraintreeFragmentUnitTest method onSaveInstanceState_savesState.
@Test
public void onSaveInstanceState_savesState() throws InvalidArgumentException, JSONException {
Configuration configuration = new TestConfigurationBuilder().buildConfiguration();
mockConfigurationManager(configuration);
BraintreeFragment fragment = BraintreeFragment.newInstance(mActivity, TOKENIZATION_KEY);
Bundle bundle = new Bundle();
fragment.onSaveInstanceState(bundle);
assertTrue(bundle.getParcelableArrayList(BraintreeFragment.EXTRA_CACHED_PAYMENT_METHOD_NONCES).isEmpty());
assertFalse(bundle.getBoolean(BraintreeFragment.EXTRA_FETCHED_PAYMENT_METHOD_NONCES));
assertEquals(configuration.toJson(), bundle.getString(BraintreeFragment.EXTRA_CONFIGURATION));
}
use of com.braintreepayments.api.models.Configuration in project braintree_android by braintree.
the class BraintreeFragmentUnitTest method getGraphQLHttpClient_returnsGraphQLHttpClientWhenEnabled.
@Test
public void getGraphQLHttpClient_returnsGraphQLHttpClientWhenEnabled() throws InvalidArgumentException {
Configuration configuration = new TestConfigurationBuilder().graphQL().buildConfiguration();
mockConfigurationManager(configuration);
BraintreeFragment fragment = BraintreeFragment.newInstance(mActivity, TOKENIZATION_KEY);
assertNotNull(fragment.getGraphQLHttpClient());
}
Aggregations