I would like to be able to perform a custom action when a given void method is called.
For example:-
private IMocksControl control;
private Map<String, Double> dataMap = new HashMap<>();
private Abc abc;
public void setup(){
control = EasyMock.createControl();
abc = control.createMock(Abc.class);
}
Suppose there is a void method in class Abc which i want to use. But when that method is called I want to put an entry inside the dataMap hashmap.
Any suggestions how to do this?
I don't fully remember the code for EasyMock 1 (which is obsolete for more than 10 years now) but there should be a control.andAnswer()
where you will be able to do something like:
abc.method();
control.andAnswer(new IAnswer() {
dataMap.put(...);
});