我需要获取“描述”数组的大小,转换为对象 dto。我需要放心检查我的数组“描述”是否包含至少 1 个元素。我怎么做?我的杰森
{
"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
}