1

I have below method in my service class -

public List<Employee> getEmployee(String deptId){
    try{
        DepartmentResponse department = departmentClient.employeeData(deptId);

        return isNull(department) ? newArrayList() : department.getEmployee();

    }catch(CstomeException ex) {
        log.error("Some Error Message");
    }catch(RetryableException ex) {
        log.error("Some Error Message");
    }
    return newArrayList();
}

When I am trying to mock this method like below -

when(departmentService.getEmployee(anyString()))
        .thenReturn(newArrayList(Employee.builder.build()));

I am getting below error -

 org.mockito.exceptions.misusing.InvalidUseOfMatchersException

I tried with this also.

when(departmentService.getEmployee(any(String.class)))
        .thenReturn(newArrayList(Employee.builder.build()));
ppb
  • 2,299
  • 4
  • 43
  • 75

0 Answers0