use of com.paypal.android.sdk.onetouch.core.CheckoutRequest in project braintree_android by braintree.
the class PayPalRequestUnitTest method getCheckoutRequest_containsCorrectValues.
@Test
public void getCheckoutRequest_containsCorrectValues() throws JSONException {
Configuration configuration = Configuration.fromJson(stringFromFixture("configuration/with_offline_paypal.json"));
BraintreeFragment fragment = mMockFragmentBuilder.configuration(configuration).build();
CheckoutRequest request = PayPal.getCheckoutRequest(fragment, "https://paypal.com/?token=pairingId");
assertEquals(EnvironmentManager.MOCK, request.getEnvironment());
assertEquals("com.braintreepayments.api.braintree://onetouch/v1/cancel", request.getCancelUrl());
assertEquals("com.braintreepayments.api.braintree://onetouch/v1/success", request.getSuccessUrl());
assertEquals("paypal_client_id", request.getClientId());
assertEquals("pairingId", request.getPairingId());
}
use of com.paypal.android.sdk.onetouch.core.CheckoutRequest in project braintree_android by braintree.
the class BrowserSwitchHelperUnitTest method handleBrowserResponse_sendsEventForReturn.
@Test
public void handleBrowserResponse_sendsEventForReturn() {
Result expectedResult = new Result("test", ResponseType.web, new JSONObject(), "");
CheckoutRequest request = mock(CheckoutRequest.class);
when(request.parseBrowserResponse(any(ContextInspector.class), any(Uri.class))).thenReturn(expectedResult);
BrowserSwitchHelper.parseBrowserSwitchResponse(mContextInspector, request, mock(Uri.class));
verify(request).trackFpti(any(Context.class), eq(TrackingPoint.Return), isNull(Protocol.class));
}
use of com.paypal.android.sdk.onetouch.core.CheckoutRequest in project braintree_android by braintree.
the class BrowserSwitchHelperUnitTest method handleBrowserResponse_parsesResponse.
@Test
public void handleBrowserResponse_parsesResponse() {
Result expectedResult = new Result();
CheckoutRequest request = mock(CheckoutRequest.class);
when(request.parseBrowserResponse(any(ContextInspector.class), any(Uri.class))).thenReturn(expectedResult);
Result result = BrowserSwitchHelper.parseBrowserSwitchResponse(mContextInspector, request, mock(Uri.class));
assertEquals(expectedResult, result);
}
use of com.paypal.android.sdk.onetouch.core.CheckoutRequest in project braintree_android by braintree.
the class BrowserSwitchHelperUnitTest method handleBrowserResponse_sendsEventForError.
@Test
public void handleBrowserResponse_sendsEventForError() {
Result expectedResult = new Result(new Exception());
CheckoutRequest request = mock(CheckoutRequest.class);
when(request.parseBrowserResponse(any(ContextInspector.class), any(Uri.class))).thenReturn(expectedResult);
BrowserSwitchHelper.parseBrowserSwitchResponse(mContextInspector, request, mock(Uri.class));
verify(request).trackFpti(any(Context.class), eq(TrackingPoint.Error), isNull(Protocol.class));
}
use of com.paypal.android.sdk.onetouch.core.CheckoutRequest in project braintree_android by braintree.
the class BrowserSwitchHelperUnitTest method getBrowserIntent_returnsIntent.
@Test
public void getBrowserIntent_returnsIntent() throws Exception {
CheckoutRequest request = spy(new CheckoutRequest());
doNothing().when(request).trackFpti(any(Context.class), any(TrackingPoint.class), any(Protocol.class));
request.approvalURL("https://paypal.com/?token=test-token-key");
Intent intent = BrowserSwitchHelper.getBrowserSwitchIntent(mContextInspector, mConfigManager, request);
verify(request).trackFpti(any(Context.class), eq(TrackingPoint.SwitchToBrowser), any(Protocol.class));
assertEquals(Intent.ACTION_VIEW, intent.getAction());
assertEquals("https://paypal.com/?token=test-token-key", intent.getData().toString());
assertEquals("com.android.chrome", intent.getPackage());
}
Aggregations