Use AssertJ's hasSize() for collections and maps
Achieved via a global search-and-replace.
This commit is contained in:
@@ -44,7 +44,7 @@ public class HeaderContentTypeResolverTests {
|
||||
List<MediaType> mediaTypes = this.resolver.resolveMediaTypes(
|
||||
MockServerWebExchange.from(MockServerHttpRequest.get("/").header("accept", header)));
|
||||
|
||||
assertThat(mediaTypes.size()).isEqualTo(4);
|
||||
assertThat(mediaTypes).hasSize(4);
|
||||
assertThat(mediaTypes.get(0).toString()).isEqualTo("text/html");
|
||||
assertThat(mediaTypes.get(1).toString()).isEqualTo("text/x-c");
|
||||
assertThat(mediaTypes.get(2).toString()).isEqualTo("text/x-dvi;q=0.8");
|
||||
|
||||
@@ -45,7 +45,7 @@ public class CorsRegistryTests {
|
||||
public void multipleMappings() {
|
||||
this.registry.addMapping("/foo");
|
||||
this.registry.addMapping("/bar");
|
||||
assertThat(this.registry.getCorsConfigurations().size()).isEqualTo(2);
|
||||
assertThat(this.registry.getCorsConfigurations()).hasSize(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -54,7 +54,7 @@ public class CorsRegistryTests {
|
||||
.allowedMethods("DELETE").allowCredentials(false).allowedHeaders("header1", "header2")
|
||||
.exposedHeaders("header3", "header4").maxAge(3600);
|
||||
Map<String, CorsConfiguration> configs = this.registry.getCorsConfigurations();
|
||||
assertThat(configs.size()).isEqualTo(1);
|
||||
assertThat(configs).hasSize(1);
|
||||
CorsConfiguration config = configs.get("/foo");
|
||||
assertThat(config.getAllowedOrigins()).isEqualTo(Arrays.asList("https://domain2.com", "https://domain2.com"));
|
||||
assertThat(config.getAllowedMethods()).isEqualTo(Collections.singletonList("DELETE"));
|
||||
@@ -83,7 +83,7 @@ public class CorsRegistryTests {
|
||||
this.registry.addMapping("/api/**").combine(otherConfig);
|
||||
|
||||
Map<String, CorsConfiguration> configs = this.registry.getCorsConfigurations();
|
||||
assertThat(configs.size()).isEqualTo(1);
|
||||
assertThat(configs).hasSize(1);
|
||||
CorsConfiguration config = configs.get("/api/**");
|
||||
assertThat(config.getAllowedOrigins()).isEqualTo(Collections.singletonList("http://localhost:3000"));
|
||||
assertThat(config.getAllowedMethods()).isEqualTo(Collections.singletonList("*"));
|
||||
|
||||
@@ -112,7 +112,7 @@ public class DelegatingWebFluxConfigurationTests {
|
||||
boolean condition = initializer.getValidator() instanceof LocalValidatorFactoryBean;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(initializer.getConversionService()).isSameAs(formatterRegistry.getValue());
|
||||
assertThat(codecsConfigurer.getValue().getReaders().size()).isEqualTo(16);
|
||||
assertThat(codecsConfigurer.getValue().getReaders()).hasSize(16);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -106,7 +106,7 @@ class ResourceHandlerRegistryTests {
|
||||
this.registration.setMediaTypes(Collections.singletonMap("bar", mediaType));
|
||||
ResourceWebHandler requestHandler = this.registration.getRequestHandler();
|
||||
|
||||
assertThat(requestHandler.getMediaTypes()).size().isEqualTo(1);
|
||||
assertThat(requestHandler.getMediaTypes()).hasSize(1);
|
||||
assertThat(requestHandler.getMediaTypes()).containsEntry("bar", mediaType);
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ public class ViewResolverRegistryTests {
|
||||
@Test
|
||||
public void noResolvers() {
|
||||
assertThat(this.registry.getViewResolvers()).isNotNull();
|
||||
assertThat(this.registry.getViewResolvers().size()).isEqualTo(0);
|
||||
assertThat(this.registry.getViewResolvers()).hasSize(0);
|
||||
assertThat(this.registry.hasRegistrations()).isFalse();
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class ViewResolverRegistryTests {
|
||||
this.registry.viewResolver(viewResolver);
|
||||
|
||||
assertThat(this.registry.getViewResolvers().get(0)).isSameAs(viewResolver);
|
||||
assertThat(this.registry.getViewResolvers().size()).isEqualTo(1);
|
||||
assertThat(this.registry.getViewResolvers()).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -89,7 +89,7 @@ public class ViewResolverRegistryTests {
|
||||
View view = new HttpMessageWriterView(new Jackson2JsonEncoder());
|
||||
this.registry.defaultViews(view);
|
||||
|
||||
assertThat(this.registry.getDefaultViews().size()).isEqualTo(1);
|
||||
assertThat(this.registry.getDefaultViews()).hasSize(1);
|
||||
assertThat(this.registry.getDefaultViews().get(0)).isSameAs(view);
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ public class ViewResolverRegistryTests {
|
||||
this.registry.scriptTemplate().prefix("/").suffix(".html");
|
||||
|
||||
List<ViewResolver> viewResolvers = this.registry.getViewResolvers();
|
||||
assertThat(viewResolvers.size()).isEqualTo(1);
|
||||
assertThat(viewResolvers).hasSize(1);
|
||||
assertThat(viewResolvers.get(0).getClass()).isEqualTo(ScriptTemplateViewResolver.class);
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(viewResolvers.get(0));
|
||||
assertThat(accessor.getPropertyValue("prefix")).isEqualTo("/");
|
||||
|
||||
@@ -131,7 +131,7 @@ public class WebFluxConfigurationSupportTests {
|
||||
assertThat(mapping).isNotNull();
|
||||
|
||||
Map<RequestMappingInfo, HandlerMethod> map = mapping.getHandlerMethods();
|
||||
assertThat(map.size()).isEqualTo(1);
|
||||
assertThat(map).hasSize(1);
|
||||
assertThat(map.keySet().iterator().next().getPatternsCondition().getPatterns())
|
||||
.isEqualTo(Collections.singleton(new PathPatternParser().parse("/api/user/{id}")));
|
||||
}
|
||||
@@ -145,7 +145,7 @@ public class WebFluxConfigurationSupportTests {
|
||||
assertThat(adapter).isNotNull();
|
||||
|
||||
List<HttpMessageReader<?>> readers = adapter.getMessageReaders();
|
||||
assertThat(readers.size()).isEqualTo(16);
|
||||
assertThat(readers).hasSize(16);
|
||||
|
||||
ResolvableType multiValueMapType = forClassWithGenerics(MultiValueMap.class, String.class, String.class);
|
||||
|
||||
@@ -183,7 +183,7 @@ public class WebFluxConfigurationSupportTests {
|
||||
assertThat(adapter).isNotNull();
|
||||
|
||||
List<HttpMessageReader<?>> messageReaders = adapter.getMessageReaders();
|
||||
assertThat(messageReaders.size()).isEqualTo(2);
|
||||
assertThat(messageReaders).hasSize(2);
|
||||
|
||||
assertHasMessageReader(messageReaders, forClass(String.class), TEXT_PLAIN);
|
||||
assertHasMessageReader(messageReaders, forClass(TestBean.class), APPLICATION_XML);
|
||||
@@ -200,7 +200,7 @@ public class WebFluxConfigurationSupportTests {
|
||||
assertThat(handler.getOrder()).isEqualTo(0);
|
||||
|
||||
List<HttpMessageWriter<?>> writers = handler.getMessageWriters();
|
||||
assertThat(writers.size()).isEqualTo(14);
|
||||
assertThat(writers).hasSize(14);
|
||||
|
||||
assertHasMessageWriter(writers, forClass(byte[].class), APPLICATION_OCTET_STREAM);
|
||||
assertHasMessageWriter(writers, forClass(ByteBuffer.class), APPLICATION_OCTET_STREAM);
|
||||
@@ -228,7 +228,7 @@ public class WebFluxConfigurationSupportTests {
|
||||
assertThat(handler.getOrder()).isEqualTo(100);
|
||||
|
||||
List<HttpMessageWriter<?>> writers = handler.getMessageWriters();
|
||||
assertThat(writers.size()).isEqualTo(14);
|
||||
assertThat(writers).hasSize(14);
|
||||
|
||||
assertHasMessageWriter(writers, forClass(byte[].class), APPLICATION_OCTET_STREAM);
|
||||
assertHasMessageWriter(writers, forClass(ByteBuffer.class), APPLICATION_OCTET_STREAM);
|
||||
@@ -256,11 +256,11 @@ public class WebFluxConfigurationSupportTests {
|
||||
assertThat(handler.getOrder()).isEqualTo(Ordered.LOWEST_PRECEDENCE);
|
||||
|
||||
List<ViewResolver> resolvers = handler.getViewResolvers();
|
||||
assertThat(resolvers.size()).isEqualTo(1);
|
||||
assertThat(resolvers).hasSize(1);
|
||||
assertThat(resolvers.get(0).getClass()).isEqualTo(FreeMarkerViewResolver.class);
|
||||
|
||||
List<View> views = handler.getDefaultViews();
|
||||
assertThat(views.size()).isEqualTo(1);
|
||||
assertThat(views).hasSize(1);
|
||||
|
||||
MimeType type = MimeTypeUtils.parseMimeType("application/json");
|
||||
assertThat(views.get(0).getSupportedMediaTypes().get(0)).isEqualTo(type);
|
||||
|
||||
@@ -208,7 +208,7 @@ class MultipartIntegrationTests extends AbstractRouterFunctionIntegrationTests {
|
||||
.flatMap(map -> {
|
||||
Map<String, Part> parts = map.toSingleValueMap();
|
||||
try {
|
||||
assertThat(parts.size()).isEqualTo(2);
|
||||
assertThat(parts).hasSize(2);
|
||||
assertThat(((FilePart) parts.get("fooPart")).filename()).isEqualTo("foo.txt");
|
||||
assertThat(((FormFieldPart) parts.get("barPart")).value()).isEqualTo("bar");
|
||||
return Flux.fromIterable(parts.values())
|
||||
@@ -225,7 +225,7 @@ class MultipartIntegrationTests extends AbstractRouterFunctionIntegrationTests {
|
||||
return request.body(BodyExtractors.toParts()).collectList()
|
||||
.flatMap(parts -> {
|
||||
try {
|
||||
assertThat(parts.size()).isEqualTo(2);
|
||||
assertThat(parts).hasSize(2);
|
||||
assertThat(((FilePart) parts.get(0)).filename()).isEqualTo("foo.txt");
|
||||
assertThat(((FormFieldPart) parts.get(1)).value()).isEqualTo("bar");
|
||||
return Flux.fromIterable(parts)
|
||||
|
||||
@@ -70,9 +70,9 @@ public class DefaultClientRequestBuilderTests {
|
||||
|
||||
assertThat(result.url()).isEqualTo(DEFAULT_URL);
|
||||
assertThat(result.method()).isEqualTo(GET);
|
||||
assertThat(result.headers().size()).isEqualTo(1);
|
||||
assertThat(result.headers()).hasSize(1);
|
||||
assertThat(result.headers().getFirst("foo")).isEqualTo("baar");
|
||||
assertThat(result.cookies().size()).isEqualTo(1);
|
||||
assertThat(result.cookies()).hasSize(1);
|
||||
assertThat(result.cookies().getFirst("baz")).isEqualTo("quux");
|
||||
assertThat(result.httpRequest()).isNotNull();
|
||||
assertThat(result.attributes().get("attributeKey")).isEqualTo("attributeValue");
|
||||
|
||||
@@ -88,10 +88,10 @@ class DefaultClientResponseBuilderTests {
|
||||
|
||||
|
||||
assertThat(result.statusCode()).isEqualTo(HttpStatus.BAD_REQUEST);
|
||||
assertThat(result.headers().asHttpHeaders().size()).isEqualTo(3);
|
||||
assertThat(result.headers().asHttpHeaders()).hasSize(3);
|
||||
assertThat(result.headers().asHttpHeaders().getFirst("foo")).isEqualTo("baar");
|
||||
assertThat(result.headers().asHttpHeaders().getFirst("bar")).isEqualTo("baz");
|
||||
assertThat(result.cookies().size()).isEqualTo(1);
|
||||
assertThat(result.cookies()).hasSize(1);
|
||||
assertThat(result.cookies().getFirst("baz").getValue()).isEqualTo("quux");
|
||||
assertThat(result.logPrefix()).isEqualTo("my-prefix");
|
||||
|
||||
|
||||
@@ -293,19 +293,19 @@ public class DefaultWebClientTests {
|
||||
// Now, verify what each client has.
|
||||
|
||||
WebClient.Builder builder1 = client1.mutate();
|
||||
builder1.filters(filters -> assertThat(filters.size()).isEqualTo(1));
|
||||
builder1.defaultHeaders(headers -> assertThat(headers.size()).isEqualTo(1));
|
||||
builder1.defaultCookies(cookies -> assertThat(cookies.size()).isEqualTo(1));
|
||||
builder1.filters(filters -> assertThat(filters).hasSize(1));
|
||||
builder1.defaultHeaders(headers -> assertThat(headers).hasSize(1));
|
||||
builder1.defaultCookies(cookies -> assertThat(cookies).hasSize(1));
|
||||
|
||||
WebClient.Builder builder2 = client2.mutate();
|
||||
builder2.filters(filters -> assertThat(filters.size()).isEqualTo(2));
|
||||
builder2.defaultHeaders(headers -> assertThat(headers.size()).isEqualTo(2));
|
||||
builder2.defaultCookies(cookies -> assertThat(cookies.size()).isEqualTo(2));
|
||||
builder2.filters(filters -> assertThat(filters).hasSize(2));
|
||||
builder2.defaultHeaders(headers -> assertThat(headers).hasSize(2));
|
||||
builder2.defaultCookies(cookies -> assertThat(cookies).hasSize(2));
|
||||
|
||||
WebClient.Builder builder1a = client1a.mutate();
|
||||
builder1a.filters(filters -> assertThat(filters.size()).isEqualTo(2));
|
||||
builder1a.defaultHeaders(headers -> assertThat(headers.size()).isEqualTo(2));
|
||||
builder1a.defaultCookies(cookies -> assertThat(cookies.size()).isEqualTo(2));
|
||||
builder1a.filters(filters -> assertThat(filters).hasSize(2));
|
||||
builder1a.defaultHeaders(headers -> assertThat(headers).hasSize(2));
|
||||
builder1a.defaultCookies(cookies -> assertThat(cookies).hasSize(2));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -403,7 +403,7 @@ public class DefaultServerRequestTests {
|
||||
Mono<MultiValueMap<String, String>> resultData = request.formData();
|
||||
StepVerifier.create(resultData)
|
||||
.consumeNextWith(formData -> {
|
||||
assertThat(formData.size()).isEqualTo(2);
|
||||
assertThat(formData).hasSize(2);
|
||||
assertThat(formData.getFirst("foo")).isEqualTo("bar");
|
||||
assertThat(formData.getFirst("baz")).isEqualTo("qux");
|
||||
})
|
||||
@@ -436,7 +436,7 @@ public class DefaultServerRequestTests {
|
||||
Mono<MultiValueMap<String, Part>> resultData = request.multipartData();
|
||||
StepVerifier.create(resultData)
|
||||
.consumeNextWith(formData -> {
|
||||
assertThat(formData.size()).isEqualTo(2);
|
||||
assertThat(formData).hasSize(2);
|
||||
|
||||
Part part = formData.getFirst("foo");
|
||||
boolean condition1 = part instanceof FormFieldPart;
|
||||
|
||||
@@ -97,7 +97,7 @@ class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTe
|
||||
|
||||
assertThat(result.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
List<Person> body = result.getBody();
|
||||
assertThat(body.size()).isEqualTo(2);
|
||||
assertThat(body).hasSize(2);
|
||||
assertThat(body.get(0).getName()).isEqualTo("John");
|
||||
assertThat(body.get(1).getName()).isEqualTo("Jane");
|
||||
}
|
||||
@@ -208,13 +208,13 @@ class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTe
|
||||
Map<String, String> pathVariables =
|
||||
(Map<String, String>) request.attributes().get(RouterFunctions.URI_TEMPLATE_VARIABLES_ATTRIBUTE);
|
||||
assertThat(pathVariables).isNotNull();
|
||||
assertThat(pathVariables.size()).isEqualTo(1);
|
||||
assertThat(pathVariables).hasSize(1);
|
||||
assertThat(pathVariables.get("foo")).isEqualTo("bar");
|
||||
|
||||
pathVariables =
|
||||
(Map<String, String>) request.attributes().get(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE);
|
||||
assertThat(pathVariables).isNotNull();
|
||||
assertThat(pathVariables.size()).isEqualTo(1);
|
||||
assertThat(pathVariables).hasSize(1);
|
||||
assertThat(pathVariables.get("foo")).isEqualTo("bar");
|
||||
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ class PublisherHandlerFunctionIntegrationTests extends AbstractRouterFunctionInt
|
||||
|
||||
assertThat(result.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
List<Person> body = result.getBody();
|
||||
assertThat(body.size()).isEqualTo(2);
|
||||
assertThat(body).hasSize(2);
|
||||
assertThat(body.get(0).getName()).isEqualTo("John");
|
||||
assertThat(body.get(1).getName()).isEqualTo("Jane");
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ class RenderingResponseIntegrationTests extends AbstractRouterFunctionIntegratio
|
||||
|
||||
assertThat(result.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
Map<String, String> body = parseBody(result.getBody());
|
||||
assertThat(body.size()).isEqualTo(2);
|
||||
assertThat(body).hasSize(2);
|
||||
assertThat(body.get("name")).isEqualTo("foo");
|
||||
assertThat(body.get("bar")).isEqualTo("baz");
|
||||
}
|
||||
@@ -95,7 +95,7 @@ class RenderingResponseIntegrationTests extends AbstractRouterFunctionIntegratio
|
||||
|
||||
assertThat(result.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
Map<String, String> body = parseBody(result.getBody());
|
||||
assertThat(body.size()).isEqualTo(3);
|
||||
assertThat(body).hasSize(3);
|
||||
assertThat(body.get("name")).isEqualTo("foo");
|
||||
assertThat(body.get("bar")).isEqualTo("baz");
|
||||
assertThat(body.get("qux")).isEqualTo("quux");
|
||||
|
||||
@@ -148,7 +148,7 @@ public class HeadersRequestConditionTests {
|
||||
|
||||
HeadersRequestCondition result = condition1.combine(condition2);
|
||||
Collection<?> conditions = result.getContent();
|
||||
assertThat(conditions.size()).isEqualTo(2);
|
||||
assertThat(conditions).hasSize(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -119,7 +119,7 @@ public class ParamsRequestConditionTests {
|
||||
|
||||
ParamsRequestCondition result = condition1.combine(condition2);
|
||||
Collection<?> conditions = result.getContent();
|
||||
assertThat(conditions.size()).isEqualTo(2);
|
||||
assertThat(conditions).hasSize(2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ public class PatternsRequestConditionTests {
|
||||
@Test
|
||||
public void equallyMatchingPatternsAreBothPresent() {
|
||||
PatternsRequestCondition c = createPatternsCondition("/a", "/b");
|
||||
assertThat(c.getPatterns().size()).isEqualTo(2);
|
||||
assertThat(c.getPatterns()).hasSize(2);
|
||||
Iterator<PathPattern> itr = c.getPatterns().iterator();
|
||||
assertThat(itr.next().getPatternString()).isEqualTo("/a");
|
||||
assertThat(itr.next().getPatternString()).isEqualTo("/b");
|
||||
|
||||
@@ -56,7 +56,7 @@ public class RequestMappingInfoTests {
|
||||
|
||||
PathPattern emptyPattern = (new PathPatternParser()).parse("");
|
||||
assertThat(info.getPatternsCondition().getPatterns()).isEqualTo(Collections.singleton(emptyPattern));
|
||||
assertThat(info.getMethodsCondition().getMethods().size()).isEqualTo(0);
|
||||
assertThat(info.getMethodsCondition().getMethods()).hasSize(0);
|
||||
assertThat(info.getConsumesCondition().isEmpty()).isTrue();
|
||||
assertThat(info.getProducesCondition().isEmpty()).isTrue();
|
||||
assertThat(info.getParamsCondition()).isNotNull();
|
||||
@@ -93,7 +93,7 @@ public class RequestMappingInfoTests {
|
||||
public void prependPatternWithSlash() {
|
||||
RequestMappingInfo actual = paths("foo").build();
|
||||
List<PathPattern> patterns = new ArrayList<>(actual.getPatternsCondition().getPatterns());
|
||||
assertThat(patterns.size()).isEqualTo(1);
|
||||
assertThat(patterns).hasSize(1);
|
||||
assertThat(patterns.get(0).getPatternString()).isEqualTo("/foo");
|
||||
}
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ public class RequestMethodsRequestConditionTests {
|
||||
RequestMethodsRequestCondition condition2 = new RequestMethodsRequestCondition(POST);
|
||||
|
||||
RequestMethodsRequestCondition result = condition1.combine(condition2);
|
||||
assertThat(result.getContent().size()).isEqualTo(2);
|
||||
assertThat(result.getContent()).hasSize(2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -306,7 +306,7 @@ public class RequestMappingInfoHandlerMappingTests {
|
||||
// segment is a sequence of name-value pairs.
|
||||
|
||||
assertThat(matrixVariables).isNotNull();
|
||||
assertThat(matrixVariables.size()).isEqualTo(1);
|
||||
assertThat(matrixVariables).hasSize(1);
|
||||
assertThat(matrixVariables.getFirst("b")).isEqualTo("c");
|
||||
assertThat(uriVariables.get("foo")).isEqualTo("a=42");
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ public class ControllerAdviceTests {
|
||||
|
||||
Model model = handle(adapter, controller, "handle").getModel();
|
||||
|
||||
assertThat(model.asMap().size()).isEqualTo(2);
|
||||
assertThat(model.asMap()).hasSize(2);
|
||||
assertThat(model.asMap().get("attr1")).isEqualTo("lAttr1");
|
||||
assertThat(model.asMap().get("attr2")).isEqualTo("gAttr2");
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ public class ModelInitializerTests {
|
||||
this.modelInitializer.initModel(handlerMethod, context, this.exchange).block(TIMEOUT);
|
||||
|
||||
Map<String, Object> model = context.getModel().asMap();
|
||||
assertThat(model.size()).isEqualTo(5);
|
||||
assertThat(model).hasSize(5);
|
||||
|
||||
Object value = model.get("bean");
|
||||
assertThat(((TestBean) value).getName()).isEqualTo("Bean");
|
||||
@@ -141,10 +141,10 @@ public class ModelInitializerTests {
|
||||
|
||||
WebSession session = this.exchange.getSession().block(Duration.ZERO);
|
||||
assertThat(session).isNotNull();
|
||||
assertThat(session.getAttributes().size()).isEqualTo(0);
|
||||
assertThat(session.getAttributes()).hasSize(0);
|
||||
|
||||
context.saveModel();
|
||||
assertThat(session.getAttributes().size()).isEqualTo(1);
|
||||
assertThat(session.getAttributes()).hasSize(1);
|
||||
assertThat(((TestBean) session.getRequiredAttribute("bean")).getName()).isEqualTo("Bean");
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ public class ModelInitializerTests {
|
||||
this.modelInitializer.initModel(handlerMethod, context, this.exchange).block(TIMEOUT);
|
||||
|
||||
context.saveModel();
|
||||
assertThat(session.getAttributes().size()).isEqualTo(1);
|
||||
assertThat(session.getAttributes()).hasSize(1);
|
||||
assertThat(((TestBean) session.getRequiredAttribute("bean")).getName()).isEqualTo("Session Bean");
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ public class ModelInitializerTests {
|
||||
context.getSessionStatus().setComplete();
|
||||
context.saveModel();
|
||||
|
||||
assertThat(session.getAttributes().size()).isEqualTo(0);
|
||||
assertThat(session.getAttributes()).hasSize(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -168,11 +168,11 @@ public class RequestMappingHandlerMappingTests {
|
||||
assertThat(info).isNotNull();
|
||||
|
||||
Set<PathPattern> paths = info.getPatternsCondition().getPatterns();
|
||||
assertThat(paths.size()).isEqualTo(1);
|
||||
assertThat(paths).hasSize(1);
|
||||
assertThat(paths.iterator().next().getPatternString()).isEqualTo(path);
|
||||
|
||||
Set<RequestMethod> methods = info.getMethodsCondition().getMethods();
|
||||
assertThat(methods.size()).isEqualTo(1);
|
||||
assertThat(methods).hasSize(1);
|
||||
assertThat(methods.iterator().next()).isEqualTo(requestMethod);
|
||||
|
||||
return info;
|
||||
|
||||
@@ -358,7 +358,7 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq
|
||||
asList(new Person("Robert"), new Person("Marie")), null, Void.class);
|
||||
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(getApplicationContext().getBean(PersonCreateController.class).persons.size()).isEqualTo(2);
|
||||
assertThat(getApplicationContext().getBean(PersonCreateController.class).persons).hasSize(2);
|
||||
}
|
||||
|
||||
@ParameterizedHttpServerTest
|
||||
@@ -369,7 +369,7 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq
|
||||
ResponseEntity<Void> response = performPost("/person-create/publisher", APPLICATION_XML, people, null, Void.class);
|
||||
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(getApplicationContext().getBean(PersonCreateController.class).persons.size()).isEqualTo(2);
|
||||
assertThat(getApplicationContext().getBean(PersonCreateController.class).persons).hasSize(2);
|
||||
}
|
||||
|
||||
@ParameterizedHttpServerTest
|
||||
@@ -380,7 +380,7 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq
|
||||
"/person-create/mono", JSON, new Person("Robert"), null, Void.class);
|
||||
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(getApplicationContext().getBean(PersonCreateController.class).persons.size()).isEqualTo(1);
|
||||
assertThat(getApplicationContext().getBean(PersonCreateController.class).persons).hasSize(1);
|
||||
}
|
||||
|
||||
@ParameterizedHttpServerTest
|
||||
@@ -391,7 +391,7 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq
|
||||
"/person-create/single", JSON, new Person("Robert"), null, Void.class);
|
||||
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(getApplicationContext().getBean(PersonCreateController.class).persons.size()).isEqualTo(1);
|
||||
assertThat(getApplicationContext().getBean(PersonCreateController.class).persons).hasSize(1);
|
||||
}
|
||||
|
||||
@ParameterizedHttpServerTest
|
||||
@@ -402,7 +402,7 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq
|
||||
asList(new Person("Robert"), new Person("Marie")), null, Void.class);
|
||||
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(getApplicationContext().getBean(PersonCreateController.class).persons.size()).isEqualTo(2);
|
||||
assertThat(getApplicationContext().getBean(PersonCreateController.class).persons).hasSize(2);
|
||||
}
|
||||
|
||||
@ParameterizedHttpServerTest
|
||||
@@ -413,7 +413,7 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq
|
||||
ResponseEntity<Void> response = performPost("/person-create/flux", APPLICATION_XML, people, null, Void.class);
|
||||
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(getApplicationContext().getBean(PersonCreateController.class).persons.size()).isEqualTo(2);
|
||||
assertThat(getApplicationContext().getBean(PersonCreateController.class).persons).hasSize(2);
|
||||
}
|
||||
|
||||
@ParameterizedHttpServerTest
|
||||
@@ -424,7 +424,7 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq
|
||||
asList(new Person("Robert"), new Person("Marie")), null, Void.class);
|
||||
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(getApplicationContext().getBean(PersonCreateController.class).persons.size()).isEqualTo(2);
|
||||
assertThat(getApplicationContext().getBean(PersonCreateController.class).persons).hasSize(2);
|
||||
}
|
||||
|
||||
@ParameterizedHttpServerTest
|
||||
@@ -435,7 +435,7 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq
|
||||
ResponseEntity<Void> response = performPost("/person-create/observable", APPLICATION_XML, people, null, Void.class);
|
||||
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(getApplicationContext().getBean(PersonCreateController.class).persons.size()).isEqualTo(2);
|
||||
assertThat(getApplicationContext().getBean(PersonCreateController.class).persons).hasSize(2);
|
||||
}
|
||||
|
||||
@ParameterizedHttpServerTest
|
||||
@@ -446,7 +446,7 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq
|
||||
asList(new Person("Robert"), new Person("Marie")), null, Void.class);
|
||||
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(getApplicationContext().getBean(PersonCreateController.class).persons.size()).isEqualTo(2);
|
||||
assertThat(getApplicationContext().getBean(PersonCreateController.class).persons).hasSize(2);
|
||||
}
|
||||
|
||||
@ParameterizedHttpServerTest
|
||||
@@ -457,7 +457,7 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq
|
||||
ResponseEntity<Void> response = performPost("/person-create/flowable", APPLICATION_XML, people, null, Void.class);
|
||||
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(getApplicationContext().getBean(PersonCreateController.class).persons.size()).isEqualTo(2);
|
||||
assertThat(getApplicationContext().getBean(PersonCreateController.class).persons).hasSize(2);
|
||||
}
|
||||
|
||||
@ParameterizedHttpServerTest // gh-23791
|
||||
|
||||
@@ -173,7 +173,7 @@ public class ResponseEntityResultHandlerTests {
|
||||
this.resultHandler.handleResult(exchange, result).block(Duration.ofSeconds(5));
|
||||
|
||||
assertThat(exchange.getResponse().getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
|
||||
assertThat(exchange.getResponse().getHeaders().size()).isEqualTo(0);
|
||||
assertThat(exchange.getResponse().getHeaders()).hasSize(0);
|
||||
assertResponseBodyIsEmpty(exchange);
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ public class ResponseEntityResultHandlerTests {
|
||||
this.resultHandler.handleResult(exchange, result).block(Duration.ofSeconds(5));
|
||||
|
||||
assertThat(exchange.getResponse().getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(exchange.getResponse().getHeaders().size()).isEqualTo(1);
|
||||
assertThat(exchange.getResponse().getHeaders()).hasSize(1);
|
||||
assertThat(exchange.getResponse().getHeaders().getFirst("Allow")).isEqualTo("GET,POST,OPTIONS");
|
||||
assertResponseBodyIsEmpty(exchange);
|
||||
}
|
||||
@@ -202,7 +202,7 @@ public class ResponseEntityResultHandlerTests {
|
||||
this.resultHandler.handleResult(exchange, result).block(Duration.ofSeconds(5));
|
||||
|
||||
assertThat(exchange.getResponse().getStatusCode()).isEqualTo(HttpStatus.CREATED);
|
||||
assertThat(exchange.getResponse().getHeaders().size()).isEqualTo(1);
|
||||
assertThat(exchange.getResponse().getHeaders()).hasSize(1);
|
||||
assertThat(exchange.getResponse().getHeaders().getLocation()).isEqualTo(location);
|
||||
assertResponseBodyIsEmpty(exchange);
|
||||
}
|
||||
@@ -272,7 +272,7 @@ public class ResponseEntityResultHandlerTests {
|
||||
this.resultHandler.handleResult(exchange, result).block(Duration.ofSeconds(5));
|
||||
|
||||
assertThat(exchange.getResponse().getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST);
|
||||
assertThat(exchange.getResponse().getHeaders().size()).isEqualTo(2);
|
||||
assertThat(exchange.getResponse().getHeaders()).hasSize(2);
|
||||
assertThat(exchange.getResponse().getHeaders().getContentType()).isEqualTo(MediaType.APPLICATION_PROBLEM_JSON);
|
||||
assertResponseBody(exchange,
|
||||
"{\"type\":\"about:blank\"," +
|
||||
@@ -401,7 +401,7 @@ public class ResponseEntityResultHandlerTests {
|
||||
this.resultHandler.handleResult(exchange, result).block(Duration.ofSeconds(5));
|
||||
|
||||
assertThat(exchange.getResponse().getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(exchange.getResponse().getHeaders().size()).isEqualTo(1);
|
||||
assertThat(exchange.getResponse().getHeaders()).hasSize(1);
|
||||
assertThat(exchange.getResponse().getHeaders().getContentType()).isEqualTo(MediaType.APPLICATION_JSON);
|
||||
assertResponseBodyIsEmpty(exchange);
|
||||
}
|
||||
@@ -535,11 +535,11 @@ public class ResponseEntityResultHandlerTests {
|
||||
assertResponseBodyIsEmpty(exchange);
|
||||
}
|
||||
if (etag != null) {
|
||||
assertThat(exchange.getResponse().getHeaders().get(HttpHeaders.ETAG).size()).isEqualTo(1);
|
||||
assertThat(exchange.getResponse().getHeaders().get(HttpHeaders.ETAG)).hasSize(1);
|
||||
assertThat(exchange.getResponse().getHeaders().getETag()).isEqualTo(etag);
|
||||
}
|
||||
if (lastModified.isAfter(Instant.EPOCH)) {
|
||||
assertThat(exchange.getResponse().getHeaders().get(HttpHeaders.LAST_MODIFIED).size()).isEqualTo(1);
|
||||
assertThat(exchange.getResponse().getHeaders().get(HttpHeaders.LAST_MODIFIED)).hasSize(1);
|
||||
assertThat(exchange.getResponse().getHeaders().getLastModified()).isEqualTo(lastModified.toEpochMilli());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class DefaultRenderingBuilderTests {
|
||||
assertThat(rendering.view()).isEqualTo("abc");
|
||||
assertThat(rendering.modelAttributes()).isEqualTo(Collections.emptyMap());
|
||||
assertThat(rendering.status()).isNull();
|
||||
assertThat(rendering.headers().size()).isEqualTo(0);
|
||||
assertThat(rendering.headers()).hasSize(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -95,7 +95,7 @@ public class DefaultRenderingBuilderTests {
|
||||
public void header() throws Exception {
|
||||
Rendering rendering = Rendering.view("foo").header("foo", "bar").build();
|
||||
|
||||
assertThat(rendering.headers().size()).isEqualTo(1);
|
||||
assertThat(rendering.headers()).hasSize(1);
|
||||
assertThat(rendering.headers().get("foo")).isEqualTo(Collections.singletonList("bar"));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user