I'm using mockito in a junit test. How do you make an exception happen and then assert that it has (generic pseudo-code)
Mockito alone is not the best solution for handling exceptions, use Mockito with Catch-Exception
given(otherServiceMock.bar()).willThrow(new MyException());
when(() -> myService.foo());
then(caughtException()).isInstanceOf(MyException.class);