RegistrationActivity extends WebViewActivity { @Override protected void handleUserReadyEvent(Map<Object, Object> payload) { Intent result = new Intent(); result.putExtra(EXTRA_USER_TOKEN, (String)payload.get(PAYLOAD_USER_TOKEN)); setResult(RESULT_OK, result); finish(); }  @Override void onBackPressed(); static final String EXTRA_USER_TOKEN; static final String EXTRA_SETTINGS; }
@Test public void handleUserReadyEvent_ShouldPutRegistrationResultInExtraAndCallFinishWithResultOk() { registrationActivity.handleUserReadyEvent(new HashMap<Object, Object>() {{ put("userToken", "my_token"); }}); Intent expectedIntent = new Intent(); expectedIntent.putExtra(RegistrationActivity.EXTRA_USER_TOKEN, "my_token"); verify(registrationActivity).setResult(eq(Activity.RESULT_OK), eq(expectedIntent)); verify(registrationActivity).finish(); }