ChangePasswordActivity extends RapidFtrActivity { protected void sendRequestToServer(String old_password, String new_password, String confirmation) { ChangePasswordTask task = inject(ChangePasswordTask.class); task.setActivity(this); if(RapidFtrApplication.getApplicationInstance().isOnline()){ task.execute(old_password, new_password, confirmation); } else { Toast.makeText(RapidFtrApplication.getApplicationInstance(), R.string.no_connection, Toast.LENGTH_LONG).show(); this.finish(); } }  void changePassword(View view);  }
@Test public void shouldNotSendRequestToServerIfFieldsAreInValid() { newPassword = mock(EditText.class); newPasswordConfirm = mock(EditText.class); currentPassword = mock(EditText.class); doReturn(currentPassword).when(changePasswordActivity).findViewById(R.id.current_password); doReturn(newPassword).when(changePasswordActivity).findViewById(R.id.new_password); doReturn(newPasswordConfirm).when(changePasswordActivity).findViewById(R.id.new_password_confirm); changeButton.performClick(); verify(changePasswordActivity, never()).sendRequestToServer(anyString(),anyString(),anyString()); }