0

I need to get the size of the "description" array, convert to object dto. I need to check with rest assured if my array "description" contains at least 1 element inside. How do I do that? My Json

{
"success": true,
"description": [
    {
        "a": "xxx",
        "a": 5,
        "a": "xxx",
        "a": "xx",
        "aaa": [
            {
                "b": 247,
                "b": "BR",
                "b": "CPF",
                "b": 3
            }
        ],
        "ccc": 3
    }
]
}

My code

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());
}

My DTO

public class ResponseDTO {

  private boolean success;
  private List description;

  getters/setters
}
Graham
  • 7,431
  • 18
  • 59
  • 84
JJB
  • 115
  • 1
  • 1
  • 7
  • If it needs to be done on DTO object why don't you make list size validation in validate method? Like this `public void validade(ResponseDTO responseDTO) { assertTrue(responseDTO.isSuccess()); assertTrue(responseDTO.getDescription().size()>=1); }` – Milan Mar 14 '18 at 13:39
  • Thank you for your information John Smith. I got it – JJB Mar 16 '18 at 18:06

0 Answers0