use of com.paypal.android.sdk.onetouch.core.Request in project braintree_android by braintree.
the class AppSwitchHelperUnitTest method parseAppSwitchResponse_parsesErrorAndReturnsResult.
@Test
public void parseAppSwitchResponse_parsesErrorAndReturnsResult() {
Request request = mock(AuthorizationRequest.class);
when(request.validateV1V2Response(any(ContextInspector.class), any(Bundle.class))).thenReturn(true);
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.Return), isNull(Protocol.class));
assertTrue(result.getError() instanceof WalletSwitchException);
assertEquals("there was an error", result.getError().getMessage());
}
use of com.paypal.android.sdk.onetouch.core.Request in project braintree_android by braintree.
the class AppSwitchHelperUnitTest method buildAppSwitchIntent_buildsIntent.
@Test
public void buildAppSwitchIntent_buildsIntent() {
Request request = mock(CheckoutRequest.class);
when(request.getEnvironment()).thenReturn("test");
when(request.getClientMetadataId()).thenReturn("client-metadata-id");
when(request.getClientId()).thenReturn("client-id");
Intent intent = AppSwitchHelper.getAppSwitchIntent(mContextInspector, mConfigManager, request, getMockRecipe(2));
assertEquals("installation-guid", intent.getStringExtra("app_guid"));
assertEquals("client-metadata-id", intent.getStringExtra("client_metadata_id"));
assertEquals("client-id", intent.getStringExtra("client_id"));
assertEquals("application-name", intent.getStringExtra("app_name"));
assertEquals("test", intent.getStringExtra("environment"));
assertEquals("test", intent.getStringExtra("environment_url"));
}
use of com.paypal.android.sdk.onetouch.core.Request 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.Request in project braintree_android by braintree.
the class AppSwitchHelperUnitTest method buildAppSwitchIntent_buildsIntentForProtocolV1.
@Test
public void buildAppSwitchIntent_buildsIntentForProtocolV1() {
Request request = mock(CheckoutRequest.class);
when(request.getEnvironment()).thenReturn("test");
Intent intent = AppSwitchHelper.getAppSwitchIntent(mContextInspector, mConfigManager, request, getMockRecipe(1));
assertEquals("com.paypal.android.lib.authenticator.activity.v1.TouchActivity", intent.getAction());
assertEquals("com.paypal.android.p2pmobile", intent.getPackage());
assertEquals("1.0", intent.getStringExtra("version"));
}
use of com.paypal.android.sdk.onetouch.core.Request 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());
}
Aggregations