Remove charset from all response content types in samples, as it's been

deprecated in framework.
This commit is contained in:
Olga Maciaszek-Sharma
2019-05-29 22:03:21 +02:00
parent e0fc7aeca8
commit d5a631a561
11 changed files with 15 additions and 19 deletions

View File

@@ -16,7 +16,6 @@
package com.example.fraud;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
@@ -41,7 +40,7 @@ class FraudNameController {
this.fraudVerifier = fraudVerifier;
}
@PutMapping(value = "/frauds/name", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@PutMapping(value = "/frauds/name")
public NameResponse checkByName(@RequestBody NameRequest request) {
boolean fraud = this.fraudVerifier.isFraudByName(request.getName());
if (fraud) {
@@ -51,7 +50,7 @@ class FraudNameController {
"Don't worry " + request.getName() + " you're not a fraud");
}
@GetMapping(value = "/frauds/name", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@GetMapping(value = "/frauds/name")
public String checkByName(@CookieValue("name") String value,
@CookieValue("name2") String value2) {
return value + " " + value2;

View File

@@ -35,7 +35,7 @@ org.springframework.cloud.contract.spec.Contract.make {
result: "Sorry ${fromRequest().body('$.name')} but you're a fraud"
])
headers {
header(contentType(), "${fromRequest().header(contentType())};charset=UTF-8")
header(contentType(), "${fromRequest().header(contentType())}")
}
}
}

View File

@@ -33,7 +33,7 @@ org.springframework.cloud.contract.spec.Contract.make {
result: "Don't worry ${fromRequest().body('$.name')} you're not a fraud"
])
headers {
header(contentType(), "${fromRequest().header(contentType())};charset=UTF-8")
header(contentType(), "${fromRequest().header(contentType())}")
}
}
}

View File

@@ -22,7 +22,6 @@ import com.example.fraud.model.FraudCheck;
import com.example.fraud.model.FraudCheckResult;
import com.example.fraud.model.FraudCheckStatus;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -39,7 +38,7 @@ public class FraudDetectionController {
private static final BigDecimal MAX_AMOUNT = new BigDecimal("5000");
// tag::server_api[]
@RequestMapping(value = "/fraudcheck", method = PUT, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@RequestMapping(value = "/fraudcheck", method = PUT)
public FraudCheckResult fraudCheck(@RequestBody FraudCheck fraudCheck) {
// end::server_api[]
// tag::new_impl[]

View File

@@ -16,7 +16,6 @@
package com.example.fraud;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@@ -39,7 +38,7 @@ class FraudNameController {
this.fraudVerifier = fraudVerifier;
}
@PutMapping(value = "/frauds/name", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@PutMapping(value = "/frauds/name")
public NameResponse checkByName(@RequestBody NameRequest request) {
boolean fraud = this.fraudVerifier.isFraudByName(request.getName());
if (fraud) {

View File

@@ -16,7 +16,6 @@
package com.example.fraud;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -41,12 +40,12 @@ public class FraudStatsController {
this.statsProvider = statsProvider;
}
@GetMapping(value = "/frauds", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@GetMapping(value = "/frauds")
public Response countAllFrauds() {
return new Response(this.statsProvider.count(FraudType.ALL));
}
@GetMapping(value = "/drunks", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@GetMapping(value = "/drunks")
public Response countAllDrunks() {
return new Response(this.statsProvider.count(FraudType.DRUNKS));
}

View File

@@ -17,7 +17,7 @@ response: # (7)
fraudCheckStatus: "FRAUD"
"rejection.reason": "Amount too high"
headers: # (10)
Content-Type: application/json;charset=UTF-8
Content-Type: application/json
#From the Consumer perspective, when shooting a request in the integration test:
@@ -49,4 +49,4 @@ response: # (7)
#(8) - status equal `200`
#(9) - and JSON body equal to
# { "fraudCheckStatus": "FRAUD", "rejectionReason": "Amount too high" }
#(10) - with header `Content-Type` equal to `application/json;charset=UTF-8`
#(10) - with header `Content-Type` equal to `application/json`

View File

@@ -17,7 +17,7 @@ response:
fraudCheckStatus: "OK"
"rejection.reason": null
headers:
Content-Type: application/json;charset=UTF-8
Content-Type: application/json
matchers:
body:
- path: $.['rejection.reason']

View File

@@ -8,7 +8,7 @@ response:
body:
count: 200
headers:
Content-Type: application/json;charset=UTF-8
Content-Type: application/json
---
request:
method: GET
@@ -18,4 +18,4 @@ response:
body:
count: 100
headers:
Content-Type: application/json;charset=UTF-8
Content-Type: application/json

View File

@@ -6,7 +6,7 @@ request:
body:
name: "fraud"
headers:
Content-Type: application/json;charset=UTF-8
Content-Type: application/json
response:
status: 200
body:

View File

@@ -15,4 +15,4 @@ response:
body:
result: "Don't worry {{{ jsonpath this '$.name' }}} you're not a fraud"
headers:
Content-Type: "{{{ request.headers.Content-Type.0 }}};charset=UTF-8"
Content-Type: "{{{ request.headers.Content-Type.0 }}}"