I am getting following error when stubbing a void:
The method when(T) in the type Stubber is not applicable for the arguments (void)
Here is my sample code:
doNothing().when(mockRegistrationPeristImpl.create(any(Registration.class)));
public void create(final T record) throws DataAccessException {
try {
entityManager.persist(record);
entityManager.flush();
} catch (PersistenceException ex) {}
}
What am I missing ?
Your brackets are in the wrong place, try this:
doNothing().when(mockRegistrationPeristImpl).create(any(Registration.class));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With