I'm facing the exception
java.lang.IllegalAccessError: class org.mockito.Matchers tried to access private method 'void org.mockito.internal.progress.ThreadSafeMockingProgress.()' (org.mockito.Matchers and org.mockito.internal.progress.ThreadSafeMockingProgress are in unnamed module of loader 'app')
at org.mockito.Matchers.(Matchers.java:107)
when I try to use the matcher any()
in mockito when()
stub call. The class argument type is for "NewOrder" from the binance spot java library here
I'm trying to do
when(mockBinanceApiRestClient.newOrder(any(NewOrder.class))).thenReturn(buyOrderResp);
mocking the BinanceApiRestClient.
The any()
and when()
are static imports from org.mockito.Mockito
.
This is such a nightmare why wouldn't it work?
Looks like you have two conflicting versions of Mockito on your classpath.
ThreadSafeMockingProgress was converted to a singleton back in 2016, and its constructor was changed to private.
On the other hand, you seem to be using org.mockito.Matchers
,
which was deprecated for a long while and finally removed in Mockito 4.x