jeudi 28 juillet 2016

Json Schema Validation Not Fail

I am working on Json Schema Valdation with Rest Assured api. I am getting a Json response from web service and validate with this a a schema. When I change a property in schema and run the test code, test not fail. But I wanna test that any property exist there. If one of the properties that in the schema is not exist in response test must be fail. But I couldn't do this. How can I do this? My Test Code:

@Test
public void catalogButiqueDetailTest(){
    File file = new File("src/test/resources/generatedJson/boutiqueDetailSchema.json");
    JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.newBuilder().setValidationConfiguration(ValidationConfiguration.newBuilder().setDefaultVersion(SchemaVersion.DRAFTV4).freeze()).freeze();


    given()
    .headers("some-header-info")
    .contentType("application/json")
    .get("web-service-url")
    .then()
    .assertThat()
    .body(JsonSchemaValidator.matchesJsonSchema(file).using(jsonSchemaFactory));
}

Aucun commentaire:

Enregistrer un commentaire