如何 return 调用模拟方法的参数作为响应?

How to return the argument, which the mock method was called with, as response?

在 Mockito 中是否可以 return 调用模拟方法的对象?在事先不知道它将是什么对象的情况下。

@Mock
MyObjectRepository myObjectRepository;
...
when(myObjectRepository.save(any(MyObject.class))) //save method returns normally MyObject.class object
     .thenReturn(\the object that method was called with);

我想return传递给保存方法的对象。

以下应该有效:

when(myObjectRepository.save(any(MyObject.class)))
     .then(AdditionalAnswers.returnsFirstArg());