use of com.braintreepayments.testutils.TestConfigurationBuilder in project braintree_android by braintree.
the class PayPalUnitTest method setup.
@Before
public void setup() throws Exception {
spy(PayPal.class);
doReturn(true).when(PayPal.class, "isManifestValid", any(Context.class));
spy(Recipe.class);
doReturn(true).when(Recipe.class, "isValidBrowserTarget", any(Context.class), anyString(), anyString());
Authorization authorization = mock(Authorization.class);
when(authorization.getBearer()).thenReturn("authorization");
when(authorization.toString()).thenReturn("authorization");
Configuration configuration = new TestConfigurationBuilder().withAnalytics().paypal(new TestPayPalConfigurationBuilder(true).environment("offline").billingAgreementsEnabled(false)).buildConfiguration();
mMockFragmentBuilder = new MockFragmentBuilder().authorization(authorization).configuration(configuration);
}
use of com.braintreepayments.testutils.TestConfigurationBuilder 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.testutils.TestConfigurationBuilder in project braintree_android by braintree.
the class TokenizationClientUnitTest method tokenize_sendGraphQLAnalyticsEventWhenEnabled.
@Test
public void tokenize_sendGraphQLAnalyticsEventWhenEnabled() {
BraintreeFragment fragment = new MockFragmentBuilder().configuration(new TestConfigurationBuilder().graphQL().build()).build();
CardBuilder cardBuilder = new CardBuilder();
TokenizationClient.tokenize(fragment, cardBuilder, null);
verify(fragment).sendAnalyticsEvent("card.graphql.tokenization.started");
}
use of com.braintreepayments.testutils.TestConfigurationBuilder 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.testutils.TestConfigurationBuilder in project braintree_android by braintree.
the class TokenizationClientUnitTest method tokenize_tokenizesCardsWithGraphQLWhenEnabled.
@Test
public void tokenize_tokenizesCardsWithGraphQLWhenEnabled() throws BraintreeException {
BraintreeFragment fragment = new MockFragmentBuilder().configuration(new TestConfigurationBuilder().graphQL().build()).build();
CardBuilder cardBuilder = new CardBuilder();
TokenizationClient.tokenize(fragment, cardBuilder, null);
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
verifyZeroInteractions(fragment.getHttpClient());
verify(fragment.getGraphQLHttpClient()).post(captor.capture(), any(HttpResponseCallback.class));
assertEquals(cardBuilder.buildGraphQL(fragment.getApplicationContext(), fragment.getAuthorization()), captor.getValue());
}
Aggregations