### Question:
Gateway { public static boolean handle3DSecureResult(int requestCode, int resultCode, Intent data, Gateway3DSecureCallback callback) { if (callback == null) { return false; } if (requestCode == REQUEST_3D_SECURE) { if (resultCode == Activity.RESULT_OK) { String acsResultJson = data.getStringExtra(Gateway3DSecureActivity.EXTRA_ACS_RESULT); GatewayMap acsResult = new GatewayMap(acsResultJson); callback.on3DSecureComplete(acsResult); } else { callback.on3DSecureCancel(); } return true; } return false; } Gateway(); String getMerchantId(); Gateway setMerchantId(String merchantId); Region getRegion(); Gateway setRegion(Region region); void updateSession(String sessionId, String apiVersion, GatewayMap payload, GatewayCallback callback); Single<GatewayMap> updateSession(String sessionId, String apiVersion, GatewayMap payload); static void start3DSecureActivity(Activity activity, String html); static void start3DSecureActivity(Activity activity, String html, String title); static boolean handle3DSecureResult(int requestCode, int resultCode, Intent data, Gateway3DSecureCallback callback); static void requestGooglePayData(PaymentsClient paymentsClient, PaymentDataRequest request, Activity activity); static boolean handleGooglePayResult(int requestCode, int resultCode, Intent data, GatewayGooglePayCallback callback);  }### Answer:
@Test public void testHandle3DSecureResultReturnsFalseWithNullCallback() { assertFalse(Gateway.handle3DSecureResult(0, 0, null, null)); }
@Test public void testHandle3DSSecureResultReturnsFalseIfInvalidRequestCode() { int invalidRequestCode = 10; Gateway3DSecureCallback callback = mock(Gateway3DSecureCallback.class); assertFalse(Gateway.handle3DSecureResult(invalidRequestCode, 0, null, callback)); }
@Test public void testHandle3DSecureResultCallsCancelIfResultNotOk() { int validRequestCode = Gateway.REQUEST_3D_SECURE; int resultCode = Activity.RESULT_CANCELED; Gateway3DSecureCallback callback = mock(Gateway3DSecureCallback.class); boolean result = Gateway.handle3DSecureResult(validRequestCode, resultCode, null, callback); assertTrue(result); verify(callback).on3DSecureCancel(); }
@Test public void testHandle3DSecureResultCallsCompleteIfResultOK() { int validRequestCode = Gateway.REQUEST_3D_SECURE; int resultCode = Activity.RESULT_OK; Intent data = mock(Intent.class); String acsResultJson = "{\"foo\":\"bar\"}"; Gateway3DSecureCallback callback = spy(new Gateway3DSecureCallback() { @Override public void on3DSecureComplete(GatewayMap response) { assertNotNull(response); assertTrue(response.containsKey("foo")); assertEquals("bar", response.get("foo")); } @Override public void on3DSecureCancel() { fail("Should never have called cancel"); } }); doReturn(acsResultJson).when(data).getStringExtra(Gateway3DSecureActivity.EXTRA_ACS_RESULT); boolean result = Gateway.handle3DSecureResult(validRequestCode, resultCode, data, callback); assertTrue(result); verify(callback).on3DSecureComplete(any()); }