本文整理汇总了Java中com.braintreepayments.api.interfaces.BraintreeResponseListener类的典型用法代码示例。如果您正苦于以下问题:Java BraintreeResponseListener类的具体用法?Java BraintreeResponseListener怎么用?Java BraintreeResponseListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BraintreeResponseListener类属于com.braintreepayments.api.interfaces包,在下文中一共展示了BraintreeResponseListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: queueTask
import com.braintreepayments.api.interfaces.BraintreeResponseListener; //导入依赖的package包/类
private void queueTask(final DatabaseTask task) {
task.setFinishedCallback(new BraintreeResponseListener<Void>() {
@Override
public void onResponse(Void aVoid) {
synchronized (mTaskSet) {
mTaskSet.remove(task);
}
}
});
synchronized (mTaskSet) {
mTaskSet.add(task);
}
task.execute();
}
示例2: collectDeviceData_withListener
import com.braintreepayments.api.interfaces.BraintreeResponseListener; //导入依赖的package包/类
@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();
}
示例3: collectDeviceData_withListener_usesDirectMerchantId
import com.braintreepayments.api.interfaces.BraintreeResponseListener; //导入依赖的package包/类
@Test(timeout = 10000)
public void collectDeviceData_withListener_usesDirectMerchantId() throws InterruptedException {
String configuration = new TestConfigurationBuilder()
.kount(new TestKountConfigurationBuilder()
.kountMerchantId("600000"))
.build();
BraintreeFragment fragment = getFragmentWithConfiguration(mActivity, configuration);
DataCollector.collectDeviceData(fragment, "600001", new BraintreeResponseListener<String>() {
@Override
public void onResponse(String deviceData) {
try {
JSONObject json = new JSONObject(deviceData);
assertFalse(TextUtils.isEmpty(json.getString("device_session_id")));
assertEquals("600001", json.getString("fraud_merchant_id"));
assertNotNull(json.getString("correlation_id"));
} catch (JSONException e) {
fail(e.getMessage());
}
mCountDownLatch.countDown();
}
});
mCountDownLatch.await();
}
示例4: collectDeviceData_doesNotCollectKountDataIfKountDisabledInConfiguration
import com.braintreepayments.api.interfaces.BraintreeResponseListener; //导入依赖的package包/类
@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();
}
示例5: fetchIssuingBanks_returnsIssuingBanks
import com.braintreepayments.api.interfaces.BraintreeResponseListener; //导入依赖的package包/类
@Test(timeout = 10000)
public void fetchIssuingBanks_returnsIssuingBanks() throws InterruptedException {
Ideal.fetchIssuingBanks(mBraintreeFragment, new BraintreeResponseListener<List<IdealBank>>() {
@Override
public void onResponse(List<IdealBank> idealBanks) {
assertFalse(idealBanks.isEmpty());
assertFalse(TextUtils.isEmpty(idealBanks.get(0).getId()));
assertFalse(TextUtils.isEmpty(idealBanks.get(0).getName()));
assertFalse(TextUtils.isEmpty(idealBanks.get(0).getImageUri()));
mCountDownLatch.countDown();
}
});
mBraintreeFragment.addListener(new BraintreeErrorListener() {
@Override
public void onError(Exception error) {
fail(error.getMessage());
}
});
mCountDownLatch.await();
}
示例6: isFetchingConfiguration_isTrueWhenFetchingConfiguration
import com.braintreepayments.api.interfaces.BraintreeResponseListener; //导入依赖的package包/类
@Test
public void isFetchingConfiguration_isTrueWhenFetchingConfiguration() throws InterruptedException {
when(mBraintreeFragment.getHttpClient()).thenReturn(new BraintreeHttpClient(mTokenizationKey) {
@Override
public void get(String path, HttpResponseCallback callback) {
mThreadPool.submit(new Runnable() {
@Override
public void run() {
SystemClock.sleep(1000);
}
});
}
});
ConfigurationManager.getConfiguration(mBraintreeFragment, new ConfigurationListener() {
@Override
public void onConfigurationFetched(Configuration configuration) {}
}, new BraintreeResponseListener<Exception>() {
@Override
public void onResponse(Exception e) {}
});
assertTrue(ConfigurationManager.isFetchingConfiguration());
}
示例7: isFetchingConfiguration_isFalseInSuccessCallback
import com.braintreepayments.api.interfaces.BraintreeResponseListener; //导入依赖的package包/类
@Test(timeout = 1000)
public void isFetchingConfiguration_isFalseInSuccessCallback() throws InterruptedException {
stubConfigurationFromGateway(stringFromFixture("configuration/with_analytics.json"));
ConfigurationManager.getConfiguration(mBraintreeFragment, new ConfigurationListener() {
@Override
public void onConfigurationFetched(Configuration configuration) {
assertFalse(ConfigurationManager.isFetchingConfiguration());
mCountDownLatch.countDown();
}
}, new BraintreeResponseListener<Exception>() {
@Override
public void onResponse(Exception e) {
fail(e.getMessage());
}
});
mCountDownLatch.await();
}
示例8: isFetchingConfiguration_isFalseInErrorCallback
import com.braintreepayments.api.interfaces.BraintreeResponseListener; //导入依赖的package包/类
@Test(timeout = 1000)
public void isFetchingConfiguration_isFalseInErrorCallback() throws InterruptedException {
when(mBraintreeFragment.getHttpClient()).thenReturn(new BraintreeHttpClient(mTokenizationKey) {
@Override
public void get(String path, HttpResponseCallback callback) {
if (path.contains(mTokenizationKey.getConfigUrl())) {
callback.failure(new UnexpectedException("Something bad happened"));
}
}
});
ConfigurationManager.getConfiguration(mBraintreeFragment, new ConfigurationListener() {
@Override
public void onConfigurationFetched(Configuration configuration) {
fail("Success listener should not have been called for bad request");
}
}, new BraintreeResponseListener<Exception>() {
@Override
public void onResponse(Exception e) {
assertFalse(ConfigurationManager.isFetchingConfiguration());
mCountDownLatch.countDown();
}
});
mCountDownLatch.await();
}
示例9: getConfiguration_getsConfigFromCacheWhenTimeoutHasNotExpired
import com.braintreepayments.api.interfaces.BraintreeResponseListener; //导入依赖的package包/类
@Test(timeout = 1000)
public void getConfiguration_getsConfigFromCacheWhenTimeoutHasNotExpired() throws InterruptedException {
writeMockConfiguration(RuntimeEnvironment.application, mTokenizationKey.getConfigUrl(),
mTokenizationKey.getBearer(), stringFromFixture("configuration/configuration.json"),
System.currentTimeMillis());
ConfigurationManager.getConfiguration(mBraintreeFragment, new ConfigurationListener() {
@Override
public void onConfigurationFetched(Configuration configuration) {
assertEquals(stringFromFixture("configuration/configuration.json"), configuration.toJson());
mCountDownLatch.countDown();
}
}, new BraintreeResponseListener<Exception>() {
@Override
public void onResponse(Exception e) {
fail(e.getMessage());
}
});
mCountDownLatch.await();
}
示例10: getConfiguration_getsConfigFromGatewayWhenTimeoutExpired
import com.braintreepayments.api.interfaces.BraintreeResponseListener; //导入依赖的package包/类
@Test(timeout = 1000)
public void getConfiguration_getsConfigFromGatewayWhenTimeoutExpired() throws InterruptedException {
writeMockConfiguration(RuntimeEnvironment.application, mTokenizationKey.getConfigUrl(),
mTokenizationKey.getBearer(), stringFromFixture("configuration/configuration.json"),
System.currentTimeMillis() - (ConfigurationManager.TTL + 1));
stubConfigurationFromGateway(stringFromFixture("configuration/with_analytics.json"));
ConfigurationManager.getConfiguration(mBraintreeFragment, new ConfigurationListener() {
@Override
public void onConfigurationFetched(Configuration configuration) {
assertEquals(stringFromFixture("configuration/with_analytics.json"),
configuration.toJson());
mCountDownLatch.countDown();
}
}, new BraintreeResponseListener<Exception>() {
@Override
public void onResponse(Exception e) {
fail(e.getMessage());
}
});
mCountDownLatch.await();
}
示例11: getConfiguration_fetchesConfigFromGatewayWhenCacheIsEmpty
import com.braintreepayments.api.interfaces.BraintreeResponseListener; //导入依赖的package包/类
@Test(timeout = 1000)
public void getConfiguration_fetchesConfigFromGatewayWhenCacheIsEmpty() throws InterruptedException {
stubConfigurationFromGateway(stringFromFixture("configuration/with_analytics.json"));
ConfigurationManager.getConfiguration(mBraintreeFragment, new ConfigurationListener() {
@Override
public void onConfigurationFetched(Configuration configuration) {
assertEquals(stringFromFixture("configuration/with_analytics.json"),
configuration.toJson());
mCountDownLatch.countDown();
}
}, new BraintreeResponseListener<Exception>() {
@Override
public void onResponse(Exception e) {
fail(e.getMessage());
}
});
mCountDownLatch.await();
}
示例12: getConfiguration_fetchesConfigurationFromGatewayWhenCachedConfigIsInvalid
import com.braintreepayments.api.interfaces.BraintreeResponseListener; //导入依赖的package包/类
@Test(timeout = 1000)
public void getConfiguration_fetchesConfigurationFromGatewayWhenCachedConfigIsInvalid()
throws InterruptedException {
writeMockConfiguration(RuntimeEnvironment.application, mTokenizationKey.getConfigUrl(),
mTokenizationKey.getBearer(), "not a config");
stubConfigurationFromGateway(stringFromFixture("configuration/configuration.json"));
ConfigurationManager.getConfiguration(mBraintreeFragment, new ConfigurationListener() {
@Override
public void onConfigurationFetched(Configuration configuration) {
assertEquals(stringFromFixture("configuration/configuration.json"), configuration.toJson());
mCountDownLatch.countDown();
}
}, new BraintreeResponseListener<Exception>() {
@Override
public void onResponse(Exception e) {
fail(e.getMessage());
}
});
mCountDownLatch.await();
}
示例13: getConfiguration_takesClientTokenIntoAccountForCache
import com.braintreepayments.api.interfaces.BraintreeResponseListener; //导入依赖的package包/类
@Test(timeout = 1000)
public void getConfiguration_takesClientTokenIntoAccountForCache()
throws InvalidArgumentException, InterruptedException {
ClientToken clientToken = (ClientToken) Authorization.fromString(
stringFromFixture("client_token_with_authorization_fingerprint_options.json"));
when(mBraintreeFragment.getAuthorization()).thenReturn(clientToken);
writeMockConfiguration(RuntimeEnvironment.application, clientToken.getConfigUrl(),
clientToken.getAuthorizationFingerprint(), stringFromFixture("configuration/configuration.json"),
System.currentTimeMillis());
ConfigurationManager.getConfiguration(mBraintreeFragment, new ConfigurationListener() {
@Override
public void onConfigurationFetched(Configuration configuration) {
assertEquals(stringFromFixture("configuration/configuration.json"), configuration.toJson());
mCountDownLatch.countDown();
}
}, new BraintreeResponseListener<Exception>() {
@Override
public void onResponse(Exception e) {
fail(e.getMessage());
}
});
mCountDownLatch.await();
}
示例14: waitForConfiguration_retriesIfConfigurationIsNull
import com.braintreepayments.api.interfaces.BraintreeResponseListener; //导入依赖的package包/类
@Test
public void waitForConfiguration_retriesIfConfigurationIsNull() throws InvalidArgumentException {
mockConfigurationManager(new Exception());
BraintreeFragment fragment = BraintreeFragment.newInstance(mActivity, TOKENIZATION_KEY);
fragment.waitForConfiguration(new ConfigurationListener() {
@Override
public void onConfigurationFetched(Configuration configuration) {}
});
// Request 1: BraintreeFragment sends a "set up" analytics event when it's instantiated
// Request 2: BraintreeFragment calls #fetchConfiguration in BraintreeFragment#onCreate
// Request 3: fragment.waitForConfiguration called in this test
verifyStatic(times(3));
ConfigurationManager.getConfiguration(eq(fragment), any(ConfigurationListener.class),
any(BraintreeResponseListener.class));
}
示例15: fetchIssuingBanks_postsConfigurationExceptionWhenBraintreeApiNotEnabled
import com.braintreepayments.api.interfaces.BraintreeResponseListener; //导入依赖的package包/类
@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());
}