sunmingtao / sample-code

3 stars 4 forks source link

Cannot mock SQLStatement.bind() #359

Closed sunmingtao closed 1 week ago

sunmingtao commented 1 week ago

Below exception is thrown on when(query.bind(anyString(), anyLong())).thenReturn(query);

java.lang.NullPointerException
    at org.skife.jdbi.v2.SQLStatement.bind(SQLStatement.java:1035)
    at au.gov.nla.banjo.cleaning.CaptureStatusDataCleanupUnitTest2.setup(CaptureStatusDataCleanupUnitTest2.java:35)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sunmingtao commented 1 week ago

Query.bind() is a final method.

Mockito-core 3.12.4 is unable to mock a final method but mockito-core 5.1.1 is able to