I have a test that throws HttpException from a certain library (com.googlecode.jsonrpc4j). I have written a test like so:
Exception exception = assertThrows(HttpException.class,
() -> this.myApi.getInformation(date1, date2)
);
For this, I have imported the HttpException class like so:
import com.googlecode.jsonrpc4j.HttpException;
However, doing so gives me an error message:
'com.googlecode.jsonrpc4j.HttpException' is not public in 'com.googlecode.jsonrpc4j'.
Cannot be accessed from outside package
So, even though this exception is thrown in certain conditions, I am unable to test that this exception will be thrown under those conditions. Is there any way that I can test this?
My workaround, since the private HttpException extends RuntimeException, I can test it by asserting that RuntimeException is thrown. However, is there a better way to test this?