Search in sources :

Example 1 with BraintreeGraphQLHttpClient

use of com.braintreepayments.api.internal.BraintreeGraphQLHttpClient in project braintree_android by braintree.

the class MockFragmentBuilder method build.

public BraintreeFragment build() {
    BraintreeFragment fragment = mock(BraintreeFragment.class);
    when(fragment.getApplicationContext()).thenReturn(mContext);
    when(fragment.getAuthorization()).thenReturn(mAuthorization);
    when(fragment.getSessionId()).thenReturn(mSessionId);
    when(fragment.getReturnUrlScheme()).thenReturn("com.braintreepayments.api.braintree");
    doAnswer(new Answer() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            ((ConfigurationListener) invocation.getArguments()[0]).onConfigurationFetched(mConfiguration);
            return null;
        }
    }).when(fragment).waitForConfiguration(any(ConfigurationListener.class));
    when(fragment.getConfiguration()).thenReturn(mConfiguration);
    BraintreeHttpClient httpClient = mock(BraintreeHttpClient.class);
    if (mSuccessResponse != null) {
        setupSuccessResponses(httpClient);
    } else if (mErrorResponse != null) {
        setupErrorResponses(httpClient);
    }
    when(fragment.getHttpClient()).thenReturn(httpClient);
    BraintreeGraphQLHttpClient graphQLHttpClient = mock(BraintreeGraphQLHttpClient.class);
    if (mGraphQLSuccessResponse != null) {
        setupGraphQLSuccessResponses(graphQLHttpClient);
    } else if (mGraphQLErrorResponse != null) {
        setupGraphQLErrorResponses(graphQLHttpClient);
    }
    when(fragment.getGraphQLHttpClient()).thenReturn(graphQLHttpClient);
    return fragment;
}
Also used : ConfigurationListener(com.braintreepayments.api.interfaces.ConfigurationListener) Answer(org.mockito.stubbing.Answer) Mockito.doAnswer(org.mockito.Mockito.doAnswer) BraintreeGraphQLHttpClient(com.braintreepayments.api.internal.BraintreeGraphQLHttpClient) InvocationOnMock(org.mockito.invocation.InvocationOnMock) BraintreeHttpClient(com.braintreepayments.api.internal.BraintreeHttpClient)

Example 2 with BraintreeGraphQLHttpClient

use of com.braintreepayments.api.internal.BraintreeGraphQLHttpClient in project braintree_android by braintree.

the class BraintreeFragment method setConfiguration.

protected void setConfiguration(Configuration configuration) {
    mConfiguration = configuration;
    getHttpClient().setBaseUrl(configuration.getClientApiUrl());
    if (configuration.getGraphQL().isEnabled()) {
        mGraphQLHttpClient = new BraintreeGraphQLHttpClient(configuration.getGraphQL().getUrl(), mAuthorization.getBearer());
    }
}
Also used : BraintreeGraphQLHttpClient(com.braintreepayments.api.internal.BraintreeGraphQLHttpClient)

Aggregations

BraintreeGraphQLHttpClient (com.braintreepayments.api.internal.BraintreeGraphQLHttpClient)2 ConfigurationListener (com.braintreepayments.api.interfaces.ConfigurationListener)1 BraintreeHttpClient (com.braintreepayments.api.internal.BraintreeHttpClient)1 Mockito.doAnswer (org.mockito.Mockito.doAnswer)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 Answer (org.mockito.stubbing.Answer)1