From ebe70a91c7fc8cb9a5044e6f62112bcc57d441aa Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 15 Jul 2022 12:38:25 +0100 Subject: [PATCH] Remove redundant throws declarations from non public API Closes gh-828 --- .../restassured/EveryTestPreprocessing.java | 4 +- .../com/example/restassured/HttpHeaders.java | 4 +- .../com/example/restassured/Hypermedia.java | 6 +-- .../example/restassured/InvokeService.java | 4 +- .../example/restassured/PathParameters.java | 4 +- .../java/com/example/restassured/Payload.java | 16 ++++---- .../restassured/PerTestPreprocessing.java | 4 +- .../restassured/RequestParameters.java | 6 +-- .../restassured/RequestPartPayload.java | 6 +-- .../com/example/restassured/RequestParts.java | 4 +- .../restassured/RestAssuredSnippetReuse.java | 4 +- .../webtestclient/EveryTestPreprocessing.java | 4 +- .../example/webtestclient/HttpHeaders.java | 4 +- .../com/example/webtestclient/Hypermedia.java | 6 +-- .../example/webtestclient/InvokeService.java | 4 +- .../example/webtestclient/PathParameters.java | 4 +- .../com/example/webtestclient/Payload.java | 16 ++++---- .../webtestclient/RequestParameters.java | 6 +-- .../webtestclient/RequestPartPayload.java | 6 +-- .../example/webtestclient/RequestParts.java | 4 +- .../WebTestClientSnippetReuse.java | 4 +- .../SampleRestAssuredApplicationTests.java | 4 +- .../SampleWebTestClientApplicationTests.java | 4 +- .../SnippetsDirectoryResolverTests.java | 14 +++---- .../RequestHeadersSnippetFailureTests.java | 5 +-- .../ResponseHeadersSnippetFailureTests.java | 5 +-- .../hypermedia/LinksSnippetFailureTests.java | 9 ++--- .../PatternReplacingContentModifierTests.java | 6 +-- .../PrettyPrintingContentModifierTests.java | 12 +++--- ...ldPathPayloadSubsectionExtractorTests.java | 15 +++---- .../payload/JsonContentHandlerTests.java | 5 +-- .../payload/JsonFieldProcessorTests.java | 34 ++++++++-------- .../RequestFieldsSnippetFailureTests.java | 31 +++++++-------- .../RequestPartFieldsSnippetFailureTests.java | 7 ++-- .../ResponseFieldsSnippetFailureTests.java | 25 ++++++------ .../PathParametersSnippetFailureTests.java | 9 ++--- .../RequestParametersSnippetFailureTests.java | 7 ++-- .../RequestPartsSnippetFailureTests.java | 7 ++-- ...tationContextPlaceholderResolverTests.java | 28 ++++++------- ...StandardTemplateResourceResolverTests.java | 12 ++++-- .../RestDocumentationResultHandler.java | 4 +- .../mockmvc/MockMvcRequestConverterTests.java | 33 ++++++++-------- ...uredRestDocumentationIntegrationTests.java | 39 ++++++++++--------- .../WebTestClientRequestConverterTests.java | 18 ++++----- ...ientRestDocumentationIntegrationTests.java | 12 +++--- 45 files changed, 228 insertions(+), 237 deletions(-) diff --git a/docs/src/test/java/com/example/restassured/EveryTestPreprocessing.java b/docs/src/test/java/com/example/restassured/EveryTestPreprocessing.java index f92d6e36..bf8f155e 100644 --- a/docs/src/test/java/com/example/restassured/EveryTestPreprocessing.java +++ b/docs/src/test/java/com/example/restassured/EveryTestPreprocessing.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2021 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ public class EveryTestPreprocessing { } // end::setup[] - public void use() throws Exception { + public void use() { // tag::use[] RestAssured.given(this.spec) .filter(document("index", links(linkWithRel("self").description("Canonical self link")))).when() diff --git a/docs/src/test/java/com/example/restassured/HttpHeaders.java b/docs/src/test/java/com/example/restassured/HttpHeaders.java index 09bcaf68..ff162ae7 100644 --- a/docs/src/test/java/com/example/restassured/HttpHeaders.java +++ b/docs/src/test/java/com/example/restassured/HttpHeaders.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2021 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ public class HttpHeaders { private RequestSpecification spec; - public void headers() throws Exception { + public void headers() { // tag::headers[] RestAssured.given(this.spec).filter(document("headers", requestHeaders(// <1> headerWithName("Authorization").description("Basic auth credentials")), // <2> diff --git a/docs/src/test/java/com/example/restassured/Hypermedia.java b/docs/src/test/java/com/example/restassured/Hypermedia.java index 1d013702..0bc799f3 100644 --- a/docs/src/test/java/com/example/restassured/Hypermedia.java +++ b/docs/src/test/java/com/example/restassured/Hypermedia.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2021 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ public class Hypermedia { private RequestSpecification spec; - public void defaultExtractor() throws Exception { + public void defaultExtractor() { // tag::links[] RestAssured.given(this.spec).accept("application/json").filter(document("index", links(// <1> linkWithRel("alpha").description("Link to the alpha resource"), // <2> @@ -38,7 +38,7 @@ public class Hypermedia { // end::links[] } - public void explicitExtractor() throws Exception { + public void explicitExtractor() { RestAssured.given(this.spec).accept("application/json") // tag::explicit-extractor[] .filter(document("index", links(halLinks(), // <1> diff --git a/docs/src/test/java/com/example/restassured/InvokeService.java b/docs/src/test/java/com/example/restassured/InvokeService.java index 5937b15a..737406ac 100644 --- a/docs/src/test/java/com/example/restassured/InvokeService.java +++ b/docs/src/test/java/com/example/restassured/InvokeService.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2021 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,7 @@ public class InvokeService { private RequestSpecification spec; - public void invokeService() throws Exception { + public void invokeService() { // tag::invoke-service[] RestAssured.given(this.spec) // <1> .accept("application/json") // <2> diff --git a/docs/src/test/java/com/example/restassured/PathParameters.java b/docs/src/test/java/com/example/restassured/PathParameters.java index 0da95f00..01f445df 100644 --- a/docs/src/test/java/com/example/restassured/PathParameters.java +++ b/docs/src/test/java/com/example/restassured/PathParameters.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2021 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,7 @@ public class PathParameters { private RequestSpecification spec; - public void pathParametersSnippet() throws Exception { + public void pathParametersSnippet() { // tag::path-parameters[] RestAssured.given(this.spec).filter(document("locations", pathParameters(// <1> parameterWithName("latitude").description("The location's latitude"), // <2> diff --git a/docs/src/test/java/com/example/restassured/Payload.java b/docs/src/test/java/com/example/restassured/Payload.java index 22dfb5d7..66046623 100644 --- a/docs/src/test/java/com/example/restassured/Payload.java +++ b/docs/src/test/java/com/example/restassured/Payload.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2021 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ public class Payload { private RequestSpecification spec; - public void response() throws Exception { + public void response() { // tag::response[] RestAssured.given(this.spec).accept("application/json").filter(document("user", responseFields(// <1> fieldWithPath("contact.name").description("The user's name"), // <2> @@ -46,7 +46,7 @@ public class Payload { // end::response[] } - public void subsection() throws Exception { + public void subsection() { // tag::subsection[] RestAssured.given(this.spec).accept("application/json") .filter(document("user", @@ -55,7 +55,7 @@ public class Payload { // end::subsection[] } - public void explicitType() throws Exception { + public void explicitType() { RestAssured.given(this.spec).accept("application/json") // tag::explicit-type[] .filter(document("user", responseFields(fieldWithPath("contact.email").type(JsonFieldType.STRING) // <1> @@ -64,7 +64,7 @@ public class Payload { .when().get("/user/5").then().assertThat().statusCode(is(200)); } - public void constraints() throws Exception { + public void constraints() { RestAssured.given(this.spec).accept("application/json") // tag::constraints[] .filter(document("create-user", @@ -77,7 +77,7 @@ public class Payload { .when().post("/users").then().assertThat().statusCode(is(200)); } - public void descriptorReuse() throws Exception { + public void descriptorReuse() { FieldDescriptor[] book = new FieldDescriptor[] { fieldWithPath("title").description("Title of the book"), fieldWithPath("author").description("Author of the book") }; @@ -94,7 +94,7 @@ public class Payload { // end::book-array[] } - public void fieldsSubsection() throws Exception { + public void fieldsSubsection() { // tag::fields-subsection[] RestAssured.given(this.spec).accept("application/json") .filter(document("location", responseFields(beneathPath("weather.temperature"), // <1> @@ -104,7 +104,7 @@ public class Payload { // end::fields-subsection[] } - public void bodySubsection() throws Exception { + public void bodySubsection() { // tag::body-subsection[] RestAssured.given(this.spec).accept("application/json") .filter(document("location", responseBody(beneathPath("weather.temperature")))) // <1> diff --git a/docs/src/test/java/com/example/restassured/PerTestPreprocessing.java b/docs/src/test/java/com/example/restassured/PerTestPreprocessing.java index 2f63dfc9..cc0e1a10 100644 --- a/docs/src/test/java/com/example/restassured/PerTestPreprocessing.java +++ b/docs/src/test/java/com/example/restassured/PerTestPreprocessing.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2021 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ public class PerTestPreprocessing { private RequestSpecification spec; - public void general() throws Exception { + public void general() { // tag::preprocessing[] RestAssured.given(this.spec).filter(document("index", preprocessRequest(removeHeaders("Foo")), // <1> preprocessResponse(prettyPrint()))) // <2> diff --git a/docs/src/test/java/com/example/restassured/RequestParameters.java b/docs/src/test/java/com/example/restassured/RequestParameters.java index 40a48fa7..c2d4d5cc 100644 --- a/docs/src/test/java/com/example/restassured/RequestParameters.java +++ b/docs/src/test/java/com/example/restassured/RequestParameters.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2021 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,7 @@ public class RequestParameters { private RequestSpecification spec; - public void getQueryStringSnippet() throws Exception { + public void getQueryStringSnippet() { // tag::request-parameters-query-string[] RestAssured.given(this.spec).filter(document("users", requestParameters(// <1> parameterWithName("page").description("The page to retrieve"), // <2> @@ -38,7 +38,7 @@ public class RequestParameters { // end::request-parameters-query-string[] } - public void postFormDataSnippet() throws Exception { + public void postFormDataSnippet() { // tag::request-parameters-form-data[] RestAssured.given(this.spec) .filter(document("create-user", diff --git a/docs/src/test/java/com/example/restassured/RequestPartPayload.java b/docs/src/test/java/com/example/restassured/RequestPartPayload.java index 5dcfc7fc..68d61bac 100644 --- a/docs/src/test/java/com/example/restassured/RequestPartPayload.java +++ b/docs/src/test/java/com/example/restassured/RequestPartPayload.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2021 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ public class RequestPartPayload { private RequestSpecification spec; - public void fields() throws Exception { + public void fields() { // tag::fields[] Map metadata = new HashMap<>(); metadata.put("version", "1.0"); @@ -45,7 +45,7 @@ public class RequestPartPayload { // end::fields[] } - public void body() throws Exception { + public void body() { // tag::body[] Map metadata = new HashMap<>(); metadata.put("version", "1.0"); diff --git a/docs/src/test/java/com/example/restassured/RequestParts.java b/docs/src/test/java/com/example/restassured/RequestParts.java index 70059b12..31ebdb1b 100644 --- a/docs/src/test/java/com/example/restassured/RequestParts.java +++ b/docs/src/test/java/com/example/restassured/RequestParts.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2021 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,7 @@ public class RequestParts { private RequestSpecification spec; - public void upload() throws Exception { + public void upload() { // tag::request-parts[] RestAssured.given(this.spec).filter(document("users", requestParts(// <1> partWithName("file").description("The file to upload")))) // <2> diff --git a/docs/src/test/java/com/example/restassured/RestAssuredSnippetReuse.java b/docs/src/test/java/com/example/restassured/RestAssuredSnippetReuse.java index 1668cc5e..2a2c8567 100644 --- a/docs/src/test/java/com/example/restassured/RestAssuredSnippetReuse.java +++ b/docs/src/test/java/com/example/restassured/RestAssuredSnippetReuse.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2021 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,7 @@ public class RestAssuredSnippetReuse extends SnippetReuse { private RequestSpecification spec; - public void documentation() throws Exception { + public void documentation() { // tag::use[] RestAssured.given(this.spec).accept("application/json").filter(document("example", this.pagingLinks.and(// <1> linkWithRel("alpha").description("Link to the alpha resource"), diff --git a/docs/src/test/java/com/example/webtestclient/EveryTestPreprocessing.java b/docs/src/test/java/com/example/webtestclient/EveryTestPreprocessing.java index 4b08af95..f628ab23 100644 --- a/docs/src/test/java/com/example/webtestclient/EveryTestPreprocessing.java +++ b/docs/src/test/java/com/example/webtestclient/EveryTestPreprocessing.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ public class EveryTestPreprocessing { } // end::setup[] - public void use() throws Exception { + public void use() { // tag::use[] this.webTestClient.get().uri("/").exchange().expectStatus().isOk() .expectBody().consumeWith(document("index", diff --git a/docs/src/test/java/com/example/webtestclient/HttpHeaders.java b/docs/src/test/java/com/example/webtestclient/HttpHeaders.java index 7f8a2c0b..9e004185 100644 --- a/docs/src/test/java/com/example/webtestclient/HttpHeaders.java +++ b/docs/src/test/java/com/example/webtestclient/HttpHeaders.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ public class HttpHeaders { private WebTestClient webTestClient; - public void headers() throws Exception { + public void headers() { // tag::headers[] this.webTestClient .get().uri("/people").header("Authorization", "Basic dXNlcjpzZWNyZXQ=") // <1> diff --git a/docs/src/test/java/com/example/webtestclient/Hypermedia.java b/docs/src/test/java/com/example/webtestclient/Hypermedia.java index be247cb0..fcc7eb81 100644 --- a/docs/src/test/java/com/example/webtestclient/Hypermedia.java +++ b/docs/src/test/java/com/example/webtestclient/Hypermedia.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2021 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,7 @@ public class Hypermedia { private WebTestClient webTestClient; - public void defaultExtractor() throws Exception { + public void defaultExtractor() { // tag::links[] this.webTestClient.get().uri("/").accept(MediaType.APPLICATION_JSON).exchange().expectStatus().isOk() .expectBody().consumeWith(document("index", links(// <1> @@ -37,7 +37,7 @@ public class Hypermedia { // end::links[] } - public void explicitExtractor() throws Exception { + public void explicitExtractor() { this.webTestClient.get().uri("/").accept(MediaType.APPLICATION_JSON).exchange().expectStatus().isOk() .expectBody() // tag::explicit-extractor[] diff --git a/docs/src/test/java/com/example/webtestclient/InvokeService.java b/docs/src/test/java/com/example/webtestclient/InvokeService.java index 46270c9b..5f28ea9b 100644 --- a/docs/src/test/java/com/example/webtestclient/InvokeService.java +++ b/docs/src/test/java/com/example/webtestclient/InvokeService.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,7 @@ public class InvokeService { private WebTestClient webTestClient; - public void invokeService() throws Exception { + public void invokeService() { // tag::invoke-service[] this.webTestClient.get().uri("/").accept(MediaType.APPLICATION_JSON) // <1> .exchange().expectStatus().isOk() // <2> diff --git a/docs/src/test/java/com/example/webtestclient/PathParameters.java b/docs/src/test/java/com/example/webtestclient/PathParameters.java index 6627c701..5199f680 100644 --- a/docs/src/test/java/com/example/webtestclient/PathParameters.java +++ b/docs/src/test/java/com/example/webtestclient/PathParameters.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,7 @@ public class PathParameters { private WebTestClient webTestClient; - public void pathParametersSnippet() throws Exception { + public void pathParametersSnippet() { // tag::path-parameters[] this.webTestClient.get().uri("/locations/{latitude}/{longitude}", 51.5072, 0.1275) // <1> .exchange().expectStatus().isOk().expectBody() diff --git a/docs/src/test/java/com/example/webtestclient/Payload.java b/docs/src/test/java/com/example/webtestclient/Payload.java index e9b116f5..d7d828e5 100644 --- a/docs/src/test/java/com/example/webtestclient/Payload.java +++ b/docs/src/test/java/com/example/webtestclient/Payload.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ public class Payload { private WebTestClient webTestClient; - public void response() throws Exception { + public void response() { // tag::response[] this.webTestClient.get().uri("user/5").accept(MediaType.APPLICATION_JSON) .exchange().expectStatus().isOk().expectBody() @@ -48,7 +48,7 @@ public class Payload { // end::response[] } - public void subsection() throws Exception { + public void subsection() { // tag::subsection[] this.webTestClient.get().uri("user/5").accept(MediaType.APPLICATION_JSON) .exchange().expectStatus().isOk().expectBody() @@ -58,7 +58,7 @@ public class Payload { // end::subsection[] } - public void explicitType() throws Exception { + public void explicitType() { this.webTestClient.get().uri("user/5").accept(MediaType.APPLICATION_JSON) .exchange().expectStatus().isOk().expectBody() // tag::explicit-type[] @@ -70,7 +70,7 @@ public class Payload { // end::explicit-type[] } - public void constraints() throws Exception { + public void constraints() { this.webTestClient.get().uri("user/5").accept(MediaType.APPLICATION_JSON) .exchange().expectStatus().isOk().expectBody() // tag::constraints[] @@ -86,7 +86,7 @@ public class Payload { // end::constraints[] } - public void descriptorReuse() throws Exception { + public void descriptorReuse() { FieldDescriptor[] book = new FieldDescriptor[] { fieldWithPath("title").description("Title of the book"), fieldWithPath("author").description("Author of the book") }; @@ -109,7 +109,7 @@ public class Payload { // end::book-array[] } - public void fieldsSubsection() throws Exception { + public void fieldsSubsection() { // tag::fields-subsection[] this.webTestClient.get().uri("/locations/1").accept(MediaType.APPLICATION_JSON) .exchange().expectStatus().isOk().expectBody() @@ -120,7 +120,7 @@ public class Payload { // end::fields-subsection[] } - public void bodySubsection() throws Exception { + public void bodySubsection() { // tag::body-subsection[] this.webTestClient.get().uri("/locations/1").accept(MediaType.APPLICATION_JSON) .exchange().expectStatus().isOk().expectBody() diff --git a/docs/src/test/java/com/example/webtestclient/RequestParameters.java b/docs/src/test/java/com/example/webtestclient/RequestParameters.java index aa312832..de0cb239 100644 --- a/docs/src/test/java/com/example/webtestclient/RequestParameters.java +++ b/docs/src/test/java/com/example/webtestclient/RequestParameters.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ public class RequestParameters { private WebTestClient webTestClient; - public void getQueryStringSnippet() throws Exception { + public void getQueryStringSnippet() { // tag::request-parameters-query-string[] this.webTestClient.get().uri("/users?page=2&per_page=100") // <1> .exchange().expectStatus().isOk().expectBody() @@ -42,7 +42,7 @@ public class RequestParameters { // end::request-parameters-query-string[] } - public void postFormDataSnippet() throws Exception { + public void postFormDataSnippet() { // tag::request-parameters-form-data[] MultiValueMap formData = new LinkedMultiValueMap<>(); formData.add("username", "Tester"); diff --git a/docs/src/test/java/com/example/webtestclient/RequestPartPayload.java b/docs/src/test/java/com/example/webtestclient/RequestPartPayload.java index a2df783e..e8812627 100644 --- a/docs/src/test/java/com/example/webtestclient/RequestPartPayload.java +++ b/docs/src/test/java/com/example/webtestclient/RequestPartPayload.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ public class RequestPartPayload { private WebTestClient webTestClient; - public void fields() throws Exception { + public void fields() { // tag::fields[] MultiValueMap multipartData = new LinkedMultiValueMap<>(); Resource imageResource = new ByteArrayResource("<>".getBytes()) { @@ -59,7 +59,7 @@ public class RequestPartPayload { // end::fields[] } - public void body() throws Exception { + public void body() { // tag::body[] MultiValueMap multipartData = new LinkedMultiValueMap<>(); Resource imageResource = new ByteArrayResource("<>".getBytes()) { diff --git a/docs/src/test/java/com/example/webtestclient/RequestParts.java b/docs/src/test/java/com/example/webtestclient/RequestParts.java index e1115fb8..5d65f091 100644 --- a/docs/src/test/java/com/example/webtestclient/RequestParts.java +++ b/docs/src/test/java/com/example/webtestclient/RequestParts.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ public class RequestParts { private WebTestClient webTestClient; - public void upload() throws Exception { + public void upload() { // tag::request-parts[] MultiValueMap multipartData = new LinkedMultiValueMap<>(); multipartData.add("file", "example".getBytes()); diff --git a/docs/src/test/java/com/example/webtestclient/WebTestClientSnippetReuse.java b/docs/src/test/java/com/example/webtestclient/WebTestClientSnippetReuse.java index 110835b4..6f57fc91 100644 --- a/docs/src/test/java/com/example/webtestclient/WebTestClientSnippetReuse.java +++ b/docs/src/test/java/com/example/webtestclient/WebTestClientSnippetReuse.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ public class WebTestClientSnippetReuse extends SnippetReuse { private WebTestClient webTestClient; - public void documentation() throws Exception { + public void documentation() { // tag::use[] this.webTestClient.get().uri("/").accept(MediaType.APPLICATION_JSON).exchange() .expectStatus().isOk().expectBody() diff --git a/samples/rest-assured/src/test/java/com/example/restassured/SampleRestAssuredApplicationTests.java b/samples/rest-assured/src/test/java/com/example/restassured/SampleRestAssuredApplicationTests.java index 32e7044a..cce7beb6 100644 --- a/samples/rest-assured/src/test/java/com/example/restassured/SampleRestAssuredApplicationTests.java +++ b/samples/rest-assured/src/test/java/com/example/restassured/SampleRestAssuredApplicationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2018 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,7 +55,7 @@ public class SampleRestAssuredApplicationTests { } @Test - public void sample() throws Exception { + public void sample() { given(this.documentationSpec) .accept("text/plain") .filter(document("sample", diff --git a/samples/web-test-client/src/test/java/com/example/webtestclient/SampleWebTestClientApplicationTests.java b/samples/web-test-client/src/test/java/com/example/webtestclient/SampleWebTestClientApplicationTests.java index 281adaaa..47e2ffc0 100644 --- a/samples/web-test-client/src/test/java/com/example/webtestclient/SampleWebTestClientApplicationTests.java +++ b/samples/web-test-client/src/test/java/com/example/webtestclient/SampleWebTestClientApplicationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2017 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,7 +51,7 @@ public class SampleWebTestClientApplicationTests { } @Test - public void sample() throws Exception { + public void sample() { this.webTestClient.get().uri("/").exchange() .expectStatus().isOk().expectBody() .consumeWith(document("sample")); diff --git a/spring-restdocs-asciidoctor-support/src/test/java/org/springframework/restdocs/asciidoctor/SnippetsDirectoryResolverTests.java b/spring-restdocs-asciidoctor-support/src/test/java/org/springframework/restdocs/asciidoctor/SnippetsDirectoryResolverTests.java index ebb7dc37..4af5463e 100644 --- a/spring-restdocs-asciidoctor-support/src/test/java/org/springframework/restdocs/asciidoctor/SnippetsDirectoryResolverTests.java +++ b/spring-restdocs-asciidoctor-support/src/test/java/org/springframework/restdocs/asciidoctor/SnippetsDirectoryResolverTests.java @@ -49,7 +49,7 @@ public class SnippetsDirectoryResolverTests { } @Test - public void illegalStateExceptionWhenMavenPomCannotBeFound() throws IOException { + public void illegalStateExceptionWhenMavenPomCannotBeFound() { Map attributes = new HashMap<>(); String docdir = new File(this.temporaryFolder.getRoot(), "src/main/asciidoc").getAbsolutePath(); attributes.put("docdir", docdir); @@ -58,14 +58,14 @@ public class SnippetsDirectoryResolverTests { } @Test - public void illegalStateWhenDocdirAttributeIsNotSetInMavenProject() throws IOException { + public void illegalStateWhenDocdirAttributeIsNotSetInMavenProject() { Map attributes = new HashMap<>(); assertThatIllegalStateException().isThrownBy(() -> getMavenSnippetsDirectory(attributes)) .withMessage("docdir attribute not found"); } @Test - public void gradleProjectsUseBuildGeneratedSnippetsBeneathGradleProjectdir() throws IOException { + public void gradleProjectsUseBuildGeneratedSnippetsBeneathGradleProjectdir() { Map attributes = new HashMap<>(); attributes.put("gradle-projectdir", "project/dir"); File snippetsDirectory = new SnippetsDirectoryResolver().getSnippetsDirectory(attributes); @@ -73,8 +73,7 @@ public class SnippetsDirectoryResolverTests { } @Test - public void gradleProjectsUseBuildGeneratedSnippetsBeneathGradleProjectdirWhenBothItAndProjectdirAreSet() - throws IOException { + public void gradleProjectsUseBuildGeneratedSnippetsBeneathGradleProjectdirWhenBothItAndProjectdirAreSet() { Map attributes = new HashMap<>(); attributes.put("gradle-projectdir", "project/dir"); attributes.put("projectdir", "fallback/dir"); @@ -83,8 +82,7 @@ public class SnippetsDirectoryResolverTests { } @Test - public void gradleProjectsUseBuildGeneratedSnippetsBeneathProjectdirWhenGradleProjectdirIsNotSet() - throws IOException { + public void gradleProjectsUseBuildGeneratedSnippetsBeneathProjectdirWhenGradleProjectdirIsNotSet() { Map attributes = new HashMap<>(); attributes.put("projectdir", "project/dir"); File snippetsDirectory = new SnippetsDirectoryResolver().getSnippetsDirectory(attributes); @@ -92,7 +90,7 @@ public class SnippetsDirectoryResolverTests { } @Test - public void illegalStateWhenGradleProjectdirAndProjectdirAttributesAreNotSetInGradleProject() throws IOException { + public void illegalStateWhenGradleProjectdirAndProjectdirAttributesAreNotSetInGradleProject() { Map attributes = new HashMap<>(); assertThatIllegalStateException() .isThrownBy(() -> new SnippetsDirectoryResolver().getSnippetsDirectory(attributes)) diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/headers/RequestHeadersSnippetFailureTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/headers/RequestHeadersSnippetFailureTests.java index e8e16867..0b5c9a19 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/headers/RequestHeadersSnippetFailureTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/headers/RequestHeadersSnippetFailureTests.java @@ -16,7 +16,6 @@ package org.springframework.restdocs.headers; -import java.io.IOException; import java.util.Arrays; import org.junit.Rule; @@ -41,7 +40,7 @@ public class RequestHeadersSnippetFailureTests { public OperationBuilder operationBuilder = new OperationBuilder(TemplateFormats.asciidoctor()); @Test - public void missingRequestHeader() throws IOException { + public void missingRequestHeader() { assertThatExceptionOfType(SnippetException.class) .isThrownBy(() -> new RequestHeadersSnippet(Arrays.asList(headerWithName("Accept").description("one"))) .document(this.operationBuilder.request("http://localhost").build())) @@ -49,7 +48,7 @@ public class RequestHeadersSnippetFailureTests { } @Test - public void undocumentedRequestHeaderAndMissingRequestHeader() throws IOException { + public void undocumentedRequestHeaderAndMissingRequestHeader() { assertThatExceptionOfType(SnippetException.class) .isThrownBy(() -> new RequestHeadersSnippet(Arrays.asList(headerWithName("Accept").description("one"))) .document(this.operationBuilder.request("http://localhost").header("X-Test", "test").build())) diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/headers/ResponseHeadersSnippetFailureTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/headers/ResponseHeadersSnippetFailureTests.java index e2105de0..7d647e1f 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/headers/ResponseHeadersSnippetFailureTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/headers/ResponseHeadersSnippetFailureTests.java @@ -16,7 +16,6 @@ package org.springframework.restdocs.headers; -import java.io.IOException; import java.util.Arrays; import org.junit.Rule; @@ -41,7 +40,7 @@ public class ResponseHeadersSnippetFailureTests { public OperationBuilder operationBuilder = new OperationBuilder(TemplateFormats.asciidoctor()); @Test - public void missingResponseHeader() throws IOException { + public void missingResponseHeader() { assertThatExceptionOfType(SnippetException.class).isThrownBy( () -> new ResponseHeadersSnippet(Arrays.asList(headerWithName("Content-Type").description("one"))) .document(this.operationBuilder.response().build())) @@ -49,7 +48,7 @@ public class ResponseHeadersSnippetFailureTests { } @Test - public void undocumentedResponseHeaderAndMissingResponseHeader() throws IOException { + public void undocumentedResponseHeaderAndMissingResponseHeader() { assertThatExceptionOfType(SnippetException.class).isThrownBy( () -> new ResponseHeadersSnippet(Arrays.asList(headerWithName("Content-Type").description("one"))) .document(this.operationBuilder.response().header("X-Test", "test").build())) diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/hypermedia/LinksSnippetFailureTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/hypermedia/LinksSnippetFailureTests.java index a10ba150..fe6330aa 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/hypermedia/LinksSnippetFailureTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/hypermedia/LinksSnippetFailureTests.java @@ -16,7 +16,6 @@ package org.springframework.restdocs.hypermedia; -import java.io.IOException; import java.util.Arrays; import java.util.Collections; @@ -41,7 +40,7 @@ public class LinksSnippetFailureTests { public OperationBuilder operationBuilder = new OperationBuilder(TemplateFormats.asciidoctor()); @Test - public void undocumentedLink() throws IOException { + public void undocumentedLink() { assertThatExceptionOfType(SnippetException.class) .isThrownBy(() -> new LinksSnippet(new StubLinkExtractor().withLinks(new Link("foo", "bar")), Collections.emptyList()).document(this.operationBuilder.build())) @@ -49,7 +48,7 @@ public class LinksSnippetFailureTests { } @Test - public void missingLink() throws IOException { + public void missingLink() { assertThatExceptionOfType(SnippetException.class) .isThrownBy(() -> new LinksSnippet(new StubLinkExtractor(), Arrays.asList(new LinkDescriptor("foo").description("bar"))) @@ -58,7 +57,7 @@ public class LinksSnippetFailureTests { } @Test - public void undocumentedLinkAndMissingLink() throws IOException { + public void undocumentedLinkAndMissingLink() { assertThatExceptionOfType(SnippetException.class) .isThrownBy(() -> new LinksSnippet(new StubLinkExtractor().withLinks(new Link("a", "alpha")), Arrays.asList(new LinkDescriptor("foo").description("bar"))) @@ -68,7 +67,7 @@ public class LinksSnippetFailureTests { } @Test - public void linkWithNoDescription() throws IOException { + public void linkWithNoDescription() { assertThatExceptionOfType(SnippetException.class) .isThrownBy(() -> new LinksSnippet(new StubLinkExtractor().withLinks(new Link("foo", "bar")), Arrays.asList(new LinkDescriptor("foo"))).document(this.operationBuilder.build())) diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/PatternReplacingContentModifierTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/PatternReplacingContentModifierTests.java index 40930162..9b016561 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/PatternReplacingContentModifierTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/PatternReplacingContentModifierTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat; public class PatternReplacingContentModifierTests { @Test - public void patternsAreReplaced() throws Exception { + public void patternsAreReplaced() { Pattern pattern = Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}", Pattern.CASE_INSENSITIVE); PatternReplacingContentModifier contentModifier = new PatternReplacingContentModifier(pattern, "<>"); @@ -44,7 +44,7 @@ public class PatternReplacingContentModifierTests { } @Test - public void contentThatDoesNotMatchIsUnchanged() throws Exception { + public void contentThatDoesNotMatchIsUnchanged() { Pattern pattern = Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}", Pattern.CASE_INSENSITIVE); PatternReplacingContentModifier contentModifier = new PatternReplacingContentModifier(pattern, "<>"); diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/PrettyPrintingContentModifierTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/PrettyPrintingContentModifierTests.java index adc34708..218a488a 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/PrettyPrintingContentModifierTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/PrettyPrintingContentModifierTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2021 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,13 +39,13 @@ public class PrettyPrintingContentModifierTests { public OutputCaptureRule outputCapture = new OutputCaptureRule(); @Test - public void prettyPrintJson() throws Exception { + public void prettyPrintJson() { assertThat(new PrettyPrintingContentModifier().modifyContent("{\"a\":5}".getBytes(), null)) .isEqualTo(String.format("{%n \"a\" : 5%n}").getBytes()); } @Test - public void prettyPrintXml() throws Exception { + public void prettyPrintXml() { assertThat(new PrettyPrintingContentModifier() .modifyContent("".getBytes(), null)) .isEqualTo(String.format("%n" @@ -53,12 +53,12 @@ public class PrettyPrintingContentModifierTests { } @Test - public void empytContentIsHandledGracefully() throws Exception { + public void empytContentIsHandledGracefully() { assertThat(new PrettyPrintingContentModifier().modifyContent("".getBytes(), null)).isEqualTo("".getBytes()); } @Test - public void nonJsonAndNonXmlContentIsHandledGracefully() throws Exception { + public void nonJsonAndNonXmlContentIsHandledGracefully() { String content = "abcdefg"; assertThat(new PrettyPrintingContentModifier().modifyContent(content.getBytes(), null)) .isEqualTo(content.getBytes()); @@ -66,7 +66,7 @@ public class PrettyPrintingContentModifierTests { } @Test - public void nonJsonContentThatInitiallyLooksLikeJsonIsHandledGracefully() throws Exception { + public void nonJsonContentThatInitiallyLooksLikeJsonIsHandledGracefully() { String content = "\"abc\",\"def\""; assertThat(new PrettyPrintingContentModifier().modifyContent(content.getBytes(), null)) .isEqualTo(content.getBytes()); diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/FieldPathPayloadSubsectionExtractorTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/FieldPathPayloadSubsectionExtractorTests.java index 2d6febba..f8f6c66f 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/FieldPathPayloadSubsectionExtractorTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/FieldPathPayloadSubsectionExtractorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2021 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -99,8 +99,7 @@ public class FieldPathPayloadSubsectionExtractorTests { } @Test - public void extractMapSubsectionWithVaryingStructureFromMultiElementArrayInAJsonMap() - throws JsonParseException, JsonMappingException, IOException { + public void extractMapSubsectionWithVaryingStructureFromMultiElementArrayInAJsonMap() { this.thrown.expect(PayloadHandlingException.class); this.thrown.expectMessage("The following non-optional uncommon paths were found: [a.[].b.d]"); new FieldPathPayloadSubsectionExtractor("a.[].b").extractSubsection( @@ -108,8 +107,7 @@ public class FieldPathPayloadSubsectionExtractorTests { } @Test - public void extractMapSubsectionWithVaryingStructureFromInconsistentJsonMap() - throws JsonParseException, JsonMappingException, IOException { + public void extractMapSubsectionWithVaryingStructureFromInconsistentJsonMap() { this.thrown.expect(PayloadHandlingException.class); this.thrown.expectMessage("The following non-optional uncommon paths were found: [*.d, *.d.e, *.d.f]"); new FieldPathPayloadSubsectionExtractor("*.d").extractSubsection( @@ -117,8 +115,7 @@ public class FieldPathPayloadSubsectionExtractorTests { } @Test - public void extractMapSubsectionWithVaryingStructureFromInconsistentJsonMapWhereAllSubsectionFieldsAreOptional() - throws IOException { + public void extractMapSubsectionWithVaryingStructureFromInconsistentJsonMapWhereAllSubsectionFieldsAreOptional() { this.thrown.expect(PayloadHandlingException.class); this.thrown.expectMessage("The following non-optional uncommon paths were found: [*.d]"); new FieldPathPayloadSubsectionExtractor("*.d").extractSubsection( @@ -176,7 +173,7 @@ public class FieldPathPayloadSubsectionExtractorTests { } @Test - public void extractNonExistentSubsection() throws JsonParseException, JsonMappingException, IOException { + public void extractNonExistentSubsection() { assertThatThrownBy(() -> new FieldPathPayloadSubsectionExtractor("a.c") .extractSubsection("{\"a\":{\"b\":{\"c\":5}}}".getBytes(), MediaType.APPLICATION_JSON)) .isInstanceOf(PayloadHandlingException.class) @@ -184,7 +181,7 @@ public class FieldPathPayloadSubsectionExtractorTests { } @Test - public void extractEmptyArraySubsection() throws JsonParseException, JsonMappingException, IOException { + public void extractEmptyArraySubsection() { assertThatThrownBy(() -> new FieldPathPayloadSubsectionExtractor("a") .extractSubsection("{\"a\":[]}}".getBytes(), MediaType.APPLICATION_JSON)) .isInstanceOf(PayloadHandlingException.class) diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/JsonContentHandlerTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/JsonContentHandlerTests.java index 6785bcac..d859fa4f 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/JsonContentHandlerTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/JsonContentHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,6 @@ package org.springframework.restdocs.payload; -import java.io.IOException; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -102,7 +101,7 @@ public class JsonContentHandlerTests { } @Test - public void typeForFieldWithSometimesPresentOptionalAncestorCanBeProvidedExplicitly() throws IOException { + public void typeForFieldWithSometimesPresentOptionalAncestorCanBeProvidedExplicitly() { FieldDescriptor descriptor = new FieldDescriptor("a.[].b.c").type(JsonFieldType.NUMBER); FieldDescriptor ancestor = new FieldDescriptor("a.[].b").optional(); Object fieldType = new JsonContentHandler("{\"a\":[ { \"d\": 4}, {\"b\":{\"c\":5}, \"d\": 4}]}".getBytes(), diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/JsonFieldProcessorTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/JsonFieldProcessorTests.java index 7304b90e..94ce7ae9 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/JsonFieldProcessorTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/JsonFieldProcessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -306,7 +306,7 @@ public class JsonFieldProcessorTests { } @Test - public void extractNestedEntryWithDotInKeys() throws IOException { + public void extractNestedEntryWithDotInKeys() { Map payload = new HashMap<>(); Map alpha = new HashMap<>(); payload.put("a.key", alpha); @@ -316,7 +316,7 @@ public class JsonFieldProcessorTests { @SuppressWarnings("unchecked") @Test - public void extractNestedEntriesUsingTopLevelWildcard() throws IOException { + public void extractNestedEntriesUsingTopLevelWildcard() { Map payload = new LinkedHashMap<>(); Map alpha = new LinkedHashMap<>(); payload.put("a", alpha); @@ -330,7 +330,7 @@ public class JsonFieldProcessorTests { @SuppressWarnings("unchecked") @Test - public void extractNestedEntriesUsingMidLevelWildcard() throws IOException { + public void extractNestedEntriesUsingMidLevelWildcard() { Map payload = new LinkedHashMap<>(); Map alpha = new LinkedHashMap<>(); payload.put("a", alpha); @@ -344,7 +344,7 @@ public class JsonFieldProcessorTests { @SuppressWarnings("unchecked") @Test - public void extractUsingLeafWildcardMatchingSingleItem() throws IOException { + public void extractUsingLeafWildcardMatchingSingleItem() { Map payload = new HashMap<>(); Map alpha = new HashMap<>(); payload.put("a", alpha); @@ -357,7 +357,7 @@ public class JsonFieldProcessorTests { @SuppressWarnings("unchecked") @Test - public void extractUsingLeafWildcardMatchingMultipleItems() throws IOException { + public void extractUsingLeafWildcardMatchingMultipleItems() { Map payload = new HashMap<>(); Map alpha = new HashMap<>(); payload.put("a", alpha); @@ -368,7 +368,7 @@ public class JsonFieldProcessorTests { } @Test - public void removeUsingLeafWildcard() throws IOException { + public void removeUsingLeafWildcard() { Map payload = new HashMap<>(); Map alpha = new HashMap<>(); payload.put("a", alpha); @@ -379,7 +379,7 @@ public class JsonFieldProcessorTests { } @Test - public void removeUsingTopLevelWildcard() throws IOException { + public void removeUsingTopLevelWildcard() { Map payload = new HashMap<>(); Map alpha = new HashMap<>(); payload.put("a", alpha); @@ -390,7 +390,7 @@ public class JsonFieldProcessorTests { } @Test - public void removeUsingMidLevelWildcard() throws IOException { + public void removeUsingMidLevelWildcard() { Map payload = new LinkedHashMap<>(); Map alpha = new LinkedHashMap<>(); payload.put("a", alpha); @@ -407,28 +407,28 @@ public class JsonFieldProcessorTests { } @Test - public void hasFieldIsTrueForNonNullFieldInMap() throws Exception { + public void hasFieldIsTrueForNonNullFieldInMap() { Map payload = new HashMap<>(); payload.put("a", "alpha"); assertThat(this.fieldProcessor.hasField("a", payload)).isTrue(); } @Test - public void hasFieldIsTrueForNullFieldInMap() throws Exception { + public void hasFieldIsTrueForNullFieldInMap() { Map payload = new HashMap<>(); payload.put("a", null); assertThat(this.fieldProcessor.hasField("a", payload)).isTrue(); } @Test - public void hasFieldIsFalseForAbsentFieldInMap() throws Exception { + public void hasFieldIsFalseForAbsentFieldInMap() { Map payload = new HashMap<>(); payload.put("a", null); assertThat(this.fieldProcessor.hasField("b", payload)).isFalse(); } @Test - public void hasFieldIsTrueForNeverNullFieldBeneathArray() throws Exception { + public void hasFieldIsTrueForNeverNullFieldBeneathArray() { Map payload = new HashMap<>(); Map nested = new HashMap<>(); nested.put("b", "bravo"); @@ -437,7 +437,7 @@ public class JsonFieldProcessorTests { } @Test - public void hasFieldIsTrueForAlwaysNullFieldBeneathArray() throws Exception { + public void hasFieldIsTrueForAlwaysNullFieldBeneathArray() { Map payload = new HashMap<>(); Map nested = new HashMap<>(); nested.put("b", null); @@ -446,7 +446,7 @@ public class JsonFieldProcessorTests { } @Test - public void hasFieldIsFalseForAlwaysAbsentFieldBeneathArray() throws Exception { + public void hasFieldIsFalseForAlwaysAbsentFieldBeneathArray() { Map payload = new HashMap<>(); Map nested = new HashMap<>(); nested.put("b", "bravo"); @@ -455,7 +455,7 @@ public class JsonFieldProcessorTests { } @Test - public void hasFieldIsFalseForOccasionallyAbsentFieldBeneathArray() throws Exception { + public void hasFieldIsFalseForOccasionallyAbsentFieldBeneathArray() { Map payload = new HashMap<>(); Map nested = new HashMap<>(); nested.put("b", "bravo"); @@ -464,7 +464,7 @@ public class JsonFieldProcessorTests { } @Test - public void hasFieldIsFalseForOccasionallyNullFieldBeneathArray() throws Exception { + public void hasFieldIsFalseForOccasionallyNullFieldBeneathArray() { Map payload = new HashMap<>(); Map fieldPresent = new HashMap<>(); fieldPresent.put("b", "bravo"); diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/RequestFieldsSnippetFailureTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/RequestFieldsSnippetFailureTests.java index e9d2f38c..69b81e18 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/RequestFieldsSnippetFailureTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/RequestFieldsSnippetFailureTests.java @@ -16,7 +16,6 @@ package org.springframework.restdocs.payload; -import java.io.IOException; import java.util.Arrays; import java.util.Collections; @@ -44,7 +43,7 @@ public class RequestFieldsSnippetFailureTests { public OperationBuilder operationBuilder = new OperationBuilder(TemplateFormats.asciidoctor()); @Test - public void undocumentedRequestField() throws IOException { + public void undocumentedRequestField() { assertThatExceptionOfType(SnippetException.class) .isThrownBy(() -> new RequestFieldsSnippet(Collections.emptyList()) .document(this.operationBuilder.request("http://localhost").content("{\"a\": 5}").build())) @@ -52,7 +51,7 @@ public class RequestFieldsSnippetFailureTests { } @Test - public void missingRequestField() throws IOException { + public void missingRequestField() { assertThatExceptionOfType(SnippetException.class) .isThrownBy(() -> new RequestFieldsSnippet(Arrays.asList(fieldWithPath("a.b").description("one"))) .document(this.operationBuilder.request("http://localhost").content("{}").build())) @@ -60,14 +59,14 @@ public class RequestFieldsSnippetFailureTests { } @Test - public void missingOptionalRequestFieldWithNoTypeProvided() throws IOException { + public void missingOptionalRequestFieldWithNoTypeProvided() { assertThatExceptionOfType(FieldTypeRequiredException.class).isThrownBy( () -> new RequestFieldsSnippet(Arrays.asList(fieldWithPath("a.b").description("one").optional())) .document(this.operationBuilder.request("http://localhost").content("{ }").build())); } @Test - public void undocumentedRequestFieldAndMissingRequestField() throws IOException { + public void undocumentedRequestFieldAndMissingRequestField() { assertThatExceptionOfType(SnippetException.class).isThrownBy( () -> new RequestFieldsSnippet(Arrays.asList(fieldWithPath("a.b").description("one"))).document( this.operationBuilder.request("http://localhost").content("{ \"a\": { \"c\": 5 }}").build())) @@ -76,7 +75,7 @@ public class RequestFieldsSnippetFailureTests { } @Test - public void attemptToDocumentFieldsWithNoRequestBody() throws IOException { + public void attemptToDocumentFieldsWithNoRequestBody() { assertThatExceptionOfType(SnippetException.class) .isThrownBy(() -> new RequestFieldsSnippet(Arrays.asList(fieldWithPath("a").description("one"))) .document(this.operationBuilder.request("http://localhost").build())) @@ -84,7 +83,7 @@ public class RequestFieldsSnippetFailureTests { } @Test - public void fieldWithExplicitTypeThatDoesNotMatchThePayload() throws IOException { + public void fieldWithExplicitTypeThatDoesNotMatchThePayload() { assertThatExceptionOfType(FieldTypesDoNotMatchException.class) .isThrownBy(() -> new RequestFieldsSnippet( Arrays.asList(fieldWithPath("a").description("one").type(JsonFieldType.OBJECT))).document( @@ -93,7 +92,7 @@ public class RequestFieldsSnippetFailureTests { } @Test - public void fieldWithExplicitSpecificTypeThatActuallyVaries() throws IOException { + public void fieldWithExplicitSpecificTypeThatActuallyVaries() { assertThatExceptionOfType(FieldTypesDoNotMatchException.class) .isThrownBy(() -> new RequestFieldsSnippet( Arrays.asList(fieldWithPath("[].a").description("one").type(JsonFieldType.OBJECT))) @@ -103,7 +102,7 @@ public class RequestFieldsSnippetFailureTests { } @Test - public void undocumentedXmlRequestField() throws IOException { + public void undocumentedXmlRequestField() { assertThatExceptionOfType(SnippetException.class) .isThrownBy(() -> new RequestFieldsSnippet(Collections.emptyList()) .document(this.operationBuilder.request("http://localhost").content("5") @@ -112,7 +111,7 @@ public class RequestFieldsSnippetFailureTests { } @Test - public void xmlDescendentsAreNotDocumentedByFieldDescriptor() throws IOException { + public void xmlDescendentsAreNotDocumentedByFieldDescriptor() { assertThatExceptionOfType(SnippetException.class) .isThrownBy( () -> new RequestFieldsSnippet(Arrays.asList(fieldWithPath("a").type("a").description("one"))) @@ -122,7 +121,7 @@ public class RequestFieldsSnippetFailureTests { } @Test - public void xmlRequestFieldWithNoType() throws IOException { + public void xmlRequestFieldWithNoType() { assertThatExceptionOfType(FieldTypeRequiredException.class) .isThrownBy(() -> new RequestFieldsSnippet(Arrays.asList(fieldWithPath("a").description("one"))) .document(this.operationBuilder.request("http://localhost").content("5") @@ -130,7 +129,7 @@ public class RequestFieldsSnippetFailureTests { } @Test - public void missingXmlRequestField() throws IOException { + public void missingXmlRequestField() { assertThatExceptionOfType(SnippetException.class) .isThrownBy(() -> new RequestFieldsSnippet( Arrays.asList(fieldWithPath("a/b").description("one"), fieldWithPath("a").description("one"))) @@ -140,7 +139,7 @@ public class RequestFieldsSnippetFailureTests { } @Test - public void undocumentedXmlRequestFieldAndMissingXmlRequestField() throws IOException { + public void undocumentedXmlRequestFieldAndMissingXmlRequestField() { assertThatExceptionOfType(SnippetException.class) .isThrownBy(() -> new RequestFieldsSnippet(Arrays.asList(fieldWithPath("a/b").description("one"))) .document(this.operationBuilder.request("http://localhost").content("5") @@ -150,7 +149,7 @@ public class RequestFieldsSnippetFailureTests { } @Test - public void unsupportedContent() throws IOException { + public void unsupportedContent() { assertThatExceptionOfType(PayloadHandlingException.class) .isThrownBy(() -> new RequestFieldsSnippet(Collections.emptyList()) .document(this.operationBuilder.request("http://localhost").content("Some plain text") @@ -159,7 +158,7 @@ public class RequestFieldsSnippetFailureTests { } @Test - public void nonOptionalFieldBeneathArrayThatIsSometimesNull() throws IOException { + public void nonOptionalFieldBeneathArrayThatIsSometimesNull() { assertThatExceptionOfType(SnippetException.class) .isThrownBy(() -> new RequestFieldsSnippet( Arrays.asList(fieldWithPath("a[].b").description("one").type(JsonFieldType.NUMBER), @@ -172,7 +171,7 @@ public class RequestFieldsSnippetFailureTests { } @Test - public void nonOptionalFieldBeneathArrayThatIsSometimesAbsent() throws IOException { + public void nonOptionalFieldBeneathArrayThatIsSometimesAbsent() { assertThatExceptionOfType(SnippetException.class) .isThrownBy(() -> new RequestFieldsSnippet( Arrays.asList(fieldWithPath("a[].b").description("one").type(JsonFieldType.NUMBER), diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/RequestPartFieldsSnippetFailureTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/RequestPartFieldsSnippetFailureTests.java index 2226e8c1..66e16285 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/RequestPartFieldsSnippetFailureTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/RequestPartFieldsSnippetFailureTests.java @@ -16,7 +16,6 @@ package org.springframework.restdocs.payload; -import java.io.IOException; import java.util.Arrays; import java.util.Collections; @@ -43,7 +42,7 @@ public class RequestPartFieldsSnippetFailureTests { public OperationBuilder operationBuilder = new OperationBuilder(TemplateFormats.asciidoctor()); @Test - public void undocumentedRequestPartField() throws IOException { + public void undocumentedRequestPartField() { assertThatExceptionOfType(SnippetException.class) .isThrownBy(() -> new RequestPartFieldsSnippet("part", Collections.emptyList()) .document(this.operationBuilder.request("http://localhost") @@ -52,7 +51,7 @@ public class RequestPartFieldsSnippetFailureTests { } @Test - public void missingRequestPartField() throws IOException { + public void missingRequestPartField() { assertThatExceptionOfType(SnippetException.class) .isThrownBy( () -> new RequestPartFieldsSnippet("part", Arrays.asList(fieldWithPath("b").description("one"))) @@ -62,7 +61,7 @@ public class RequestPartFieldsSnippetFailureTests { } @Test - public void missingRequestPart() throws IOException { + public void missingRequestPart() { assertThatExceptionOfType(SnippetException.class).isThrownBy( () -> new RequestPartFieldsSnippet("another", Arrays.asList(fieldWithPath("a.b").description("one"))) .document(this.operationBuilder.request("http://localhost") diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/ResponseFieldsSnippetFailureTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/ResponseFieldsSnippetFailureTests.java index 4329bdcf..a0cfda1d 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/ResponseFieldsSnippetFailureTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/ResponseFieldsSnippetFailureTests.java @@ -16,7 +16,6 @@ package org.springframework.restdocs.payload; -import java.io.IOException; import java.util.Arrays; import java.util.Collections; @@ -44,7 +43,7 @@ public class ResponseFieldsSnippetFailureTests { public OperationBuilder operationBuilder = new OperationBuilder(TemplateFormats.asciidoctor()); @Test - public void attemptToDocumentFieldsWithNoResponseBody() throws IOException { + public void attemptToDocumentFieldsWithNoResponseBody() { assertThatExceptionOfType(SnippetException.class) .isThrownBy(() -> new ResponseFieldsSnippet(Arrays.asList(fieldWithPath("a").description("one"))) .document(this.operationBuilder.build())) @@ -52,7 +51,7 @@ public class ResponseFieldsSnippetFailureTests { } @Test - public void fieldWithExplicitTypeThatDoesNotMatchThePayload() throws IOException { + public void fieldWithExplicitTypeThatDoesNotMatchThePayload() { assertThatExceptionOfType(FieldTypesDoNotMatchException.class) .isThrownBy(() -> new ResponseFieldsSnippet( Arrays.asList(fieldWithPath("a").description("one").type(JsonFieldType.OBJECT))) @@ -61,7 +60,7 @@ public class ResponseFieldsSnippetFailureTests { } @Test - public void fieldWithExplicitSpecificTypeThatActuallyVaries() throws IOException { + public void fieldWithExplicitSpecificTypeThatActuallyVaries() { assertThatExceptionOfType(FieldTypesDoNotMatchException.class) .isThrownBy(() -> new ResponseFieldsSnippet( Arrays.asList(fieldWithPath("[].a").description("one").type(JsonFieldType.OBJECT))).document( @@ -70,7 +69,7 @@ public class ResponseFieldsSnippetFailureTests { } @Test - public void undocumentedXmlResponseField() throws IOException { + public void undocumentedXmlResponseField() { assertThatExceptionOfType(SnippetException.class) .isThrownBy(() -> new ResponseFieldsSnippet(Collections.emptyList()) .document(this.operationBuilder.response().content("5") @@ -79,7 +78,7 @@ public class ResponseFieldsSnippetFailureTests { } @Test - public void missingXmlAttribute() throws IOException { + public void missingXmlAttribute() { assertThatExceptionOfType(SnippetException.class) .isThrownBy( () -> new ResponseFieldsSnippet(Arrays.asList(fieldWithPath("a").description("one").type("b"), @@ -93,7 +92,7 @@ public class ResponseFieldsSnippetFailureTests { } @Test - public void documentedXmlAttributesAreRemoved() throws IOException { + public void documentedXmlAttributesAreRemoved() { assertThatExceptionOfType(SnippetException.class).isThrownBy( () -> new ResponseFieldsSnippet(Arrays.asList(fieldWithPath("a/@id").description("one").type("a"))) .document(this.operationBuilder.response().content("bar") @@ -102,7 +101,7 @@ public class ResponseFieldsSnippetFailureTests { } @Test - public void xmlResponseFieldWithNoType() throws IOException { + public void xmlResponseFieldWithNoType() { assertThatExceptionOfType(FieldTypeRequiredException.class) .isThrownBy(() -> new ResponseFieldsSnippet(Arrays.asList(fieldWithPath("a").description("one"))) .document(this.operationBuilder.response().content("5") @@ -110,7 +109,7 @@ public class ResponseFieldsSnippetFailureTests { } @Test - public void missingXmlResponseField() throws IOException { + public void missingXmlResponseField() { assertThatExceptionOfType(SnippetException.class) .isThrownBy(() -> new ResponseFieldsSnippet( Arrays.asList(fieldWithPath("a/b").description("one"), fieldWithPath("a").description("one"))) @@ -120,7 +119,7 @@ public class ResponseFieldsSnippetFailureTests { } @Test - public void undocumentedXmlResponseFieldAndMissingXmlResponseField() throws IOException { + public void undocumentedXmlResponseFieldAndMissingXmlResponseField() { assertThatExceptionOfType(SnippetException.class) .isThrownBy(() -> new ResponseFieldsSnippet(Arrays.asList(fieldWithPath("a/b").description("one"))) .document(this.operationBuilder.response().content("5") @@ -130,7 +129,7 @@ public class ResponseFieldsSnippetFailureTests { } @Test - public void unsupportedContent() throws IOException { + public void unsupportedContent() { assertThatExceptionOfType(PayloadHandlingException.class) .isThrownBy(() -> new ResponseFieldsSnippet(Collections.emptyList()) .document(this.operationBuilder.response().content("Some plain text") @@ -139,7 +138,7 @@ public class ResponseFieldsSnippetFailureTests { } @Test - public void nonOptionalFieldBeneathArrayThatIsSometimesNull() throws IOException { + public void nonOptionalFieldBeneathArrayThatIsSometimesNull() { assertThatExceptionOfType(SnippetException.class) .isThrownBy(() -> new ResponseFieldsSnippet( Arrays.asList(fieldWithPath("a[].b").description("one").type(JsonFieldType.NUMBER), @@ -152,7 +151,7 @@ public class ResponseFieldsSnippetFailureTests { } @Test - public void nonOptionalFieldBeneathArrayThatIsSometimesAbsent() throws IOException { + public void nonOptionalFieldBeneathArrayThatIsSometimesAbsent() { assertThatExceptionOfType(SnippetException.class) .isThrownBy(() -> new ResponseFieldsSnippet( Arrays.asList(fieldWithPath("a[].b").description("one").type(JsonFieldType.NUMBER), diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/PathParametersSnippetFailureTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/PathParametersSnippetFailureTests.java index 83176449..dffbb36e 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/PathParametersSnippetFailureTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/PathParametersSnippetFailureTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2021 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,6 @@ package org.springframework.restdocs.request; -import java.io.IOException; import java.util.Arrays; import java.util.Collections; @@ -43,7 +42,7 @@ public class PathParametersSnippetFailureTests { public OperationBuilder operationBuilder = new OperationBuilder(TemplateFormats.asciidoctor()); @Test - public void undocumentedPathParameter() throws IOException { + public void undocumentedPathParameter() { assertThatExceptionOfType(SnippetException.class) .isThrownBy(() -> new PathParametersSnippet(Collections.emptyList()) .document(this.operationBuilder @@ -52,7 +51,7 @@ public class PathParametersSnippetFailureTests { } @Test - public void missingPathParameter() throws IOException { + public void missingPathParameter() { assertThatExceptionOfType(SnippetException.class) .isThrownBy(() -> new PathParametersSnippet(Arrays.asList(parameterWithName("a").description("one"))) .document(this.operationBuilder @@ -61,7 +60,7 @@ public class PathParametersSnippetFailureTests { } @Test - public void undocumentedAndMissingPathParameters() throws IOException { + public void undocumentedAndMissingPathParameters() { assertThatExceptionOfType(SnippetException.class) .isThrownBy(() -> new PathParametersSnippet(Arrays.asList(parameterWithName("a").description("one"))) .document(this.operationBuilder diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/RequestParametersSnippetFailureTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/RequestParametersSnippetFailureTests.java index 929308e0..b6921c44 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/RequestParametersSnippetFailureTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/RequestParametersSnippetFailureTests.java @@ -16,7 +16,6 @@ package org.springframework.restdocs.request; -import java.io.IOException; import java.util.Arrays; import java.util.Collections; @@ -42,7 +41,7 @@ public class RequestParametersSnippetFailureTests { public OperationBuilder operationBuilder = new OperationBuilder(TemplateFormats.asciidoctor()); @Test - public void undocumentedParameter() throws IOException { + public void undocumentedParameter() { assertThatExceptionOfType(SnippetException.class) .isThrownBy(() -> new RequestParametersSnippet(Collections.emptyList()) .document(this.operationBuilder.request("http://localhost").param("a", "alpha").build())) @@ -50,7 +49,7 @@ public class RequestParametersSnippetFailureTests { } @Test - public void missingParameter() throws IOException { + public void missingParameter() { assertThatExceptionOfType(SnippetException.class) .isThrownBy(() -> new RequestParametersSnippet(Arrays.asList(parameterWithName("a").description("one"))) .document(this.operationBuilder.request("http://localhost").build())) @@ -58,7 +57,7 @@ public class RequestParametersSnippetFailureTests { } @Test - public void undocumentedAndMissingParameters() throws IOException { + public void undocumentedAndMissingParameters() { assertThatExceptionOfType(SnippetException.class) .isThrownBy(() -> new RequestParametersSnippet(Arrays.asList(parameterWithName("a").description("one"))) .document(this.operationBuilder.request("http://localhost").param("b", "bravo").build())) diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/RequestPartsSnippetFailureTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/RequestPartsSnippetFailureTests.java index 64b4b0e5..f8512749 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/RequestPartsSnippetFailureTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/RequestPartsSnippetFailureTests.java @@ -16,7 +16,6 @@ package org.springframework.restdocs.request; -import java.io.IOException; import java.util.Arrays; import java.util.Collections; @@ -42,7 +41,7 @@ public class RequestPartsSnippetFailureTests { public OperationBuilder operationBuilder = new OperationBuilder(TemplateFormats.asciidoctor()); @Test - public void undocumentedPart() throws IOException { + public void undocumentedPart() { assertThatExceptionOfType(SnippetException.class) .isThrownBy(() -> new RequestPartsSnippet(Collections.emptyList()).document( this.operationBuilder.request("http://localhost").part("a", "alpha".getBytes()).build())) @@ -50,7 +49,7 @@ public class RequestPartsSnippetFailureTests { } @Test - public void missingPart() throws IOException { + public void missingPart() { assertThatExceptionOfType(SnippetException.class) .isThrownBy(() -> new RequestPartsSnippet(Arrays.asList(partWithName("a").description("one"))) .document(this.operationBuilder.request("http://localhost").build())) @@ -58,7 +57,7 @@ public class RequestPartsSnippetFailureTests { } @Test - public void undocumentedAndMissingParts() throws IOException { + public void undocumentedAndMissingParts() { assertThatExceptionOfType(SnippetException.class) .isThrownBy(() -> new RequestPartsSnippet(Arrays.asList(partWithName("a").description("one"))).document( this.operationBuilder.request("http://localhost").part("b", "bravo".getBytes()).build())) diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/snippet/RestDocumentationContextPlaceholderResolverTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/snippet/RestDocumentationContextPlaceholderResolverTests.java index d9f8ac26..59288748 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/snippet/RestDocumentationContextPlaceholderResolverTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/snippet/RestDocumentationContextPlaceholderResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2020 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,79 +33,79 @@ import static org.assertj.core.api.Assertions.assertThat; public class RestDocumentationContextPlaceholderResolverTests { @Test - public void kebabCaseMethodName() throws Exception { + public void kebabCaseMethodName() { assertThat(createResolver("dashSeparatedMethodName").resolvePlaceholder("method-name")) .isEqualTo("dash-separated-method-name"); } @Test - public void kebabCaseMethodNameWithUpperCaseOpeningSection() throws Exception { + public void kebabCaseMethodNameWithUpperCaseOpeningSection() { assertThat(createResolver("URIDashSeparatedMethodName").resolvePlaceholder("method-name")) .isEqualTo("uri-dash-separated-method-name"); } @Test - public void kebabCaseMethodNameWithUpperCaseMidSection() throws Exception { + public void kebabCaseMethodNameWithUpperCaseMidSection() { assertThat(createResolver("dashSeparatedMethodNameWithURIInIt").resolvePlaceholder("method-name")) .isEqualTo("dash-separated-method-name-with-uri-in-it"); } @Test - public void kebabCaseMethodNameWithUpperCaseEndSection() throws Exception { + public void kebabCaseMethodNameWithUpperCaseEndSection() { assertThat(createResolver("dashSeparatedMethodNameWithURI").resolvePlaceholder("method-name")) .isEqualTo("dash-separated-method-name-with-uri"); } @Test - public void snakeCaseMethodName() throws Exception { + public void snakeCaseMethodName() { assertThat(createResolver("underscoreSeparatedMethodName").resolvePlaceholder("method_name")) .isEqualTo("underscore_separated_method_name"); } @Test - public void snakeCaseMethodNameWithUpperCaseOpeningSection() throws Exception { + public void snakeCaseMethodNameWithUpperCaseOpeningSection() { assertThat(createResolver("URIUnderscoreSeparatedMethodName").resolvePlaceholder("method_name")) .isEqualTo("uri_underscore_separated_method_name"); } @Test - public void snakeCaseMethodNameWithUpperCaseMidSection() throws Exception { + public void snakeCaseMethodNameWithUpperCaseMidSection() { assertThat(createResolver("underscoreSeparatedMethodNameWithURIInIt").resolvePlaceholder("method_name")) .isEqualTo("underscore_separated_method_name_with_uri_in_it"); } @Test - public void snakeCaseMethodNameWithUpperCaseEndSection() throws Exception { + public void snakeCaseMethodNameWithUpperCaseEndSection() { assertThat(createResolver("underscoreSeparatedMethodNameWithURI").resolvePlaceholder("method_name")) .isEqualTo("underscore_separated_method_name_with_uri"); } @Test - public void camelCaseMethodName() throws Exception { + public void camelCaseMethodName() { assertThat(createResolver("camelCaseMethodName").resolvePlaceholder("methodName")) .isEqualTo("camelCaseMethodName"); } @Test - public void kebabCaseClassName() throws Exception { + public void kebabCaseClassName() { assertThat(createResolver().resolvePlaceholder("class-name")) .isEqualTo("rest-documentation-context-placeholder-resolver-tests"); } @Test - public void snakeCaseClassName() throws Exception { + public void snakeCaseClassName() { assertThat(createResolver().resolvePlaceholder("class_name")) .isEqualTo("rest_documentation_context_placeholder_resolver_tests"); } @Test - public void camelCaseClassName() throws Exception { + public void camelCaseClassName() { assertThat(createResolver().resolvePlaceholder("ClassName")) .isEqualTo("RestDocumentationContextPlaceholderResolverTests"); } @Test - public void stepCount() throws Exception { + public void stepCount() { assertThat(createResolver("stepCount").resolvePlaceholder("step")).isEqualTo("1"); } diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/templates/StandardTemplateResourceResolverTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/templates/StandardTemplateResourceResolverTests.java index 2782b488..31ba2047 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/templates/StandardTemplateResourceResolverTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/templates/StandardTemplateResourceResolverTests.java @@ -16,6 +16,7 @@ package org.springframework.restdocs.templates; +import java.io.IOException; import java.net.URL; import java.util.HashMap; import java.util.Map; @@ -41,7 +42,7 @@ public class StandardTemplateResourceResolverTests { private final TestClassLoader classLoader = new TestClassLoader(); @Test - public void formatSpecificCustomSnippetHasHighestPrecedence() throws Exception { + public void formatSpecificCustomSnippetHasHighestPrecedence() throws IOException { this.classLoader.addResource("org/springframework/restdocs/templates/asciidoctor/test.snippet", getClass().getResource("test-format-specific-custom.snippet")); this.classLoader.addResource("org/springframework/restdocs/templates/test.snippet", @@ -61,7 +62,7 @@ public class StandardTemplateResourceResolverTests { } @Test - public void generalCustomSnippetIsUsedInAbsenceOfFormatSpecificCustomSnippet() throws Exception { + public void generalCustomSnippetIsUsedInAbsenceOfFormatSpecificCustomSnippet() throws IOException { this.classLoader.addResource("org/springframework/restdocs/templates/test.snippet", getClass().getResource("test-custom.snippet")); this.classLoader.addResource("org/springframework/restdocs/templates/asciidoctor/default-test.snippet", @@ -95,19 +96,22 @@ public class StandardTemplateResourceResolverTests { } @Test - public void failsIfCustomAndDefaultSnippetsDoNotExist() throws Exception { + public void failsIfCustomAndDefaultSnippetsDoNotExist() { assertThatIllegalStateException() .isThrownBy(() -> doWithThreadContextClassLoader(this.classLoader, () -> StandardTemplateResourceResolverTests.this.resolver.resolveTemplateResource("test"))) .withMessage("Template named 'test' could not be resolved"); } - private T doWithThreadContextClassLoader(ClassLoader classLoader, Callable action) throws Exception { + private T doWithThreadContextClassLoader(ClassLoader classLoader, Callable action) { ClassLoader previous = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(classLoader); try { return action.call(); } + catch (Exception ex) { + throw new RuntimeException(ex); + } finally { Thread.currentThread().setContextClassLoader(previous); } diff --git a/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/RestDocumentationResultHandler.java b/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/RestDocumentationResultHandler.java index 3111b7b6..a2ded934 100644 --- a/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/RestDocumentationResultHandler.java +++ b/spring-restdocs-mockmvc/src/main/java/org/springframework/restdocs/mockmvc/RestDocumentationResultHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -71,7 +71,7 @@ public class RestDocumentationResultHandler implements ResultHandler { return new RestDocumentationResultHandler(this.delegate.withSnippets(snippets)) { @Override - public void handle(MvcResult result) throws Exception { + public void handle(MvcResult result) { Map configuration = new HashMap<>(retrieveConfiguration(result)); configuration.remove(RestDocumentationGenerator.ATTRIBUTE_NAME_DEFAULT_SNIPPETS); getDelegate().handle(result.getRequest(), result.getResponse(), configuration); diff --git a/spring-restdocs-mockmvc/src/test/java/org/springframework/restdocs/mockmvc/MockMvcRequestConverterTests.java b/spring-restdocs-mockmvc/src/test/java/org/springframework/restdocs/mockmvc/MockMvcRequestConverterTests.java index ca2028c1..c01fd3de 100644 --- a/spring-restdocs-mockmvc/src/test/java/org/springframework/restdocs/mockmvc/MockMvcRequestConverterTests.java +++ b/spring-restdocs-mockmvc/src/test/java/org/springframework/restdocs/mockmvc/MockMvcRequestConverterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ package org.springframework.restdocs.mockmvc; import java.io.ByteArrayInputStream; +import java.io.IOException; import java.net.URI; import java.util.Arrays; import java.util.Iterator; @@ -50,14 +51,14 @@ public class MockMvcRequestConverterTests { private final MockMvcRequestConverter factory = new MockMvcRequestConverter(); @Test - public void httpRequest() throws Exception { + public void httpRequest() { OperationRequest request = createOperationRequest(MockMvcRequestBuilders.get("/foo")); assertThat(request.getUri()).isEqualTo(URI.create("http://localhost/foo")); assertThat(request.getMethod()).isEqualTo(HttpMethod.GET); } @Test - public void httpRequestWithCustomPort() throws Exception { + public void httpRequestWithCustomPort() { MockHttpServletRequest mockRequest = MockMvcRequestBuilders.get("/foo").buildRequest(new MockServletContext()); mockRequest.setServerPort(8080); OperationRequest request = this.factory.convert(mockRequest); @@ -66,14 +67,14 @@ public class MockMvcRequestConverterTests { } @Test - public void requestWithContextPath() throws Exception { + public void requestWithContextPath() { OperationRequest request = createOperationRequest(MockMvcRequestBuilders.get("/foo/bar").contextPath("/foo")); assertThat(request.getUri()).isEqualTo(URI.create("http://localhost/foo/bar")); assertThat(request.getMethod()).isEqualTo(HttpMethod.GET); } @Test - public void requestWithHeaders() throws Exception { + public void requestWithHeaders() { OperationRequest request = createOperationRequest( MockMvcRequestBuilders.get("/foo").header("a", "alpha", "apple").header("b", "bravo")); assertThat(request.getUri()).isEqualTo(URI.create("http://localhost/foo")); @@ -83,7 +84,7 @@ public class MockMvcRequestConverterTests { } @Test - public void requestWithCookies() throws Exception { + public void requestWithCookies() { OperationRequest request = createOperationRequest( MockMvcRequestBuilders.get("/foo").cookie(new javax.servlet.http.Cookie("cookieName1", "cookieVal1"), new javax.servlet.http.Cookie("cookieName2", "cookieVal2"))); @@ -103,7 +104,7 @@ public class MockMvcRequestConverterTests { } @Test - public void httpsRequest() throws Exception { + public void httpsRequest() { MockHttpServletRequest mockRequest = MockMvcRequestBuilders.get("/foo").buildRequest(new MockServletContext()); mockRequest.setScheme("https"); mockRequest.setServerPort(443); @@ -113,7 +114,7 @@ public class MockMvcRequestConverterTests { } @Test - public void httpsRequestWithCustomPort() throws Exception { + public void httpsRequestWithCustomPort() { MockHttpServletRequest mockRequest = MockMvcRequestBuilders.get("/foo").buildRequest(new MockServletContext()); mockRequest.setScheme("https"); mockRequest.setServerPort(8443); @@ -123,7 +124,7 @@ public class MockMvcRequestConverterTests { } @Test - public void getRequestWithParametersProducesUriWithQueryString() throws Exception { + public void getRequestWithParametersProducesUriWithQueryString() { OperationRequest request = createOperationRequest( MockMvcRequestBuilders.get("/foo").param("a", "alpha", "apple").param("b", "br&vo")); assertThat(request.getUri()).isEqualTo(URI.create("http://localhost/foo?a=alpha&a=apple&b=br%26vo")); @@ -134,7 +135,7 @@ public class MockMvcRequestConverterTests { } @Test - public void getRequestWithQueryStringPopulatesParameters() throws Exception { + public void getRequestWithQueryStringPopulatesParameters() { OperationRequest request = createOperationRequest(MockMvcRequestBuilders.get("/foo?a=alpha&b=bravo")); assertThat(request.getUri()).isEqualTo(URI.create("http://localhost/foo?a=alpha&b=bravo")); assertThat(request.getParameters().size()).isEqualTo(2); @@ -144,7 +145,7 @@ public class MockMvcRequestConverterTests { } @Test - public void postRequestWithParameters() throws Exception { + public void postRequestWithParameters() { OperationRequest request = createOperationRequest( MockMvcRequestBuilders.post("/foo").param("a", "alpha", "apple").param("b", "br&vo")); assertThat(request.getUri()).isEqualTo(URI.create("http://localhost/foo")); @@ -155,7 +156,7 @@ public class MockMvcRequestConverterTests { } @Test - public void mockMultipartFileUpload() throws Exception { + public void mockMultipartFileUpload() { OperationRequest request = createOperationRequest(MockMvcRequestBuilders.multipart("/foo") .file(new MockMultipartFile("file", new byte[] { 1, 2, 3, 4 }))); assertThat(request.getUri()).isEqualTo(URI.create("http://localhost/foo")); @@ -170,7 +171,7 @@ public class MockMvcRequestConverterTests { } @Test - public void mockMultipartFileUploadWithContentType() throws Exception { + public void mockMultipartFileUploadWithContentType() { OperationRequest request = createOperationRequest(MockMvcRequestBuilders.multipart("/foo") .file(new MockMultipartFile("file", "original", "image/png", new byte[] { 1, 2, 3, 4 }))); assertThat(request.getUri()).isEqualTo(URI.create("http://localhost/foo")); @@ -184,7 +185,7 @@ public class MockMvcRequestConverterTests { } @Test - public void requestWithPart() throws Exception { + public void requestWithPart() throws IOException { MockHttpServletRequest mockRequest = MockMvcRequestBuilders.get("/foo").buildRequest(new MockServletContext()); Part mockPart = mock(Part.class); given(mockPart.getHeaderNames()).willReturn(Arrays.asList("a", "b")); @@ -206,7 +207,7 @@ public class MockMvcRequestConverterTests { } @Test - public void requestWithPartWithContentType() throws Exception { + public void requestWithPartWithContentType() throws IOException { MockHttpServletRequest mockRequest = MockMvcRequestBuilders.get("/foo").buildRequest(new MockServletContext()); Part mockPart = mock(Part.class); given(mockPart.getHeaderNames()).willReturn(Arrays.asList("a", "b")); @@ -228,7 +229,7 @@ public class MockMvcRequestConverterTests { assertThat(part.getContent()).isEqualTo(new byte[] { 1, 2, 3, 4 }); } - private OperationRequest createOperationRequest(MockHttpServletRequestBuilder builder) throws Exception { + private OperationRequest createOperationRequest(MockHttpServletRequestBuilder builder) { return this.factory.convert(builder.buildRequest(new MockServletContext())); } diff --git a/spring-restdocs-restassured/src/test/java/org/springframework/restdocs/restassured3/RestAssuredRestDocumentationIntegrationTests.java b/spring-restdocs-restassured/src/test/java/org/springframework/restdocs/restassured3/RestAssuredRestDocumentationIntegrationTests.java index a6c77d4c..5b3ffa48 100644 --- a/spring-restdocs-restassured/src/test/java/org/springframework/restdocs/restassured3/RestAssuredRestDocumentationIntegrationTests.java +++ b/spring-restdocs-restassured/src/test/java/org/springframework/restdocs/restassured3/RestAssuredRestDocumentationIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2021 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; +import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.nio.charset.StandardCharsets; @@ -96,7 +97,7 @@ public class RestAssuredRestDocumentationIntegrationTests { } @Test - public void curlSnippetWithContent() throws Exception { + public void curlSnippetWithContent() { String contentType = "text/plain; charset=UTF-8"; given().port(tomcat.getPort()).filter(documentationConfiguration(this.restDocumentation)) .filter(document("curl-snippet-with-content")).accept("application/json").body("content") @@ -109,7 +110,7 @@ public class RestAssuredRestDocumentationIntegrationTests { } @Test - public void curlSnippetWithCookies() throws Exception { + public void curlSnippetWithCookies() { String contentType = "text/plain; charset=UTF-8"; given().port(tomcat.getPort()).filter(documentationConfiguration(this.restDocumentation)) .filter(document("curl-snippet-with-cookies")).accept("application/json").contentType(contentType) @@ -121,7 +122,7 @@ public class RestAssuredRestDocumentationIntegrationTests { } @Test - public void curlSnippetWithEmptyParameterQueryString() throws Exception { + public void curlSnippetWithEmptyParameterQueryString() { given().port(tomcat.getPort()).filter(documentationConfiguration(this.restDocumentation)) .filter(document("curl-snippet-with-empty-parameter-query-string")).accept("application/json") .param("a", "").get("/").then().statusCode(200); @@ -133,7 +134,7 @@ public class RestAssuredRestDocumentationIntegrationTests { } @Test - public void curlSnippetWithQueryStringOnPost() throws Exception { + public void curlSnippetWithQueryStringOnPost() { given().port(tomcat.getPort()).filter(documentationConfiguration(this.restDocumentation)) .filter(document("curl-snippet-with-query-string")).accept("application/json").param("foo", "bar") .param("a", "alpha").post("/?foo=bar").then().statusCode(200); @@ -146,7 +147,7 @@ public class RestAssuredRestDocumentationIntegrationTests { } @Test - public void linksSnippet() throws Exception { + public void linksSnippet() { given().port(tomcat.getPort()).filter(documentationConfiguration(this.restDocumentation)) .filter(document("links", links(linkWithRel("rel").description("The description")))) .accept("application/json").get("/").then().statusCode(200); @@ -155,7 +156,7 @@ public class RestAssuredRestDocumentationIntegrationTests { } @Test - public void pathParametersSnippet() throws Exception { + public void pathParametersSnippet() { given().port(tomcat.getPort()).filter(documentationConfiguration(this.restDocumentation)) .filter(document("path-parameters", pathParameters(parameterWithName("foo").description("The description")))) @@ -165,7 +166,7 @@ public class RestAssuredRestDocumentationIntegrationTests { } @Test - public void requestParametersSnippet() throws Exception { + public void requestParametersSnippet() { given().port(tomcat.getPort()).filter(documentationConfiguration(this.restDocumentation)) .filter(document("request-parameters", requestParameters(parameterWithName("foo").description("The description")))) @@ -175,7 +176,7 @@ public class RestAssuredRestDocumentationIntegrationTests { } @Test - public void requestFieldsSnippet() throws Exception { + public void requestFieldsSnippet() { given().port(tomcat.getPort()).filter(documentationConfiguration(this.restDocumentation)) .filter(document("request-fields", requestFields(fieldWithPath("a").description("The description")))) .accept("application/json").body("{\"a\":\"alpha\"}").post("/").then().statusCode(200); @@ -184,7 +185,7 @@ public class RestAssuredRestDocumentationIntegrationTests { } @Test - public void requestPartsSnippet() throws Exception { + public void requestPartsSnippet() { given().port(tomcat.getPort()).filter(documentationConfiguration(this.restDocumentation)) .filter(document("request-parts", requestParts(partWithName("a").description("The description")))) .multiPart("a", "foo").post("/upload").then().statusCode(200); @@ -193,7 +194,7 @@ public class RestAssuredRestDocumentationIntegrationTests { } @Test - public void responseFieldsSnippet() throws Exception { + public void responseFieldsSnippet() { given().port(tomcat.getPort()).filter(documentationConfiguration(this.restDocumentation)) .filter(document("response-fields", responseFields(fieldWithPath("a").description("The description"), @@ -204,7 +205,7 @@ public class RestAssuredRestDocumentationIntegrationTests { } @Test - public void parameterizedOutputDirectory() throws Exception { + public void parameterizedOutputDirectory() { given().port(tomcat.getPort()).filter(documentationConfiguration(this.restDocumentation)) .filter(document("{method-name}")).get("/").then().statusCode(200); assertExpectedSnippetFilesExist(new File("build/generated-snippets/parameterized-output-directory"), @@ -212,7 +213,7 @@ public class RestAssuredRestDocumentationIntegrationTests { } @Test - public void multiStep() throws Exception { + public void multiStep() { RequestSpecification spec = new RequestSpecBuilder().setPort(tomcat.getPort()) .addFilter(documentationConfiguration(this.restDocumentation)) .addFilter(document("{method-name}-{step}")).build(); @@ -228,7 +229,7 @@ public class RestAssuredRestDocumentationIntegrationTests { } @Test - public void additionalSnippets() throws Exception { + public void additionalSnippets() { RestDocumentationFilter documentation = document("{method-name}-{step}"); RequestSpecification spec = new RequestSpecBuilder().setPort(tomcat.getPort()) .addFilter(documentationConfiguration(this.restDocumentation)).addFilter(documentation).build(); @@ -253,7 +254,7 @@ public class RestAssuredRestDocumentationIntegrationTests { } @Test - public void preprocessedRequest() throws Exception { + public void preprocessedRequest() { Pattern pattern = Pattern.compile("(\"alpha\")"); given().port(tomcat.getPort()).filter(documentationConfiguration(this.restDocumentation)).header("a", "alpha") .header("b", "bravo").contentType("application/json").accept("application/json") @@ -277,7 +278,7 @@ public class RestAssuredRestDocumentationIntegrationTests { } @Test - public void defaultPreprocessedRequest() throws Exception { + public void defaultPreprocessedRequest() { Pattern pattern = Pattern.compile("(\"alpha\")"); given().port(tomcat.getPort()) .filter(documentationConfiguration(this.restDocumentation).operationPreprocessors().withRequestDefaults( @@ -295,7 +296,7 @@ public class RestAssuredRestDocumentationIntegrationTests { } @Test - public void preprocessedResponse() throws Exception { + public void preprocessedResponse() { Pattern pattern = Pattern.compile("(\"alpha\")"); given().port(tomcat.getPort()).filter(documentationConfiguration(this.restDocumentation)) .filter(document("original-response")) @@ -315,7 +316,7 @@ public class RestAssuredRestDocumentationIntegrationTests { } @Test - public void defaultPreprocessedResponse() throws Exception { + public void defaultPreprocessedResponse() { Pattern pattern = Pattern.compile("(\"alpha\")"); given().port(tomcat.getPort()) .filter(documentationConfiguration(this.restDocumentation).operationPreprocessors() @@ -334,7 +335,7 @@ public class RestAssuredRestDocumentationIntegrationTests { } @Test - public void customSnippetTemplate() throws Exception { + public void customSnippetTemplate() throws MalformedURLException { ClassLoader classLoader = new URLClassLoader( new URL[] { new File("src/test/resources/custom-snippet-templates").toURI().toURL() }, getClass().getClassLoader()); diff --git a/spring-restdocs-webtestclient/src/test/java/org/springframework/restdocs/webtestclient/WebTestClientRequestConverterTests.java b/spring-restdocs-webtestclient/src/test/java/org/springframework/restdocs/webtestclient/WebTestClientRequestConverterTests.java index cd56ef40..d416c084 100644 --- a/spring-restdocs-webtestclient/src/test/java/org/springframework/restdocs/webtestclient/WebTestClientRequestConverterTests.java +++ b/spring-restdocs-webtestclient/src/test/java/org/springframework/restdocs/webtestclient/WebTestClientRequestConverterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2021 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -103,7 +103,7 @@ public class WebTestClientRequestConverterTests { } @Test - public void getRequestWithQueryStringPopulatesParameters() throws Exception { + public void getRequestWithQueryStringPopulatesParameters() { ExchangeResult result = WebTestClient.bindToRouterFunction(RouterFunctions.route(GET("/foo"), (req) -> null)) .configureClient().baseUrl("http://localhost").build().get().uri("/foo?a=alpha&b=bravo").exchange() .expectBody().returnResult(); @@ -116,7 +116,7 @@ public class WebTestClientRequestConverterTests { } @Test - public void postRequestWithFormDataParameters() throws Exception { + public void postRequestWithFormDataParameters() { MultiValueMap parameters = new LinkedMultiValueMap<>(); parameters.addAll("a", Arrays.asList("alpha", "apple")); parameters.addAll("b", Arrays.asList("br&vo")); @@ -134,7 +134,7 @@ public class WebTestClientRequestConverterTests { } @Test - public void postRequestWithQueryStringParameters() throws Exception { + public void postRequestWithQueryStringParameters() { ExchangeResult result = WebTestClient.bindToRouterFunction(RouterFunctions.route(POST("/foo"), (req) -> { req.body(BodyExtractors.toFormData()).block(); return null; @@ -150,7 +150,7 @@ public class WebTestClientRequestConverterTests { } @Test - public void postRequestWithQueryStringAndFormDataParameters() throws Exception { + public void postRequestWithQueryStringAndFormDataParameters() { MultiValueMap parameters = new LinkedMultiValueMap<>(); parameters.addAll("a", Arrays.asList("apple")); ExchangeResult result = WebTestClient.bindToRouterFunction(RouterFunctions.route(POST("/foo"), (req) -> { @@ -168,7 +168,7 @@ public class WebTestClientRequestConverterTests { } @Test - public void postRequestWithNoContentType() throws Exception { + public void postRequestWithNoContentType() { ExchangeResult result = WebTestClient .bindToRouterFunction(RouterFunctions.route(POST("/foo"), (req) -> ServerResponse.ok().build())) .configureClient().baseUrl("http://localhost").build().post().uri("/foo").exchange().expectBody() @@ -179,7 +179,7 @@ public class WebTestClientRequestConverterTests { } @Test - public void multipartUpload() throws Exception { + public void multipartUpload() { MultiValueMap multipartData = new LinkedMultiValueMap<>(); multipartData.add("file", new byte[] { 1, 2, 3, 4 }); ExchangeResult result = WebTestClient @@ -205,7 +205,7 @@ public class WebTestClientRequestConverterTests { } @Test - public void multipartUploadFromResource() throws Exception { + public void multipartUploadFromResource() { MultiValueMap multipartData = new LinkedMultiValueMap<>(); multipartData.add("file", new ByteArrayResource(new byte[] { 1, 2, 3, 4 }) { @@ -241,7 +241,7 @@ public class WebTestClientRequestConverterTests { } @Test - public void requestWithCookies() throws Exception { + public void requestWithCookies() { ExchangeResult result = WebTestClient.bindToRouterFunction(RouterFunctions.route(GET("/foo"), (req) -> null)) .configureClient().baseUrl("http://localhost").build().get().uri("/foo") .cookie("cookieName1", "cookieVal1").cookie("cookieName2", "cookieVal2").exchange().expectBody() diff --git a/spring-restdocs-webtestclient/src/test/java/org/springframework/restdocs/webtestclient/WebTestClientRestDocumentationIntegrationTests.java b/spring-restdocs-webtestclient/src/test/java/org/springframework/restdocs/webtestclient/WebTestClientRestDocumentationIntegrationTests.java index b7a653d2..96a4184f 100644 --- a/spring-restdocs-webtestclient/src/test/java/org/springframework/restdocs/webtestclient/WebTestClientRestDocumentationIntegrationTests.java +++ b/spring-restdocs-webtestclient/src/test/java/org/springframework/restdocs/webtestclient/WebTestClientRestDocumentationIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2021 the original author or authors. + * Copyright 2014-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -133,7 +133,7 @@ public class WebTestClientRestDocumentationIntegrationTests { } @Test - public void multipart() throws Exception { + public void multipart() { MultiValueMap multipartData = new LinkedMultiValueMap<>(); multipartData.add("a", "alpha"); multipartData.add("b", "bravo"); @@ -147,7 +147,7 @@ public class WebTestClientRestDocumentationIntegrationTests { } @Test - public void responseWithSetCookie() throws Exception { + public void responseWithSetCookie() { this.webTestClient.get().uri("/set-cookie").exchange().expectStatus().isOk().expectBody() .consumeWith(document("set-cookie")); assertThat(new File("build/generated-snippets/set-cookie/http-response.adoc")) @@ -156,7 +156,7 @@ public class WebTestClientRestDocumentationIntegrationTests { } @Test - public void curlSnippetWithCookies() throws Exception { + public void curlSnippetWithCookies() { this.webTestClient.get().uri("/").cookie("cookieName", "cookieVal").accept(MediaType.APPLICATION_JSON) .exchange().expectStatus().isOk().expectBody().consumeWith(document("curl-snippet-with-cookies")); assertThat(new File("build/generated-snippets/curl-snippet-with-cookies/curl-request.adoc")) @@ -166,7 +166,7 @@ public class WebTestClientRestDocumentationIntegrationTests { } @Test - public void curlSnippetWithEmptyParameterQueryString() throws Exception { + public void curlSnippetWithEmptyParameterQueryString() { this.webTestClient.get().uri("/?a=").accept(MediaType.APPLICATION_JSON).exchange().expectStatus().isOk() .expectBody().consumeWith(document("curl-snippet-with-empty-parameter-query-string")); assertThat( @@ -177,7 +177,7 @@ public class WebTestClientRestDocumentationIntegrationTests { } @Test - public void httpieSnippetWithCookies() throws Exception { + public void httpieSnippetWithCookies() { this.webTestClient.get().uri("/").cookie("cookieName", "cookieVal").accept(MediaType.APPLICATION_JSON) .exchange().expectStatus().isOk().expectBody().consumeWith(document("httpie-snippet-with-cookies")); assertThat(new File("build/generated-snippets/httpie-snippet-with-cookies/httpie-request.adoc"))