sla*_*ton 3 java testing jersey dropwizard
我正在使用DropWizard构建服务.我有一个预计返回的端点List<Person>
我的单元测试看起来像:
@Test
public void testGetListOfPeople() {
assertThat(
resources.client().target("/people/?age=10").request().get(ArrayList<Person>.class))
.containsAll(expectedList);
}
Run Code Online (Sandbox Code Playgroud)
但是,request().get
不允许我指定参数化集合.
我已尝试直接获得响应:
r = resources.client().target("/people/?age=10").request().get()
Run Code Online (Sandbox Code Playgroud)
但后来不清楚我如何转换r
成一个List<Person>
如何更新此测试?
是的,拥有收藏品的泽西岛客户可能有点令人沮丧.解决方案很简单,只需执行以下操作:
import javax.ws.rs.core.GenericType;
resources.client().target("/people/?age=10").request()
.get(new GenericType<List<Person>>(){});
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
938 次 |
最近记录: |