EasyMock.replay(builder);
method.builder = builder;
EasyMock.expect(method.isExpected(200)).andReturn(true);
EasyMock.replay(method);
FilterawareRequestCallback callback = new DefaultFilterawareRequestCallback(method);
// set the response code
Response resp = EasyMock.createMock(Response.class);
EasyMock.expect(resp.getStatusCode()).andReturn(200).anyTimes();
EasyMock.replay(resp);
// expect to call each filter with RequestCallback rc
CallbackFilter[] filters = new CallbackFilter[4];
for(int i = 0; i < filters.length; i++){
filters[i] = EasyMock.createMock(CallbackFilter.class);
callback.addFilter(filters[i]);
EasyMock.expect(filters[i].filter(method, resp, rc)).andReturn(rc);
EasyMock.replay(filters[i]);
}
//now call the success case
callback.onResponseReceived(null, resp);
// now call the error case
Exception e = new Exception();
try{
callback.onError(null, e);
fail();
}
catch(RuntimeException ee){
assertSame(e, ee.getCause());
}