Reputation: 1261
I have a function func() which accepts UUID as an argument. I am making a unit test for which I need to return a specific value for any UUID value passed to func(). How can I make it work for any UUID type value (just like anyString()
for any string, anyInt()
for any integer, etc)?
I have already tried:
when(obj.func(any(UUID.class)).thenReturn(null);
It gives the following error:
The method any(Class<UUID>) is ambiguous for the type <Test_Class_Name>
where Test_Class_Name is the name of the class where I am writing the unit tests.
func() is an overloaded function : func(String) and func(UUID)
Upvotes: 9
Views: 7852
Reputation: 26066
For any other type you can use any()
. This will match an argument of given type:
any(UUID.class)
You can find more information in the documentation.
Upvotes: 19