user3123934
user3123934

Reputation: 1583

The method when(T) in the type Stubber is not applicable for the arguments (void)

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

Answers (1)

codebox
codebox

Reputation: 20254

Your brackets are in the wrong place, try this:

doNothing().when(mockRegistrationPeristImpl).create(any(Registration.class));

Upvotes: 45

Related Questions