Remove redundant throws declarations from non public API

Closes gh-828
This commit is contained in:
Andy Wilkinson
2022-07-15 12:38:25 +01:00
parent 6ab923b470
commit ebe70a91c7
45 changed files with 228 additions and 237 deletions

View File

@@ -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()

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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",

View File

@@ -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<String, String> 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<String, String> metadata = new HashMap<>();
metadata.put("version", "1.0");

View File

@@ -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>

View File

@@ -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"),

View File

@@ -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",

View File

@@ -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>

View File

@@ -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[]

View File

@@ -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>

View File

@@ -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()

View File

@@ -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()

View File

@@ -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<String, String> formData = new LinkedMultiValueMap<>();
formData.add("username", "Tester");

View File

@@ -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<String, Object> multipartData = new LinkedMultiValueMap<>();
Resource imageResource = new ByteArrayResource("<<png data>>".getBytes()) {
@@ -59,7 +59,7 @@ public class RequestPartPayload {
// end::fields[]
}
public void body() throws Exception {
public void body() {
// tag::body[]
MultiValueMap<String, Object> multipartData = new LinkedMultiValueMap<>();
Resource imageResource = new ByteArrayResource("<<png data>>".getBytes()) {

View File

@@ -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<String, Object> multipartData = new LinkedMultiValueMap<>();
multipartData.add("file", "example".getBytes());

View File

@@ -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()