|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2018 the original author or authors. |
| 2 | + * Copyright 2012-2019 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -46,70 +46,51 @@ public void testHome() throws Exception {
|
46 | 46 | }
|
47 | 47 |
|
48 | 48 | @Test
|
49 |
| - public void errorFromExceptionForRequestAcceptingAnythingProducesAJsonResponse() |
50 |
| - throws Exception { |
51 |
| - assertThatErrorFromExceptionProducesExpectedResponse(MediaType.ALL, |
52 |
| - MediaType.APPLICATION_JSON); |
| 49 | + public void errorFromExceptionForRequestAcceptingAnythingProducesAJsonResponse() throws Exception { |
| 50 | + assertThatErrorFromExceptionProducesExpectedResponse(MediaType.ALL, MediaType.APPLICATION_JSON); |
53 | 51 | }
|
54 | 52 |
|
55 | 53 | @Test
|
56 |
| - public void errorFromExceptionForRequestAcceptingJsonProducesAJsonResponse() |
57 |
| - throws Exception { |
58 |
| - assertThatErrorFromExceptionProducesExpectedResponse(MediaType.APPLICATION_JSON, |
59 |
| - MediaType.APPLICATION_JSON); |
| 54 | + public void errorFromExceptionForRequestAcceptingJsonProducesAJsonResponse() throws Exception { |
| 55 | + assertThatErrorFromExceptionProducesExpectedResponse(MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON); |
60 | 56 | }
|
61 | 57 |
|
62 | 58 | @Test
|
63 |
| - public void errorFromExceptionForRequestAcceptingHtmlProducesAnHtmlResponse() |
64 |
| - throws Exception { |
65 |
| - assertThatErrorFromExceptionProducesExpectedResponse(MediaType.TEXT_HTML, |
66 |
| - MediaType.TEXT_HTML); |
| 59 | + public void errorFromExceptionForRequestAcceptingHtmlProducesAnHtmlResponse() throws Exception { |
| 60 | + assertThatErrorFromExceptionProducesExpectedResponse(MediaType.TEXT_HTML, MediaType.TEXT_HTML); |
67 | 61 | }
|
68 | 62 |
|
69 | 63 | @Test
|
70 |
| - public void sendErrorForRequestAcceptingAnythingProducesAJsonResponse() |
71 |
| - throws Exception { |
72 |
| - assertThatSendErrorProducesExpectedResponse(MediaType.ALL, |
73 |
| - MediaType.APPLICATION_JSON); |
| 64 | + public void sendErrorForRequestAcceptingAnythingProducesAJsonResponse() throws Exception { |
| 65 | + assertThatSendErrorProducesExpectedResponse(MediaType.ALL, MediaType.APPLICATION_JSON); |
74 | 66 | }
|
75 | 67 |
|
76 | 68 | @Test
|
77 | 69 | public void sendErrorForRequestAcceptingJsonProducesAJsonResponse() throws Exception {
|
78 |
| - assertThatSendErrorProducesExpectedResponse(MediaType.APPLICATION_JSON, |
79 |
| - MediaType.APPLICATION_JSON); |
| 70 | + assertThatSendErrorProducesExpectedResponse(MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON); |
80 | 71 | }
|
81 | 72 |
|
82 | 73 | @Test
|
83 |
| - public void sendErrorForRequestAcceptingHtmlProducesAnHtmlResponse() |
84 |
| - throws Exception { |
85 |
| - assertThatSendErrorProducesExpectedResponse(MediaType.TEXT_HTML, |
86 |
| - MediaType.TEXT_HTML); |
| 74 | + public void sendErrorForRequestAcceptingHtmlProducesAnHtmlResponse() throws Exception { |
| 75 | + assertThatSendErrorProducesExpectedResponse(MediaType.TEXT_HTML, MediaType.TEXT_HTML); |
87 | 76 | }
|
88 | 77 |
|
89 |
| - private void assertThatSendErrorProducesExpectedResponse(MediaType accept, |
90 |
| - MediaType contentType) { |
| 78 | + private void assertThatSendErrorProducesExpectedResponse(MediaType accept, MediaType contentType) { |
91 | 79 | RequestEntity<Void> request = RequestEntity
|
92 |
| - .get(URI.create("http://localhost:" + this.port + "/bootapp/send-error")) |
93 |
| - .accept(accept).build(); |
| 80 | + .get(URI.create("http://localhost:" + this.port + "/bootapp/send-error")).accept(accept).build(); |
94 | 81 | ResponseEntity<String> response = this.rest.exchange(request, String.class);
|
95 | 82 | assertThat(response.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
|
96 | 83 | assertThat(contentType.isCompatibleWith(response.getHeaders().getContentType()))
|
97 |
| - .as("%s is compatible with %s", contentType, |
98 |
| - response.getHeaders().getContentType()) |
99 |
| - .isTrue(); |
| 84 | + .as("%s is compatible with %s", contentType, response.getHeaders().getContentType()).isTrue(); |
100 | 85 | }
|
101 | 86 |
|
102 |
| - private void assertThatErrorFromExceptionProducesExpectedResponse(MediaType accept, |
103 |
| - MediaType contentType) { |
| 87 | + private void assertThatErrorFromExceptionProducesExpectedResponse(MediaType accept, MediaType contentType) { |
104 | 88 | RequestEntity<Void> request = RequestEntity
|
105 |
| - .get(URI.create("http://localhost:" + this.port + "/bootapp/exception")) |
106 |
| - .accept(accept).build(); |
| 89 | + .get(URI.create("http://localhost:" + this.port + "/bootapp/exception")).accept(accept).build(); |
107 | 90 | ResponseEntity<String> response = this.rest.exchange(request, String.class);
|
108 | 91 | assertThat(response.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
|
109 | 92 | assertThat(contentType.isCompatibleWith(response.getHeaders().getContentType()))
|
110 |
| - .as("%s is compatible with %s", contentType, |
111 |
| - response.getHeaders().getContentType()) |
112 |
| - .isTrue(); |
| 93 | + .as("%s is compatible with %s", contentType, response.getHeaders().getContentType()).isTrue(); |
113 | 94 | }
|
114 | 95 |
|
115 | 96 | }
|
0 commit comments