Polish
This commit is contained in:
@@ -103,9 +103,7 @@ class InterceptingClientHttpRequestFactoryTests {
|
||||
@Override
|
||||
protected ClientHttpResponse executeInternal() {
|
||||
List<String> headerValues = getHeaders().get(headerName);
|
||||
assertThat(headerValues).hasSize(2);
|
||||
assertThat(headerValues).element(0).isEqualTo(headerValue);
|
||||
assertThat(headerValues).element(1).isEqualTo(otherValue);
|
||||
assertThat(headerValues).containsExactly(headerValue, otherValue);
|
||||
return responseMock;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -39,13 +39,13 @@ class JdkClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTests {
|
||||
private static String originalPropertyValue;
|
||||
|
||||
@BeforeAll
|
||||
public static void setProperty() {
|
||||
static void setProperty() {
|
||||
originalPropertyValue = System.getProperty("jdk.httpclient.allowRestrictedHeaders");
|
||||
System.setProperty("jdk.httpclient.allowRestrictedHeaders", "expect");
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void restoreProperty() {
|
||||
static void restoreProperty() {
|
||||
if (originalPropertyValue != null) {
|
||||
System.setProperty("jdk.httpclient.allowRestrictedHeaders", originalPropertyValue);
|
||||
}
|
||||
|
||||
@@ -47,10 +47,10 @@ class InterceptingHttpAccessorTests {
|
||||
|
||||
);
|
||||
accessor.setInterceptors(interceptors);
|
||||
|
||||
assertThat(accessor.getInterceptors()).element(0).isInstanceOf(FirstClientHttpRequestInterceptor.class);
|
||||
assertThat(accessor.getInterceptors()).element(1).isInstanceOf(SecondClientHttpRequestInterceptor.class);
|
||||
assertThat(accessor.getInterceptors()).element(2).isInstanceOf(ThirdClientHttpRequestInterceptor.class);
|
||||
assertThat(accessor.getInterceptors()).hasExactlyElementsOfTypes(
|
||||
FirstClientHttpRequestInterceptor.class,
|
||||
SecondClientHttpRequestInterceptor.class,
|
||||
ThirdClientHttpRequestInterceptor.class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ class CookieIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||
RequestEntity.get(url).header("Cookie", header).build(), Void.class);
|
||||
|
||||
Map<String, List<HttpCookie>> requestCookies = this.cookieHandler.requestCookies;
|
||||
assertThat(requestCookies.size()).isEqualTo(2);
|
||||
assertThat(requestCookies).hasSize(2);
|
||||
assertThat(requestCookies.get("SID")).extracting(HttpCookie::getValue).containsExactly("31d4d96e407aad42");
|
||||
assertThat(requestCookies.get("lang")).extracting(HttpCookie::getValue).containsExactly("en-US", "zh-CN");
|
||||
}
|
||||
|
||||
@@ -64,8 +64,7 @@ class ListenerWriteProcessorTests {
|
||||
this.processor.onError(new IllegalStateException());
|
||||
|
||||
assertThat(this.resultSubscriber.getError()).as("Error should flow to result publisher").isNotNull();
|
||||
assertThat(this.processor.getDiscardedBuffers()).hasSize(1);
|
||||
assertThat(this.processor.getDiscardedBuffers()).element(0).isSameAs(buffer);
|
||||
assertThat(this.processor.getDiscardedBuffers()).containsExactly(buffer);
|
||||
}
|
||||
|
||||
@Test // SPR-17410
|
||||
@@ -80,8 +79,7 @@ class ListenerWriteProcessorTests {
|
||||
this.processor.onNext(buffer);
|
||||
|
||||
assertThat(this.resultSubscriber.getError()).as("Error should flow to result publisher").isNotNull();
|
||||
assertThat(this.processor.getDiscardedBuffers()).hasSize(1);
|
||||
assertThat(this.processor.getDiscardedBuffers()).element(0).isSameAs(buffer);
|
||||
assertThat(this.processor.getDiscardedBuffers()).containsExactly(buffer);
|
||||
}
|
||||
|
||||
@Test // SPR-17410
|
||||
@@ -97,9 +95,7 @@ class ListenerWriteProcessorTests {
|
||||
this.processor.onNext(buffer2);
|
||||
|
||||
assertThat(this.resultSubscriber.getError()).as("Error should flow to result publisher").isNotNull();
|
||||
assertThat(this.processor.getDiscardedBuffers()).hasSize(2);
|
||||
assertThat(this.processor.getDiscardedBuffers()).element(0).isSameAs(buffer2);
|
||||
assertThat(this.processor.getDiscardedBuffers()).element(1).isSameAs(buffer1);
|
||||
assertThat(this.processor.getDiscardedBuffers()).containsExactly(buffer2, buffer1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -68,8 +68,7 @@ class StandardServletAsyncWebRequestTests {
|
||||
MockAsyncContext context = (MockAsyncContext) this.request.getAsyncContext();
|
||||
assertThat(context).isNotNull();
|
||||
assertThat(context.getTimeout()).as("Timeout value not set").isEqualTo((44 * 1000));
|
||||
assertThat(context.getListeners()).hasSize(1);
|
||||
assertThat(context.getListeners()).element(0).isSameAs(this.asyncRequest);
|
||||
assertThat(context.getListeners()).containsExactly(this.asyncRequest);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -146,11 +146,8 @@ class RequestParamMapMethodArgumentResolverTests {
|
||||
assertThat(condition).isTrue();
|
||||
MultiValueMap<String, MultipartFile> resultMap = (MultiValueMap<String, MultipartFile>) result;
|
||||
assertThat(resultMap).hasSize(2);
|
||||
assertThat(resultMap.get("mfilelist")).hasSize(2);
|
||||
assertThat(resultMap.get("mfilelist")).element(0).isEqualTo(expected1);
|
||||
assertThat(resultMap.get("mfilelist")).element(1).isEqualTo(expected2);
|
||||
assertThat(resultMap.get("other")).hasSize(1);
|
||||
assertThat(resultMap.get("other")).element(0).isEqualTo(expected3);
|
||||
assertThat(resultMap.get("mfilelist")).containsExactly(expected1, expected2);
|
||||
assertThat(resultMap.get("other")).containsExactly(expected3);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -195,11 +192,8 @@ class RequestParamMapMethodArgumentResolverTests {
|
||||
assertThat(condition).isTrue();
|
||||
MultiValueMap<String, Part> resultMap = (MultiValueMap<String, Part>) result;
|
||||
assertThat(resultMap).hasSize(2);
|
||||
assertThat(resultMap.get("mfilelist")).hasSize(2);
|
||||
assertThat(resultMap.get("mfilelist")).element(0).isEqualTo(expected1);
|
||||
assertThat(resultMap.get("mfilelist")).element(1).isEqualTo(expected2);
|
||||
assertThat(resultMap.get("other")).hasSize(1);
|
||||
assertThat(resultMap.get("other")).element(0).isEqualTo(expected3);
|
||||
assertThat(resultMap.get("mfilelist")).containsExactly(expected1, expected2);
|
||||
assertThat(resultMap.get("other")).containsExactly(expected3);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import jakarta.servlet.http.Part;
|
||||
import org.assertj.core.api.InstanceOfAssertFactories;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.propertyeditors.StringTrimmerEditor;
|
||||
@@ -378,9 +379,8 @@ class RequestParamMethodArgumentResolverTests {
|
||||
.annotNotPresent(RequestParam.class).arg(List.class, MultipartFile.class);
|
||||
|
||||
Object actual = resolver.resolveArgument(param, null, webRequest, null);
|
||||
boolean condition = actual instanceof List;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(((List<?>) actual)).element(0).isEqualTo(expected);
|
||||
assertThat(actual).isInstanceOf(List.class).asInstanceOf(InstanceOfAssertFactories.LIST)
|
||||
.containsExactly(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user