Priority with Spring cloud contract -
sc contract version : 1.1.0.build-snapshot
i defining priority in groovy contracts :
package contracts import org.springframework.cloud.contract.spec.contract [ contract.make { priority 1 request { name 'create' method 'post' url '/api/patates' body([ cuite: true ]) headers { contenttype(applicationjson()) } } response { status 201 body([ id: $(consumer('1'), producer(regex('[0-9]{0,9}'))), cuite: true ]) headers { contenttype(applicationjson()) } } }, contract.make { priority 2 request { name 'read' method 'get' url '/api/patates/1' headers { contenttype(applicationjson()) } } response { status 200 body([ id: 1, cuite: true ]) headers { contenttype(applicationjson()) } } }, contract.make { priority 3 request { name 'update' method 'put' url '/api/patates' body([ id: 1, cuite: false ]) headers { contenttype(applicationjson()) } } response { status 200 body([ cuite: false ]) headers { contenttype(applicationjson()) } } }, contract.make { priority 4 request { name 'delete' method 'delete' url '/api/patates/1' body([ cuite: true ]) headers { contenttype(applicationjson()) } } response { status 200 headers { contenttype(applicationjson()) } } } ]
that's documentation :
following methods can called in top-level closure of contract definition. request , response mandatory, priority optional
contract priority, can used overriding, contracts (1 highest). priority optional.
and in console :
2016-12-22 12:35:39.947 debug 8964 --- [ main] c.m.myapp.web.rest.patateresource : rest request patate : 1 hibernate: select patate0_.id id1_3_0_, patate0_.cuite cuite2_3_0_ patate patate0_ patate0_.id=? 2016-12-22 12:35:40.142 debug 8964 --- [ main] c.m.myapp.web.rest.patateresource : rest request save patate : patate{id=null, cuite='true'} hibernate: insert patate (id, cuite) values (null, ?) 2016-12-22 12:35:40.287 debug 8964 --- [ main] c.m.myapp.web.rest.patateresource : rest request delete patate : 1 hibernate: select patate0_.id id1_3_0_, patate0_.cuite cuite2_3_0_ patate patate0_ patate0_.id=? 2016-12-22 12:35:40.357 debug 8964 --- [ main] c.m.myapp.web.rest.patateresource : rest request update patate : patate{id=1, cuite='false'} hibernate: select patate0_.id id1_3_0_, patate0_.cuite cuite2_3_0_ patate patate0_ patate0_.id=? hibernate: insert patate (id, cuite) values (null, ?) tests run: 4, failures: 1, errors: 1, skipped: 0, time elapsed: 0.687 sec <<< failure! - in org.springframework.cloud.contract.verifier.tests.patatetest validate_read(org.springframework.cloud.contract.verifier.tests.patatetest) time elapsed: 0.37 sec <<< failure!
there errors because "get" comming before create. doing wrong ?
thanks
Comments
Post a Comment