use of com.braintreepayments.api.models.Configuration in project braintree_android by braintree.
the class ConfigurationManagerUnitTest method getConfiguration_getsConfigFromGatewayWhenTimeoutExpired.
@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();
}
use of com.braintreepayments.api.models.Configuration in project braintree_android by braintree.
the class ConfigurationManagerUnitTest method isFetchingConfiguration_isFalseInSuccessCallback.
@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();
}
use of com.braintreepayments.api.models.Configuration in project braintree_android by braintree.
the class ConfigurationManagerUnitTest method getConfiguration_fetchesConfigFromGatewayWhenCacheIsEmpty.
@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();
}
use of com.braintreepayments.api.models.Configuration in project braintree_android by braintree.
the class VenmoUnitTest method performAppSwitch_whenProfileIdIsNull_appSwitchesWithMerchantId.
@Test
public void performAppSwitch_whenProfileIdIsNull_appSwitchesWithMerchantId() throws InvalidArgumentException, JSONException {
Configuration configuration = getConfigurationFromFixture();
Authorization clientToken = Authorization.fromString(stringFromFixture("base_64_client_token.txt"));
disableSignatureVerification();
BraintreeFragment fragment = new MockFragmentBuilder().context(VenmoInstalledContextFactory.venmoInstalledContext(true, RuntimeEnvironment.application)).authorization(clientToken).configuration(configuration).build();
when(fragment.getSessionId()).thenReturn("a-session-id");
when(fragment.getIntegrationType()).thenReturn("custom");
Venmo.authorizeAccount(fragment, false, null);
ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
verify(fragment).startActivityForResult(captor.capture(), eq(BraintreeRequestCodes.VENMO));
assertEquals("com.venmo/com.venmo.controller.SetupMerchantActivity", captor.getValue().getComponent().flattenToString());
Bundle extras = captor.getValue().getExtras();
assertEquals("merchant-id", extras.getString(Venmo.EXTRA_MERCHANT_ID));
assertEquals("access-token", extras.getString(Venmo.EXTRA_ACCESS_TOKEN));
}
use of com.braintreepayments.api.models.Configuration in project braintree_android by braintree.
the class VenmoUnitTest method performAppSwitch_persistsIfVaultFalse.
@Test
public void performAppSwitch_persistsIfVaultFalse() throws InvalidArgumentException {
Configuration configuration = getConfigurationFromFixture();
Authorization clientToken = Authorization.fromString(stringFromFixture("base_64_client_token.txt"));
disableSignatureVerification();
BraintreeFragment fragment = new MockFragmentBuilder().context(VenmoInstalledContextFactory.venmoInstalledContext(true, RuntimeEnvironment.application)).configuration(configuration).authorization(clientToken).build();
Venmo.authorizeAccount(fragment, false);
SharedPreferences prefs = SharedPreferencesHelper.getSharedPreferences(fragment.getApplicationContext());
assertFalse(prefs.getBoolean("com.braintreepayments.api.Venmo.VAULT_VENMO_KEY", true));
}
Aggregations