CaptureCallbackAdapter extends CameraCaptureSession.CaptureCallback { @Override public void onCaptureFailed( @NonNull CameraCaptureSession session, @NonNull CaptureRequest request, @NonNull CaptureFailure failure) { super.onCaptureFailed(session, request, failure); CameraCaptureFailure cameraFailure = new CameraCaptureFailure(CameraCaptureFailure.Reason.ERROR); mCameraCaptureCallback.onCaptureFailed(cameraFailure); } CaptureCallbackAdapter(CameraCaptureCallback cameraCaptureCallback); @Override void onCaptureCompleted(
            @NonNull CameraCaptureSession session,
            @NonNull CaptureRequest request,
            @NonNull TotalCaptureResult result); @Override void onCaptureFailed(
            @NonNull CameraCaptureSession session,
            @NonNull CaptureRequest request,
            @NonNull CaptureFailure failure);  }
@Test public void onCaptureFailed() { mCaptureCallbackAdapter.onCaptureFailed(mCameraCaptureSession, mCaptureRequest, mock(CaptureFailure.class)); verify(mCameraCaptureCallback, times(1)).onCaptureFailed(any(CameraCaptureFailure.class)); }