How to mock a method that returns Mono<Void>
?
I have this method that returns Mono<Void>
public Mono<Void> deleteMethod(Post post) {
return statusRepository.delete(post);
}
In my test class I want to do something like this
given(statusRepository.delete(any(Post.class))).willReturn(Mono.empty());
Is there any better way to do this?
Can someone help me?
Thanks.
This is possible using Mockito.when
:
Mockito.when(statusRepository.delete(any(Post.class)).thenReturn(Mono.empty());
...call the method and verify...
Mockito.verify(statusRepository).delete(any(Post.class));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With