【发布时间】:2015-05-03 12:12:34
【问题描述】:
我遇到以下错误:
java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to com.testing.models.Account
下面的代码
final int expectedId = 1;
Test newTest = create();
int expectedResponseCode = Response.SC_OK;
ArrayList<Account> account = given().when().expect().statusCode(expectedResponseCode)
.get("accounts/" + newTest.id() + "/users")
.as(ArrayList.class);
assertThat(account.get(0).getId()).isEqualTo(expectedId);
我不能做get(0)有什么原因吗?
【问题讨论】:
-
不能转换成什么?错误信息的其余部分是什么?
-
@OliverCharlesworth 还添加了整个堆栈跟踪
-
什么是
Account?你为什么要从地图投射到它? -
对于我们这些可能对库不熟悉的人,您能说一下这个
given()方法是从哪个类静态导入的吗? -
@DaveNewton
Account是 Dropwizard 的一个模型,它使用com.fasterxml.jackson.databind.annotations
标签: java jackson rest-assured