I need to mock an internal hibernate-validator
class to test my exception handlers. With hibernate-validator
8.0.1.Final
, it works fine. With 9.0.0.Beta3
, I started getting:
org.mockito.exceptions.base.MockitoException:
Mockito cannot mock this class: class org.hibernate.validator.internal.engine.path.PathImpl.
Can not mock final classes with the following settings :
- explicit serialization (e.g. withSettings().serializable())
- extra interfaces (e.g. withSettings().extraInterfaces(...))
I looked at the code, and both versions define the class as:
public final class PathImpl implements Path, Serializable {
I can’t mock the interface, because I need to mock some internal methods. It’s not really clear how to fix the error message from a Google search.