My method in the service and testing class:
public void updateSubModuleOrder(Long[] data, Long moduleSysId, Long userId) { try { for (int i = 0; i < data.length; i++) { SubModule subModule=new SubModule(); int temp = i + 1; userSubmodule.setDsplySeq(temp); userSubModuleDao.saveOrUpdate(userSubmodule); @Test public void testupdateSubModuleOrder(){ UserModuleServiceImpl userModuleServiceImpl = new UserModuleServiceImpl(); UserSubModuleDao userSubModuleDao = mock(User
I get an error
FAILED: testupdateSubModuleOrder org.mockito.exceptions.misusing.InvalidUseOfMatchersException: Invalid use of argument matchers! 2 matchers expected, 1 recorded: -> at com.TestUserModuleServiceImpl.testupdateSubModuleOrder(TestUserModuleServiceImpl.java:267)
This exception may occur if matches are combined with raw values:
//incorrect: someMethod(anyObject(), "raw String");
When using matches, all arguments must be provided by the match. For example:
//correct: someMethod(anyObject(), eq("String by matcher"));
The findbyID method is a baseDao method that my dao extends. This is not final or static, but still I get this problem.
java junit mockito matcher
user2375298
source share