我需要获得"描述"的大小。数组,转换为对象dto。我需要放心,如果我的阵列"描述"内部至少包含1个元素。我怎么做? 我的Json
{
"success": true,
"description": [
{
"a": "xxx",
"a": 5,
"a": "xxx",
"a": "xx",
"aaa": [
{
"b": 247,
"b": "BR",
"b": "CPF",
"b": 3
}
],
"ccc": 3
}
]
}
我的代码
public class Name extends Base {
private final String UrlString= "resource";
@Test
public void teste() {
ResponseDTO responseDTO = given()
.contentType(ContentType.JSON)
.headers("utoken", utoken)
.pathParam("name",name)
.when()
.get(UrlString)
.then()
.statusCode(is(statusok))
.extract().as(ResponseDTO.class);
validade(responseDTO);
}
public void validade(ResponseDTO responseDTO) {
assertTrue(responseDTO.isSuccess());
}
我的DTO
public class ResponseDTO {
private boolean success;
private List description;
getters/setters
}