use of com.paypal.android.sdk.onetouch.core.Result in project braintree_android by braintree.
the class AppSwitchHelperUnitTest method parseAppSwitchResponse_parsesAuthorizationCodeResponseAndReturnsResult.
@Test
public void parseAppSwitchResponse_parsesAuthorizationCodeResponseAndReturnsResult() 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", "code").putExtra("authorization_code", "auth-code").putExtra("email", "test@paypal.com");
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.authorization_code.name(), result.getResponse().getString("response_type"));
JSONObject client = result.getResponse().getJSONObject("client");
assertEquals("test", client.getString("environment"));
assertEquals("auth-code", result.getResponse().getJSONObject("response").getString("code"));
assertEquals("test@paypal.com", result.getResponse().getJSONObject("user").getString("display_string"));
}
Aggregations