Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • 1
    Likely not your problem, but assistanceRequestsHandlerMock.handle(new InfoEvent(any())); is nonsense. any() must only be used when stubbing or verifying methods. It cannot be used as arguments to other methods and will corrupt Mockito's Matcher stack. That and it simply returns null, so the call is effectively new InfoEvent(null) (plus, as written: confusing Mockito by having unused matchers on its stack). I'm really not sure if stubbing the static UUID.randomUUID() function is a good idea. And if I remember corectly, you cannot stub toString(), but I might be mistaken here Commented Apr 25 at 20:52
  • 1
    Following up on "mocking UUID": you are not basically testing anything. If you change your verification to verifyPrivate("myPrivateMethod", anyString(), anyString)), it would be equally "good". If you use two argument captors, you could even assert that both arguments are the same/equal. Commented Apr 25 at 20:55