Fix sample

This commit is contained in:
Tim Ysewyn
2019-08-08 21:50:04 +02:00
parent 907365c705
commit 55e81a1f43
10 changed files with 22 additions and 22 deletions

View File

@@ -21,10 +21,10 @@ import org.springframework.cloud.contract.spec.internal.HttpStatus
contract {
request {
url = url("/goodbye")
method = method(HttpMethods.HttpMethod.GET)
method = GET
}
response {
status = code(HttpStatus.OK())
status = OK
body = body("Goodbye World!")
}
}

View File

@@ -22,14 +22,14 @@ import org.springframework.cloud.contract.spec.internal.HttpMethods
contract {
request {
url = url("/1")
method = method(HttpMethods.PUT())
method = PUT
headers {
contentType(applicationOctetStream())
}
body = bodyFromFileAsBytes("request.pdf")
}
response {
status = code(200)
status = OK
body = bodyFromFileAsBytes("response.pdf")
headers {
contentType(applicationOctetStream())

View File

@@ -21,7 +21,7 @@ import org.springframework.cloud.contract.spec.internal.HttpStatus
contract {
request { // (1)
method = method("PUT") // (2)
method = PUT // (2)
url = url("/fraudcheck") // (3)
body = body(// (4)
"client.id" to value(regex("[0-9]{10}")),
@@ -31,7 +31,7 @@ contract {
}
}
response { // (6)
status = code(HttpStatus.OK()) // (7)
status = OK // (7)
body = body( // (8)
"fraudCheckStatus" to "FRAUD",
"rejection.reason" to "Amount too high")

View File

@@ -21,7 +21,7 @@ import org.springframework.cloud.contract.spec.internal.HttpStatus
contract {
request {
method = method("PUT")
method = PUT
url = url("/fraudcheck")
body = body(
"client.id" to value(consumer(regex("[0-9]{10}")), producer("1234567890")),
@@ -31,7 +31,7 @@ contract {
}
}
response {
status = code(HttpStatus.OK())
status = OK
body = body(
"fraudCheckStatus" to "OK",
"rejection.reason" to value(consumer(null), producer(execute("assertThatRejectionReasonIsNull(\$it)")))

View File

@@ -24,11 +24,11 @@ listOf(
contract {
name = "should count all frauds"
request {
method = method(HttpMethods.GET())
method = GET
url = url("/frauds")
}
response {
status = code(HttpStatus.OK())
status = OK
body = body(
"count" to value(regex("[2-9][0-9][0-9]"))
)
@@ -39,11 +39,11 @@ listOf(
},
contract {
request {
method = method(HttpMethods.GET())
method = GET
url = url("/drunks")
}
response {
status = code(HttpStatus.OK())
status = OK
body = body(
"count" to 100
)

View File

@@ -21,7 +21,7 @@ import org.springframework.cloud.contract.spec.internal.HttpMethods
contract {
request {
method = method(HttpMethods.HttpMethod.GET)
method = GET
url = url("/frauds/name")
cookies {
cookie("name", "foo")
@@ -29,7 +29,7 @@ contract {
}
}
response {
status = code(200)
status = OK
body = body("foo bar")
}
}

View File

@@ -24,7 +24,7 @@ contract {
// highest priority
priority = 1
request {
method = method(HttpMethods.HttpMethod.PUT)
method = PUT
url = url("/frauds/name")
body = body("name" to "fraud")
headers {
@@ -32,7 +32,7 @@ contract {
}
}
response {
status = code(HttpStatus.OK())
status = OK
// TODO
// body = body("result" to "Sorry ${fromRequest().body("$.name")} but you're a fraud")
// headers {

View File

@@ -22,7 +22,7 @@ import org.springframework.cloud.contract.spec.internal.HttpStatus
contract {
request {
method = method(HttpMethods.HttpMethod.PUT)
method = PUT
url = url("/frauds/name")
body = body("name" to `$`(anyAlphaUnicode()))
headers {
@@ -30,7 +30,7 @@ contract {
}
}
response {
status = code(HttpStatus.OK())
status = OK
// TODO
// body("result" to "Don't worry ${fromRequest().body("$.name")} you're not a fraud")
// headers {

View File

@@ -21,7 +21,7 @@ import org.springframework.cloud.contract.spec.internal.HttpMethods
contract {
request {
method = method("POST")
method = POST
url = url("/tests")
multipart = multipart(mapOf(
"file1" to named(
@@ -40,7 +40,7 @@ contract {
}
}
response {
status = code(200)
status = OK
body = body("status" to "ok")
headers {
contentType("application/json")

View File

@@ -21,7 +21,7 @@ import org.springframework.cloud.contract.spec.internal.HttpMethods
contract {
request {
method = method("POST")
method = POST
url = url("/tests")
multipart = multipart(mapOf(
"file1" to named(
@@ -40,7 +40,7 @@ contract {
}
}
response {
status = code(200)
status = OK
body = body("status" to "ok")
headers {
contentType("application/json")