[Enchancement request]: Automatic unpack Optional

32 views
Skip to first unread message

Andre Köpke

unread,
Nov 26, 2024, 6:45:39 AM11/26/24
to mockito
Hey

It would be cool, when Mockito can automatic unpack Optionals.
Today, we have to write this:

     when(mock.find()).thenReturn(Optional.of(returnObject));

It would be cool, if we can write this instead:

     when(mock.find()).thenReturn(returnObject);

Should be a low hanging or not?

Thanks

Bruno Bonanno

unread,
Nov 26, 2024, 11:36:54 AM11/26/24
to moc...@googlegroups.com
I’m pretty sure that works out of the box, can’t remember the exact incantation though 


On 26 Nov 2024, at 11:45, 'Andre Köpke' via mockito <moc...@googlegroups.com> wrote:

Hey
--
You received this message because you are subscribed to the Google Groups "mockito" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mockito+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/mockito/e3c17158-f0c1-4559-bc2a-ea451c184b37n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages