private <T> Future<T> completeOperation(T result, Callback<T> callback, OpType opType) {
    if (!isOpen) {
      throw new IllegalStateException("Router not open");
    }
    Exception exception = null;
    if (opType == exceptionOpType) {
      if (exceptionToThrow != null) {
        throw new RuntimeException(exceptionToThrow);
      } else if (exceptionToReturn != null) {
        exception = exceptionToReturn;
        result = null;
      }
    }
    FutureResult<T> futureResult = new FutureResult<T>();
    futureResult.done(result, exception);
    if (callback != null) {
      callback.onCompletion(result, exception);
    }
    return futureResult;
  }
Completes the operation by creating and invoking a {@link Future} and invoking the {@code callback} if non-null.
@param result the result to return.
@param callback the {@link Callback} to invoke. Can be null.
@param opType the type of operation calling this function.
@param <T> the type of future/callback.
@return the created {@link Future}.
ambry-frontend/src/test/java/com/github/ambry/frontend/FrontendRestRequestServiceTest.java