This code on ServiceImpl
List<EmployeeResponse> employeeResponses = employeeApiClient.getEmployeeByEmpNo(apiSecret, List.of(operationUserId));
Long branchId = Long.parseLong(employeeResponses.get(0).getWorklocationCode());
and, I wanna create the unit test, I already create this,
List<EmployeeResponse> employeeResponses = List.of(mockEmployeeResponse());
Long branchId = Long.parseLong(employeeResponses.get(0).getWorklocationCode());
and, when I use this,
doReturn(List.of(branchId)).when(employeeApiClient).getEmployeeByEmpNo(any(), anyList());
the response is
java.lang.NullPointerException
when I use this,
doReturn(branchId).when(employeeApiClient).getEmployeeByEmpNo(any(), anyList());
the response is
org.mockito.exceptions.misusing.WrongTypeOfReturnValue:
Long cannot be returned by getEmployeeByEmpNo()
getEmployeeByEmpNo() should return List
and, when I use this,
when(employeeApiClient.getEmployeeByEmpNo(any(), anyList())).thenReturn(branchId);
the response is
Cannot resolve method 'thenReturn(Long)'
Maybe, any others way to solve this issue, thank you for help.
I'm new on use the unit test (Mock), so I tried to ask about my problem for learning and getting answer.