Add since and forRemoval to @Deprecated
This commit is contained in:
@@ -20,9 +20,6 @@ import java.net.URI;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
@@ -51,11 +48,10 @@ class HttpEntityTests {
|
||||
|
||||
@Test
|
||||
void multiValueMap() {
|
||||
MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
|
||||
map.set("Content-Type", "text/plain");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Content-Type", "text/plain");
|
||||
String body = "foo";
|
||||
@SuppressWarnings("deprecation")
|
||||
HttpEntity<String> entity = new HttpEntity<>(body, map);
|
||||
HttpEntity<String> entity = new HttpEntity<>(body, headers);
|
||||
assertThat(entity.getBody()).isEqualTo(body);
|
||||
assertThat(entity.getHeaders().getContentType()).isEqualTo(MediaType.TEXT_PLAIN);
|
||||
assertThat(entity.getHeaders().getFirst("Content-Type")).isEqualTo("text/plain");
|
||||
|
||||
@@ -133,10 +133,9 @@ class HeadersAdaptersTests {
|
||||
assertThat(headers2.get("TestHeader")).as("TestHeader")
|
||||
.containsExactly("first", "second", "third");
|
||||
// Ordering and casing are not guaranteed using the entrySet+put approach
|
||||
assertThat(headers2.asMultiValueMap()).as("two keys")
|
||||
.containsKey("testheader")
|
||||
.containsKey("secondheader")
|
||||
.hasSize(2);
|
||||
assertThat(headers2.containsHeader("testheader")).isTrue();
|
||||
assertThat(headers2.containsHeader("secondheader")).isTrue();
|
||||
assertThat(headers2.size()).isEqualTo(2);
|
||||
assertThat(headers2.toString()).as("no 'with native headers' dump")
|
||||
.doesNotContain("with native headers");
|
||||
}
|
||||
@@ -150,10 +149,9 @@ class HeadersAdaptersTests {
|
||||
assertThat(headers2.get("TestHeader")).as("TestHeader")
|
||||
.containsExactly("first", "second", "third");
|
||||
// Ordering and casing are not guaranteed using the putAll approach
|
||||
assertThat(headers2.asMultiValueMap()).as("two keys")
|
||||
.containsKey("testheader")
|
||||
.containsKey("secondheader")
|
||||
.hasSize(2);
|
||||
assertThat(headers2.containsHeader("testheader")).isTrue();
|
||||
assertThat(headers2.containsHeader("secondheader")).isTrue();
|
||||
assertThat(headers2.size()).isEqualTo(2);
|
||||
assertThat(headers2.toString()).as("similar toString, no 'with native headers' dump")
|
||||
.isEqualToIgnoringCase(headers.toString().substring(0, headers.toString().indexOf(']') + 1));
|
||||
}
|
||||
|
||||
@@ -16,13 +16,10 @@
|
||||
|
||||
package org.springframework.web;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
import static java.util.Map.entry;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
@@ -33,15 +30,15 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class ErrorResponseTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
void createWithHttpHeader() {
|
||||
ErrorResponse response = ErrorResponse.builder(new IllegalStateException(), HttpStatus.BAD_REQUEST, "test")
|
||||
.header("header", "value").build();
|
||||
assertThat(response.getHeaders().asMultiValueMap()).containsOnly(entry("header", List.of("value")));
|
||||
ErrorResponse response = ErrorResponse
|
||||
.builder(new IllegalStateException(), HttpStatus.BAD_REQUEST, "test")
|
||||
.header("header", "value")
|
||||
.build();
|
||||
assertThat(response.getHeaders().containsHeaderValue("header", "value")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
void createWithHttpHeadersConsumer() {
|
||||
ErrorResponse response = ErrorResponse.builder(new IllegalStateException(), HttpStatus.BAD_REQUEST, "test")
|
||||
.header("header", "value")
|
||||
@@ -49,8 +46,8 @@ class ErrorResponseTests {
|
||||
headers.add("header", "value2");
|
||||
headers.add("another", "value3");
|
||||
}).build();
|
||||
assertThat(response.getHeaders().asMultiValueMap()).containsOnly(entry("header", List.of("value", "value2")),
|
||||
entry("another", List.of("value3")));
|
||||
assertThat(response.getHeaders().get("header")).containsExactly("value", "value2");
|
||||
assertThat(response.getHeaders().get("another")).containsExactly("value3");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user