use of com.paypal.android.sdk.onetouch.core.Result 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.Result in project braintree_android by braintree.
the class BrowserSwitchHelperUnitTest method handleBrowserResponse_sendsEventForCancel.
@Test
public void handleBrowserResponse_sendsEventForCancel() {
Result expectedResult = new Result();
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.Cancel), isNull(Protocol.class));
}
use of com.paypal.android.sdk.onetouch.core.Result in project braintree_android by braintree.
the class AppSwitchHelperUnitTest method parseAppSwitchResponse_returnsErrorWhenResponseCouldNotBeParsed.
@Test
public void parseAppSwitchResponse_returnsErrorWhenResponseCouldNotBeParsed() {
Request request = mock(AuthorizationRequest.class);
when(request.validateV1V2Response(any(ContextInspector.class), any(Bundle.class))).thenReturn(false);
Intent intent = new Intent().putExtra("braintree", "nonce");
Result result = AppSwitchHelper.parseAppSwitchResponse(mContextInspector, request, intent);
verify(request).trackFpti(any(Context.class), eq(TrackingPoint.Error), isNull(Protocol.class));
assertTrue(result.getError() instanceof ResponseParsingException);
assertEquals("invalid wallet response", result.getError().getMessage());
}
use of com.paypal.android.sdk.onetouch.core.Result in project braintree_android by braintree.
the class AppSwitchHelperUnitTest method parseAppSwitchResponse_parsesErrorForErrorResponses.
@Test
public void parseAppSwitchResponse_parsesErrorForErrorResponses() {
Request request = mock(AuthorizationRequest.class);
when(request.validateV1V2Response(any(ContextInspector.class), any(Bundle.class))).thenReturn(false);
Intent intent = new Intent().putExtra("error", "there was an error");
Result result = AppSwitchHelper.parseAppSwitchResponse(mContextInspector, request, intent);
verify(request).trackFpti(any(Context.class), eq(TrackingPoint.Error), isNull(Protocol.class));
assertTrue(result.getError() instanceof WalletSwitchException);
assertEquals("there was an error", result.getError().getMessage());
}
use of com.paypal.android.sdk.onetouch.core.Result in project braintree_android by braintree.
the class AppSwitchHelperUnitTest method parseAppSwitchResponse_parsesWebResponseAndReturnsResult.
@Test
public void parseAppSwitchResponse_parsesWebResponseAndReturnsResult() throws JSONException {
Request request = mock(AuthorizationRequest.class);
when(request.validateV1V2Response(any(ContextInspector.class), any(Bundle.class))).thenReturn(true);
Intent intent = new Intent().putExtra("environment", "test").putExtra("response_type", "web").putExtra("webURL", "web-url");
Result result = AppSwitchHelper.parseAppSwitchResponse(mContextInspector, request, intent);
verify(request).trackFpti(any(Context.class), eq(TrackingPoint.Return), isNull(Protocol.class));
assertEquals(ResultType.Success, result.getResultType());
assertEquals(ResponseType.web.name(), result.getResponse().getString("response_type"));
JSONObject client = result.getResponse().getJSONObject("client");
assertEquals("test", client.getString("environment"));
assertEquals("web-url", result.getResponse().getJSONObject("response").getString("webURL"));
}
Aggregations