Java EasyMock和泛型参数
我正在尝试使用EasyMock来模拟对Jersey客户端API的一些调用。。。 我试图模拟对以下调用生成器API的调用:Java EasyMock和泛型参数,java,unit-testing,easymock,jersey-client,Java,Unit Testing,Easymock,Jersey Client,我正在尝试使用EasyMock来模拟对Jersey客户端API的一些调用。。。 我试图模拟对以下调用生成器API的调用: <T> T post(Entity<?> entity, Class<T> responseType); 这给了我以下错误: java.lang.AssertionError: Unexpected method call Builder.post(Entity{entity=com.ibm.apin.apim.request.Cr
<T> T post(Entity<?> entity, Class<T> responseType);
这给了我以下错误:
java.lang.AssertionError:
Unexpected method call Builder.post(Entity{entity=com.ibm.apin.apim.request.CreateOrgRequest@936a7073, variant=Variant[mediaType=application/json, language=null, encoding=null], annotations=[]}, class javax.ws.rs.core.Response):
有人能看出我做错了什么,以及我如何能正确地模仿这一点吗?参见:
为了使模拟对象上的实际方法调用与预期匹配,对象
参数默认情况下与equals()
进行比较
您必须重写、使用内置参数匹配器(如)、编写自己的或使用。默认情况下,EasyMock使用
equals
匹配参数。是否在实体
上定义了合适的等于
方法?
java.lang.AssertionError:
Unexpected method call Builder.post(Entity{entity=com.ibm.apin.apim.request.CreateOrgRequest@936a7073, variant=Variant[mediaType=application/json, language=null, encoding=null], annotations=[]}, class javax.ws.rs.core.Response):