I’m working with Java and REST Assured to test REST APIs. I was trying the example with JSON schema validation but it throws this error:
java.lang.IllegalArgumentException: Schema to use cannot be null
at io.restassured.module.jsv.JsonSchemaValidator.validateSchemaIsNotNull(JsonSchemaValidator.java:270)
at io.restassured.module.jsv.JsonSchemaValidator.access$300(JsonSchemaValidator.java:75)
at io.restassured.module.jsv.JsonSchemaValidator$JsonSchemaValidatorFactory.create(JsonSchemaValidator.java:281)
at io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchema(JsonSchemaValidator.java:166)
at io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath(JsonSchemaValidator.java:117)
at suites.SchemaFollowupTest.ContractFollowUpTestSuccess(SchemaFollowupTest.java:44)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
My test code is:
given()
.header("Content-Type", ContentType.JSON)
//.header("Authorization", "Bearer " + ConfigEnvironments.TOKEN_K8S)
.body(jsonBody)
.when()
.post(ConfigEnvironments.BASE_URL_CLAIMENGINE +"/api/v1/FollowUp")
.then().log().all()
.statusCode(202)
.and()
.body(matchesJsonSchemaInClasspath("src/test/resource/followup-schema.json"));
My strucuture folder is here:
[1]: https://i.sstatic.net/K9m2UjGy.png
Source: Read More