use of com.braintreepayments.api.models.Configuration in project braintree_android by braintree.
the class BraintreeFragmentUnitTest method waitForConfiguration_postsCallbackAfterConfigurationIsReceived.
@Test
public void waitForConfiguration_postsCallbackAfterConfigurationIsReceived() throws JSONException, InvalidArgumentException {
final Configuration configuration = Configuration.fromJson(stringFromFixture("configuration/configuration.json"));
mockConfigurationManager(configuration);
BraintreeFragment fragment = BraintreeFragment.newInstance(mActivity, TOKENIZATION_KEY);
fragment.waitForConfiguration(new ConfigurationListener() {
@Override
public void onConfigurationFetched(Configuration returnedConfiguration) {
assertEquals(configuration, returnedConfiguration);
mCalled.set(true);
}
});
assertTrue(mCalled.get());
}
use of com.braintreepayments.api.models.Configuration in project braintree_android by braintree.
the class BraintreeFragmentUnitTest method waitForConfiguration_doesNotPostCallbackWhenNotAttached.
@Test
public void waitForConfiguration_doesNotPostCallbackWhenNotAttached() throws JSONException, InvalidArgumentException {
final Configuration configuration = Configuration.fromJson(stringFromFixture("configuration/configuration.json"));
mockConfigurationManager(configuration);
BraintreeFragment fragment = BraintreeFragment.newInstance(mActivity, TOKENIZATION_KEY);
mActivity.getFragmentManager().beginTransaction().detach(fragment).commit();
mActivity.getFragmentManager().executePendingTransactions();
fragment.waitForConfiguration(new ConfigurationListener() {
@Override
public void onConfigurationFetched(Configuration returnedConfiguration) {
fail("onConfigurationFetched was called");
}
});
}
use of com.braintreepayments.api.models.Configuration in project braintree_android by braintree.
the class BraintreeFragmentUnitTest method onResume_postsConfigurationToCallbackForNewActivity.
@Test
public void onResume_postsConfigurationToCallbackForNewActivity() throws InvalidArgumentException {
Configuration configuration = new TestConfigurationBuilder().buildConfiguration();
mockConfigurationManager(configuration);
UnitTestListenerActivity activity = Robolectric.setupActivity(UnitTestListenerActivity.class);
BraintreeFragment fragment = BraintreeFragment.newInstance(activity, TOKENIZATION_KEY);
fragment.onAttach(null);
fragment.onResume();
assertEquals(2, activity.configurations.size());
assertEquals(configuration, activity.configurations.get(0));
assertEquals(configuration, activity.configurations.get(1));
}
use of com.braintreepayments.api.models.Configuration in project braintree_android by braintree.
the class BraintreeFragmentUnitTest method sendEvent_addsEventToDatabase.
@Test
public void sendEvent_addsEventToDatabase() throws InvalidArgumentException {
Configuration configuration = new TestConfigurationBuilder().withAnalytics().buildConfiguration();
BraintreeFragment fragment = spy(BraintreeFragment.newInstance(mActivity, TOKENIZATION_KEY));
when(fragment.getConfiguration()).thenReturn(configuration);
fragment.sendAnalyticsEvent("test.event");
verifyAnalyticsEvent(mActivity, "test.event");
}
use of com.braintreepayments.api.models.Configuration in project braintree_android by braintree.
the class BraintreeFragmentUnitTest method onCreate_restoresConfigurationAndHttpClients.
@Test
public void onCreate_restoresConfigurationAndHttpClients() throws Exception {
Configuration configuration = new TestConfigurationBuilder().graphQL().buildConfiguration();
mockConfigurationManager(configuration);
BraintreeFragment fragment = BraintreeFragment.newInstance(mActivity, TOKENIZATION_KEY);
Bundle bundle = new Bundle();
fragment.onSaveInstanceState(bundle);
setField("mConfiguration", fragment, null);
fragment.mHttpClient = null;
fragment.onCreate(bundle);
assertNotNull(fragment.getConfiguration());
assertNotNull(fragment.mHttpClient);
assertNotNull(fragment.mGraphQLHttpClient);
assertEquals("client_api_url", getField("mBaseUrl", fragment.mHttpClient));
}
Aggregations