From 806ba76469680e9ea1e8224d5a1361a9c5f40fd1 Mon Sep 17 00:00:00 2001 From: leeseonym <59040772+leeseonym@users.noreply.github.com> Date: Thu, 19 Dec 2019 15:57:43 +0900 Subject: [PATCH] Create productGet.groovy --- .../contracts/rest/productGet.groovy | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/test/resources/contracts/rest/productGet.groovy diff --git a/src/test/resources/contracts/rest/productGet.groovy b/src/test/resources/contracts/rest/productGet.groovy new file mode 100644 index 0000000..8cee3b9 --- /dev/null +++ b/src/test/resources/contracts/rest/productGet.groovy @@ -0,0 +1,31 @@ +package contracts.rest + +org.springframework.cloud.contract.spec.Contract.make { + request { + method 'GET' + url ('/product/1') + headers { + contentType(applicationJson()) + } + } + response { + status 200 + body( + id: 1, + name: "TV", + price: 10000, + stock: 10, + imageUrl: "testUrl" + ) + bodyMatchers { + jsonPath('$.id', byRegex(nonEmpty()).asLong()) + jsonPath('$.name', byRegex(nonEmpty()).asString()) + jsonPath('$.price', byRegex(nonEmpty()).asLong()) + jsonPath('$.stock', byRegex(nonEmpty()).asLong()) + jsonPath('$.imageUrl', byRegex(nonEmpty()).asString()) + } + headers { + contentType(applicationJson()) + } + } +}