use of com.braintreepayments.api.models.PaymentMethodNonce in project braintree_android by braintree.
the class TokenizationClientUnitTest method tokenize_sendGraphQLAnalyticsEventOnFailure.
@Test
public void tokenize_sendGraphQLAnalyticsEventOnFailure() {
BraintreeFragment fragment = new MockFragmentBuilder().configuration(new TestConfigurationBuilder().graphQL().build()).graphQLErrorResponse(ErrorWithResponse.fromGraphQLJson(stringFromFixture("errors/graphql/credit_card_error.json"))).build();
CardBuilder cardBuilder = new CardBuilder();
TokenizationClient.tokenize(fragment, cardBuilder, new PaymentMethodNonceCallback() {
@Override
public void success(PaymentMethodNonce paymentMethodNonce) {
}
@Override
public void failure(Exception exception) {
}
});
verify(fragment).sendAnalyticsEvent("card.graphql.tokenization.failure");
}
use of com.braintreepayments.api.models.PaymentMethodNonce in project braintree_android by braintree.
the class TokenizationClientUnitTest method tokenize_sendGraphQLAnalyticsEventOnSuccess.
@Test
public void tokenize_sendGraphQLAnalyticsEventOnSuccess() {
BraintreeFragment fragment = new MockFragmentBuilder().configuration(new TestConfigurationBuilder().graphQL().build()).graphQLSuccessResponse(stringFromFixture("response/graphql/credit_card.json")).build();
CardBuilder cardBuilder = new CardBuilder();
TokenizationClient.tokenize(fragment, cardBuilder, new PaymentMethodNonceCallback() {
@Override
public void success(PaymentMethodNonce paymentMethodNonce) {
}
@Override
public void failure(Exception exception) {
}
});
verify(fragment).sendAnalyticsEvent("card.graphql.tokenization.success");
}
use of com.braintreepayments.api.models.PaymentMethodNonce in project braintree_android by braintree.
the class BraintreeFragmentUnitTest method postCallback_postsPaymentMethodNonceToListener.
@Test
public void postCallback_postsPaymentMethodNonceToListener() throws InvalidArgumentException {
BraintreeFragment fragment = BraintreeFragment.newInstance(mActivity, TOKENIZATION_KEY);
final AtomicBoolean wasCalled = new AtomicBoolean(false);
fragment.addListener(new PaymentMethodNonceCreatedListener() {
@Override
public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
assertTrue(paymentMethodNonce instanceof CardNonce);
wasCalled.set(true);
}
});
fragment.postCallback(new CardNonce());
assertTrue(wasCalled.get());
}
use of com.braintreepayments.api.models.PaymentMethodNonce in project braintree_android by braintree.
the class BraintreeFragmentUnitTest method addListener_flushesPaymentMethodNonceCreatedCallback.
@Test
public void addListener_flushesPaymentMethodNonceCreatedCallback() throws InvalidArgumentException {
BraintreeFragment fragment = BraintreeFragment.newInstance(mActivity, TOKENIZATION_KEY);
fragment.postCallback(new CardNonce());
fragment.addListener(new PaymentMethodNonceCreatedListener() {
@Override
public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
mCalled.set(true);
}
});
assertTrue(mCalled.get());
}
use of com.braintreepayments.api.models.PaymentMethodNonce in project braintree_android by braintree.
the class BraintreeFragmentUnitTest method removeListener_noPaymentMethodNonceCreatedReceived.
@Test
public void removeListener_noPaymentMethodNonceCreatedReceived() throws InvalidArgumentException {
BraintreeFragment fragment = BraintreeFragment.newInstance(mActivity, TOKENIZATION_KEY);
PaymentMethodNonceCreatedListener listener = new PaymentMethodNonceCreatedListener() {
@Override
public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
fail("Listener was called");
}
};
fragment.addListener(listener);
fragment.removeListener(listener);
fragment.postCallback(new CardNonce());
}
Aggregations