Making a mocked method return an argument that was passed to it

To make a mocked method return an argument that was passed to it, you can use the Mockito.when method and pass it the argument that you want to return as the answer.

Here's an example:

// create mock object
MyClass mock = Mockito.mock(MyClass.class);

// define return value for method getUniqueId()
when(mock.getUniqueId()).thenReturn(1);

// use mock in test....
int uniqueId = mock.getUniqueId();

In this example, the getUniqueId method of the mock object will return 1 when it is called.