use of com.braintreepayments.testutils.TestConfigurationBuilder in project braintree_android by braintree.
the class IdealUnitTest method setUp.
@Before
public void setUp() throws InvalidArgumentException {
mConfiguration = new TestConfigurationBuilder().assetsUrl("http://assets.example.com").ideal(new TestIdealConfigurationBuilder().routeId("some-route-id").assetsUrl("http://assets.example.com")).braintreeApi(new TestBraintreeApiConfigurationBuilder().accessToken("access-token").url("http://api.braintree.com")).buildConfiguration();
mBraintreeFragment = getMockFragment(stringFromFixture("client_token.json"), mConfiguration);
mMockApiClient = mock(BraintreeApiHttpClient.class);
when(mBraintreeFragment.getBraintreeApiHttpClient()).thenReturn(mMockApiClient);
}
use of com.braintreepayments.testutils.TestConfigurationBuilder in project braintree_android by braintree.
the class IdealUnitTest method fetchIssuingBanks_postsConfigurationExceptionWhenBraintreeApiNotEnabled.
@Test
public void fetchIssuingBanks_postsConfigurationExceptionWhenBraintreeApiNotEnabled() throws InvalidArgumentException, InterruptedException {
Configuration configuration = new TestConfigurationBuilder().ideal(new TestIdealConfigurationBuilder().routeId("some-route-id")).buildConfiguration();
BraintreeFragment fragment = getMockFragment(stringFromFixture("client_token.json"), configuration);
Ideal.fetchIssuingBanks(fragment, new BraintreeResponseListener<List<IdealBank>>() {
@Override
public void onResponse(List<IdealBank> idealBanks) {
fail("Success listener called");
}
});
ArgumentCaptor<Exception> captor = ArgumentCaptor.forClass(Exception.class);
verify(fragment).postCallback(captor.capture());
Exception e = captor.getValue();
assertEquals("Your access is restricted and cannot use this part of the Braintree API.", e.getMessage());
}
use of com.braintreepayments.testutils.TestConfigurationBuilder in project braintree_android by braintree.
the class TokenizationClientUnitTest method tokenize_tokenizesNonCardPaymentMethodsWithRestWhenGraphQLIsEnabled.
@Test
public void tokenize_tokenizesNonCardPaymentMethodsWithRestWhenGraphQLIsEnabled() {
BraintreeFragment fragment = new MockFragmentBuilder().configuration(new TestConfigurationBuilder().graphQL().build()).build();
TokenizationClient.tokenize(fragment, new PayPalAccountBuilder(), null);
TokenizationClient.tokenize(fragment, new UnionPayCardBuilder(), null);
TokenizationClient.tokenize(fragment, new VenmoAccountBuilder(), null);
verifyZeroInteractions(fragment.getGraphQLHttpClient());
}
use of com.braintreepayments.testutils.TestConfigurationBuilder in project braintree_android by braintree.
the class IdealRequestUnitTest method build_setsAllParams.
@Test
public void build_setsAllParams() throws NoSuchFieldException, IllegalAccessException, JSONException {
Configuration configuration = new TestConfigurationBuilder().assetsUrl("http://assets.example.com").buildConfiguration();
List<IdealBank> banks = IdealBank.fromJson(configuration, stringFromFixture("payment_methods/ideal_issuing_banks.json"));
IdealRequest builder = new IdealRequest().issuerId(banks.get(0).getId()).orderId("some-order-id").amount("1.00").currency("USD");
JSONObject json = new JSONObject(builder.build("http://example.com", "some-route-id"));
assertEquals("some-route-id", json.getString("route_id"));
assertEquals("some-order-id", json.getString("order_id"));
assertEquals("ABNANL2A", json.getString("issuer"));
assertEquals("1.00", json.getString("amount"));
assertEquals("USD", json.getString("currency"));
assertEquals("http://example.com", json.getString("redirect_url"));
}
use of com.braintreepayments.testutils.TestConfigurationBuilder 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));
}
Aggregations