Hi I have a class called Worker and another class called Helper with methods defined like below
class Worker{
public Response work() {
// both parameters initialised here before below method call
Helper h = new Helper;
h.change(map.entry<> entry,map<> map);
//build the response using the modified map and finally return the response
return response;
}
}
class Helper {
public void change(map.entry<> entry,map<> empty) {
// add key value pair to the empty map
}
}
Tried using doAnswer() and customised the parameters, as well as checked assertions on them but couldn't use the modified parameters from the mocked method ,if below that statement I try to make a call to work().
Question: how to create a test class for Worker class where I can use the mocked method for change() instead of the actual method and also can test all the code defined in work() method.
Is there any way to use the modified parameters from the mocked method outside of doAnswer() ,also let me know if code refactoring is required to make it easily testable