Skip to content

Latest commit

 

History

History
44 lines (29 loc) · 1.09 KB

README.md

File metadata and controls

44 lines (29 loc) · 1.09 KB

test-negative-contract

To test the services, start it and do:

To check that the error response is correct:

{
  "timestamp": 1481654921954,
  "status": 409,
  "error": "Conflict",
  "exception": "com.example.MyCustomException",
  "message": "CUSTOM_MESSAGE_HERE",
  "path": "/api/v1/xxxx"
}

To test with contracts:

  1. Run mvn clean test

A Build failure message appear:

Tests in error:
  RestTest.validate_negative:28 » IllegalArgument json string can not be null or...

Tests run: 3, Failures: 0, Errors: 2, Skipped: 0

Check the autogenerated class: /test-negative-contract/target/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/com/example/external/consumer/RestTest.java

And line 28 is:

DocumentContext parsedJson = JsonPath.parse(response.getBody().asString());

If you inspect that in debug mode, you can see that response.getBody().asString() is empty