vendredi 24 juin 2016

json response validation in java (Assertion)

I am successfully parsing JSON in body and getting response. But I want to know how to validate the response. Right now as part of validation i am just validating the status code.

protected ResponseSpecification somefunction() {
        ResponseBuilder builder = new ResponseBuilder();
        builder.expectContentType(ContentType.JSON).

                expectStatusCode(HttpStatus.OK_200);

        return builder.build();
    }

But my json response looks something like this:

{ "status": "success", "numSucceeded": 1 }

Thus How to validate message as numSucceeded is 1 in java?

Aucun commentaire:

Enregistrer un commentaire