Use AssertJ's isEmpty() instead of hasSize(0)

Achieved via global search-and-replace.
This commit is contained in:
Sam Brannen
2022-11-22 17:11:50 +01:00
parent d5b0b2b1a1
commit 7fcd1de8e3
79 changed files with 260 additions and 295 deletions

View File

@@ -112,8 +112,8 @@ public class DelegatingWebMvcConfigurationTests {
assertThat(initializer.getConversionService()).isSameAs(conversionService.getValue());
boolean condition = initializer.getValidator() instanceof LocalValidatorFactoryBean;
assertThat(condition).isTrue();
assertThat(resolvers.getValue()).hasSize(0);
assertThat(handlers.getValue()).hasSize(0);
assertThat(resolvers.getValue()).isEmpty();
assertThat(handlers.getValue()).isEmpty();
assertThat(adapter.getMessageConverters()).isEqualTo(converters.getValue());
assertThat(asyncConfigurer).isNotNull();
}

View File

@@ -86,7 +86,7 @@ public class ViewResolverRegistryTests {
@Test
public void noResolvers() {
assertThat(this.registry.getViewResolvers()).isNotNull();
assertThat(this.registry.getViewResolvers()).hasSize(0);
assertThat(this.registry.getViewResolvers()).isEmpty();
assertThat(this.registry.hasRegistrations()).isFalse();
}

View File

@@ -296,7 +296,7 @@ public class WebMvcConfigurationSupportTests {
ViewResolverComposite resolver = context.getBean("mvcViewResolver", ViewResolverComposite.class);
assertThat(resolver).isNotNull();
assertThat(resolver.getViewResolvers()).hasSize(0);
assertThat(resolver.getViewResolvers()).isEmpty();
assertThat(resolver.getOrder()).isEqualTo(Ordered.LOWEST_PRECEDENCE);
assertThat(resolver.resolveViewName("anyViewName", Locale.ENGLISH)).isNull();
}

View File

@@ -162,7 +162,7 @@ public class ResourceHandlerFunctionTests {
assertThat(servletResponse.getStatus()).isEqualTo(200);
byte[] actualBytes = servletResponse.getContentAsByteArray();
assertThat(actualBytes).hasSize(0);
assertThat(actualBytes).isEmpty();
assertThat(servletResponse.getContentType()).isEqualTo(MediaType.TEXT_PLAIN_VALUE);
assertThat(servletResponse.getContentLength()).isEqualTo(this.resource.contentLength());
}
@@ -185,7 +185,7 @@ public class ResourceHandlerFunctionTests {
String[] methods = StringUtils.tokenizeToStringArray(allowHeader, ",");
assertThat(methods).containsExactlyInAnyOrder("GET","HEAD","OPTIONS");
byte[] actualBytes = servletResponse.getContentAsByteArray();
assertThat(actualBytes).hasSize(0);
assertThat(actualBytes).isEmpty();
}
}

View File

@@ -165,7 +165,7 @@ public class HandlerMethodMappingTests {
mapping1.setApplicationContext(new StaticApplicationContext(cxt));
mapping1.afterPropertiesSet();
assertThat(mapping1.getHandlerMethods()).hasSize(0);
assertThat(mapping1.getHandlerMethods()).isEmpty();
AbstractHandlerMethodMapping<String> mapping2 = new MyHandlerMethodMapping();
mapping2.setDetectHandlerMethodsInAncestorContexts(true);

View File

@@ -59,7 +59,7 @@ class RequestMappingInfoTests {
// gh-22543
RequestMappingInfo info = infoBuilder.build();
assertThat(info.getPatternValues()).isEqualTo(Collections.singleton(""));
assertThat(info.getMethodsCondition().getMethods()).hasSize(0);
assertThat(info.getMethodsCondition().getMethods()).isEmpty();
assertThat(info.getParamsCondition()).isNotNull();
assertThat(info.getHeadersCondition()).isNotNull();
assertThat(info.getConsumesCondition().isEmpty()).isTrue();

View File

@@ -832,7 +832,7 @@ public class HttpEntityMethodProcessorMockTests {
assertResponseBody(body);
}
else {
assertThat(servletResponse.getContentAsByteArray()).hasSize(0);
assertThat(servletResponse.getContentAsByteArray()).isEmpty();
}
if (etag != null) {
assertThat(servletResponse.getHeaderValues(HttpHeaders.ETAG)).hasSize(1);

View File

@@ -179,7 +179,7 @@ public class AnnotationConfigDispatcherServletInitializerTests {
initializer.onStartup(servletContext);
assertThat(filterRegistrations).hasSize(0);
assertThat(filterRegistrations).isEmpty();
}

View File

@@ -351,7 +351,7 @@ public class UrlTagTests extends AbstractTagTests {
String uri = tag.replaceUriTemplateParams("url/path", params, usedParams);
assertThat(uri).isEqualTo("url/path");
assertThat(usedParams).hasSize(0);
assertThat(usedParams).isEmpty();
}
@Test
@@ -361,7 +361,7 @@ public class UrlTagTests extends AbstractTagTests {
String uri = tag.replaceUriTemplateParams("url/{path}", params, usedParams);
assertThat(uri).isEqualTo("url/{path}");
assertThat(usedParams).hasSize(0);
assertThat(usedParams).isEmpty();
}
@Test

View File

@@ -191,7 +191,7 @@ public class BaseViewTests {
public void ignoresNullAttributes() {
AbstractView v = new ConcreteView();
v.setAttributes(null);
assertThat(v.getStaticAttributes()).hasSize(0);
assertThat(v.getStaticAttributes()).isEmpty();
}
/**
@@ -201,14 +201,14 @@ public class BaseViewTests {
public void attributeCSVParsingIgnoresNull() {
AbstractView v = new ConcreteView();
v.setAttributesCSV(null);
assertThat(v.getStaticAttributes()).hasSize(0);
assertThat(v.getStaticAttributes()).isEmpty();
}
@Test
public void attributeCSVParsingIgnoresEmptyString() {
AbstractView v = new ConcreteView();
v.setAttributesCSV("");
assertThat(v.getStaticAttributes()).hasSize(0);
assertThat(v.getStaticAttributes()).isEmpty();
}
/**