Reputation: 1583
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 ?
Upvotes: 21
Views: 39308
Reputation: 20254
Your brackets are in the wrong place, try this:
doNothing().when(mockRegistrationPeristImpl).create(any(Registration.class));
Upvotes: 45