Java, Unit Testing, Legacy Code, Programming, Technology.
public User getUserById(String userId) { return userRepository.findById(userId); } } Refactor the method to use dependency injection and mock the UserRepository: public class UserService { private final UserRepository userRepository; public UserService(UserRepository userRepository) {