Method when (T) in Stubber type is not applicable for arguments (void)

I get the following error when a void breaks:

Method when (T) in Stubber type is not applicable for 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?

+7
mockito
source share
1 answer

Your brackets are in the wrong place, try the following:

 doNothing().when(mockRegistrationPeristImpl).create(any(Registration.class)); 
+20
source share

All Articles