I want to unit-test a method like this:
public String handleRequest(Event event) {
for(Message msg : event.getRecords()){
SDKClient client = new SDKClient(msg.getUser(), msg.getPassword());
String output = client.makeAPICall();
return output.toUpperCase();
}
}
}
Typically, we mock dependencies like SDKClient
by passing them in as arguments and mocking them in Junit/Mockito. However, in this case, I cannot just pass it because the SDKClient
depends on the actual events passed in. There is also an undetermined number of clients, one for each message in the event
. I want to unit test the method as a whole, but I do not know the dependencies in advance. Is it possible?