Mockito throw Exception

Change this:

thenThrow(DataAccessException.class)

to

thenThrow(new DataAccessException("..."){ })

Example:

when(userSubModuleDao.findById(any(UserSubModuleId.class),eq(false))).thenThrow(new DataAccessException("..."){});

You can only pass a Class reference when that Exception type has a No-Arg constructor, and the Spring exception does not have one.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)