PhotoTaker { private void onResultNotOk(int requestCode) { switch (requestCode) { case CAPTURE_IMAGE: case PICK_IMAGE: case CROP_IMAGE: listener.onError(requestCode); } } PhotoTaker(@NonNull Activity activity, @NonNull PhotoSize photoSize);  PhotoTaker(@NonNull Fragment fragment, @NonNull PhotoSize photoSize); void onActivityResult(int requestCode, int resultCode, @Nullable Intent data); void doCropImage(@NonNull Uri uri); void showDialog(); void captureImage(); void pickImage(); void setListener(@NonNull PhotoTakerListener listener); static final int CAPTURE_IMAGE; static final int CROP_IMAGE; static final int PICK_IMAGE; }
@Test public void onResultNotOk() throws Exception { taker.onActivityResult(CAPTURE_IMAGE, RESULT_FIRST_USER, null); verify(listener).onError(CAPTURE_IMAGE); taker.onActivityResult(CROP_IMAGE, RESULT_FIRST_USER, null); verify(listener).onError(CROP_IMAGE); }