Search in sources :

Example 16 with TestConfigurationBuilder

use of com.braintreepayments.testutils.TestConfigurationBuilder in project braintree_android by braintree.

the class AndroidPayTest method setup.

@Before
public void setup() {
    mLatch = new CountDownLatch(1);
    mBaseConfiguration = new TestConfigurationBuilder().androidPay(new TestAndroidPayConfigurationBuilder().googleAuthorizationFingerprint("google-auth-fingerprint")).merchantId("android-pay-merchant-id");
}
Also used : TestAndroidPayConfigurationBuilder(com.braintreepayments.testutils.TestConfigurationBuilder.TestAndroidPayConfigurationBuilder) CountDownLatch(java.util.concurrent.CountDownLatch) TestConfigurationBuilder(com.braintreepayments.testutils.TestConfigurationBuilder) Before(org.junit.Before)

Example 17 with TestConfigurationBuilder

use of com.braintreepayments.testutils.TestConfigurationBuilder in project braintree_android by braintree.

the class AndroidPayTest method isReadyToPay_returnsFalseWhenAndroidPayIsNotEnabled.

@Test(timeout = 5000)
public void isReadyToPay_returnsFalseWhenAndroidPayIsNotEnabled() throws Exception {
    String configuration = new TestConfigurationBuilder().androidPay(new TestAndroidPayConfigurationBuilder().enabled(false)).build();
    BraintreeFragment fragment = getFragment(mActivityTestRule.getActivity(), TOKENIZATION_KEY, configuration);
    AndroidPay.isReadyToPay(fragment, new BraintreeResponseListener<Boolean>() {

        @Override
        public void onResponse(Boolean isReadyToPay) {
            assertFalse(isReadyToPay);
            mLatch.countDown();
        }
    });
    mLatch.await();
}
Also used : TestAndroidPayConfigurationBuilder(com.braintreepayments.testutils.TestConfigurationBuilder.TestAndroidPayConfigurationBuilder) TestConfigurationBuilder(com.braintreepayments.testutils.TestConfigurationBuilder) Test(org.junit.Test)

Example 18 with TestConfigurationBuilder

use of com.braintreepayments.testutils.TestConfigurationBuilder in project braintree_android by braintree.

the class DataCollectorTest method collectDeviceData_doesNotCollectKountDataIfKountDisabledInConfiguration.

@Test(timeout = 1000)
public void collectDeviceData_doesNotCollectKountDataIfKountDisabledInConfiguration() throws InterruptedException {
    BraintreeFragment fragment = getFragmentWithConfiguration(mActivity, new TestConfigurationBuilder().build());
    DataCollector.collectDeviceData(fragment, new BraintreeResponseListener<String>() {

        @Override
        public void onResponse(String deviceData) {
            try {
                JSONObject json = new JSONObject(deviceData);
                assertNull(Json.optString(json, "device_session_id", null));
                assertNull(Json.optString(json, "fraud_merchant_id", null));
                assertNotNull(json.getString("correlation_id"));
            } catch (JSONException e) {
                fail(e.getMessage());
            }
            mCountDownLatch.countDown();
        }
    });
    mCountDownLatch.await();
}
Also used : JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) TestConfigurationBuilder(com.braintreepayments.testutils.TestConfigurationBuilder) Test(org.junit.Test)

Example 19 with TestConfigurationBuilder

use of com.braintreepayments.testutils.TestConfigurationBuilder in project braintree_android by braintree.

the class DataCollectorTest method collectDeviceData_withListener.

@Test(timeout = 10000)
public void collectDeviceData_withListener() throws InterruptedException {
    String configuration = new TestConfigurationBuilder().kount(new TestKountConfigurationBuilder().kountMerchantId("500000")).build();
    BraintreeFragment fragment = getFragmentWithConfiguration(mActivity, configuration);
    DataCollector.collectDeviceData(fragment, new BraintreeResponseListener<String>() {

        @Override
        public void onResponse(String deviceData) {
            try {
                JSONObject json = new JSONObject(deviceData);
                assertFalse(TextUtils.isEmpty(json.getString("device_session_id")));
                assertEquals("500000", json.getString("fraud_merchant_id"));
                assertNotNull(json.getString("correlation_id"));
            } catch (JSONException e) {
                fail(e.getMessage());
            }
            mCountDownLatch.countDown();
        }
    });
    mCountDownLatch.await();
}
Also used : TestKountConfigurationBuilder(com.braintreepayments.testutils.TestConfigurationBuilder.TestKountConfigurationBuilder) JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) TestConfigurationBuilder(com.braintreepayments.testutils.TestConfigurationBuilder) Test(org.junit.Test)

Example 20 with TestConfigurationBuilder

use of com.braintreepayments.testutils.TestConfigurationBuilder in project braintree_android by braintree.

the class GooglePaymentTest method isReadyToPay_returnsFalseWhenAndroidPayIsNotEnabled.

@Test(timeout = 5000)
public void isReadyToPay_returnsFalseWhenAndroidPayIsNotEnabled() throws Exception {
    String configuration = new TestConfigurationBuilder().androidPay(new TestAndroidPayConfigurationBuilder().enabled(false)).build();
    BraintreeFragment fragment = getFragment(mActivityTestRule.getActivity(), TOKENIZATION_KEY, configuration);
    GooglePayment.isReadyToPay(fragment, new BraintreeResponseListener<Boolean>() {

        @Override
        public void onResponse(Boolean isReadyToPay) {
            assertFalse(isReadyToPay);
            mLatch.countDown();
        }
    });
    mLatch.await();
}
Also used : TestAndroidPayConfigurationBuilder(com.braintreepayments.testutils.TestConfigurationBuilder.TestAndroidPayConfigurationBuilder) TestConfigurationBuilder(com.braintreepayments.testutils.TestConfigurationBuilder) Test(org.junit.Test)

Aggregations

TestConfigurationBuilder (com.braintreepayments.testutils.TestConfigurationBuilder)39 Test (org.junit.Test)35 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)19 Configuration (com.braintreepayments.api.models.Configuration)12 JSONException (org.json.JSONException)9 JSONObject (org.json.JSONObject)9 Intent (android.content.Intent)8 CountDownLatch (java.util.concurrent.CountDownLatch)6 UnionPayCardBuilder (com.braintreepayments.api.models.UnionPayCardBuilder)5 TestBraintreeApiConfigurationBuilder (com.braintreepayments.testutils.TestConfigurationBuilder.TestBraintreeApiConfigurationBuilder)5 InvocationOnMock (org.mockito.invocation.InvocationOnMock)5 Answer (org.mockito.stubbing.Answer)5 Context (android.content.Context)4 InvalidArgumentException (com.braintreepayments.api.exceptions.InvalidArgumentException)4 CardBuilder (com.braintreepayments.api.models.CardBuilder)4 PaymentMethodNonce (com.braintreepayments.api.models.PaymentMethodNonce)4 TestAndroidPayConfigurationBuilder (com.braintreepayments.testutils.TestConfigurationBuilder.TestAndroidPayConfigurationBuilder)4 TestIdealConfigurationBuilder (com.braintreepayments.testutils.TestConfigurationBuilder.TestIdealConfigurationBuilder)4 TestKountConfigurationBuilder (com.braintreepayments.testutils.TestConfigurationBuilder.TestKountConfigurationBuilder)4 Before (org.junit.Before)4