From 7fcd1de8e301dc939ad7bec8814e3f98bc901bd1 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 22 Nov 2022 17:11:50 +0100 Subject: [PATCH] Use AssertJ's isEmpty() instead of hasSize(0) Achieved via global search-and-replace. --- .../AbstractRegexpMethodPointcutTests.java | 114 ------------------ .../support/JdkRegexpMethodPointcutTests.java | 89 +++++++++++++- .../beans/BeanWrapperEnumTests.java | 2 +- .../beans/factory/BeanFactoryUtilsTests.java | 4 +- .../PropertyResourceConfigurerTests.java | 2 +- .../config/YamlMapFactoryBeanTests.java | 2 +- .../support/BeanFactoryGenericsTests.java | 6 +- .../DefaultSingletonBeanRegistryTests.java | 4 +- .../factory/xml/EventPublicationTests.java | 2 +- .../PropertiesEditorTests.java | 2 +- .../CandidateComponentsIndexerTests.java | 6 +- .../CacheRemoveAllOperationTests.java | 2 +- .../aop/framework/AbstractAopProxyTests.java | 2 +- .../factory/xml/XmlBeanFactoryTests.java | 4 +- ...anningCandidateComponentProviderTests.java | 6 +- .../ConfigurationClassPostProcessorTests.java | 6 +- .../ConfigurationClassWithConditionTests.java | 2 +- .../DefaultLifecycleProcessorTests.java | 2 +- .../ResourceBundleMessageSourceTests.java | 2 +- .../org/springframework/ui/ModelMapTests.java | 10 +- .../tools/DynamicJavaFileManagerTests.java | 2 +- .../springframework/core/ConstantsTests.java | 2 +- ...ableTableParameterNameDiscovererTests.java | 2 +- .../core/annotation/AnnotationUtilsTests.java | 6 +- .../ComposedRepeatableAnnotationsTests.java | 2 +- ...otationsOnSingleAnnotatedElementTests.java | 6 +- .../core/convert/TypeDescriptorTests.java | 20 +-- .../GenericConversionServiceTests.java | 2 +- .../core/env/PropertySourceTests.java | 2 +- .../core/env/StandardEnvironmentTests.java | 10 +- .../core/type/AnnotationMetadataTests.java | 8 +- .../util/AntPathMatcherTests.java | 4 +- .../util/ConcurrentReferenceHashMapTests.java | 6 +- .../util/LinkedCaseInsensitiveMapTests.java | 14 +-- .../util/ObjectUtilsTests.java | 4 +- .../namedparam/NamedParameterUtilsTests.java | 4 +- .../jdbc/object/BatchSqlUpdateTests.java | 4 +- .../support/SQLErrorCodesFactoryTests.java | 6 +- .../jms/annotation/EnableJmsTests.java | 2 +- .../DefaultSubscriptionRegistryTests.java | 10 +- .../stomp/BufferingStompDecoderTests.java | 8 +- .../simp/stomp/StompDecoderTests.java | 14 +-- .../support/ChannelInterceptorTests.java | 2 +- .../support/MessageHeaderAccessorTests.java | 2 +- .../NativeMessageHeaderAccessorTests.java | 2 +- ...rEntityManagerFactoryIntegrationTests.java | 8 +- .../PersistenceXmlParsingTests.java | 10 +- .../mock/web/MockHttpServletRequestTests.java | 2 +- .../mock/web/MockServletContextTests.java | 4 +- .../context/TestContextConcurrencyTests.java | 2 +- ...notationConfigContextLoaderUtilsTests.java | 2 +- ...ntextLoaderUtilsContextHierarchyTests.java | 8 +- .../support/TestPropertySourceUtilsTests.java | 6 +- .../response/ResponseCreatorsTests.java | 32 ++--- .../http/HttpHeadersTests.java | 4 +- .../server/ServletServerHttpRequestTests.java | 2 +- .../reactive/ChannelSendOperatorTests.java | 2 +- .../server/reactive/HeadersAdaptersTests.java | 2 +- .../reactive/ServerHttpRequestTests.java | 2 +- .../web/util/WebUtilsTests.java | 2 +- .../web/util/pattern/PathPatternTests.java | 6 +- .../config/ResourceHandlerRegistryTests.java | 2 +- .../config/ViewResolverRegistryTests.java | 2 +- .../condition/RequestMappingInfoTests.java | 2 +- .../annotation/ModelInitializerTests.java | 4 +- .../ResponseEntityResultHandlerTests.java | 2 +- .../view/DefaultRenderingBuilderTests.java | 2 +- .../DelegatingWebMvcConfigurationTests.java | 4 +- .../annotation/ViewResolverRegistryTests.java | 2 +- .../WebMvcConfigurationSupportTests.java | 2 +- .../ResourceHandlerFunctionTests.java | 4 +- .../handler/HandlerMethodMappingTests.java | 2 +- .../mvc/method/RequestMappingInfoTests.java | 2 +- .../HttpEntityMethodProcessorMockTests.java | 2 +- ...nfigDispatcherServletInitializerTests.java | 2 +- .../web/servlet/tags/UrlTagTests.java | 4 +- .../web/servlet/view/BaseViewTests.java | 6 +- .../WebMvcStompEndpointRegistryTests.java | 2 +- .../StompSubProtocolHandlerTests.java | 2 +- 79 files changed, 260 insertions(+), 295 deletions(-) delete mode 100644 spring-aop/src/test/java/org/springframework/aop/support/AbstractRegexpMethodPointcutTests.java diff --git a/spring-aop/src/test/java/org/springframework/aop/support/AbstractRegexpMethodPointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/support/AbstractRegexpMethodPointcutTests.java deleted file mode 100644 index 4f196f6f11a..00000000000 --- a/spring-aop/src/test/java/org/springframework/aop/support/AbstractRegexpMethodPointcutTests.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2002-2019 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.aop.support; - -import java.io.IOException; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import org.springframework.beans.testfixture.beans.TestBean; -import org.springframework.core.testfixture.io.SerializationTestUtils; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Rod Johnson - * @author Dmitriy Kopylenko - * @author Chris Beams - */ -public abstract class AbstractRegexpMethodPointcutTests { - - private AbstractRegexpMethodPointcut rpc; - - @BeforeEach - public void setUp() { - rpc = getRegexpMethodPointcut(); - } - - protected abstract AbstractRegexpMethodPointcut getRegexpMethodPointcut(); - - @Test - public void testNoPatternSupplied() throws Exception { - noPatternSuppliedTests(rpc); - } - - @Test - public void testSerializationWithNoPatternSupplied() throws Exception { - rpc = SerializationTestUtils.serializeAndDeserialize(rpc); - noPatternSuppliedTests(rpc); - } - - protected void noPatternSuppliedTests(AbstractRegexpMethodPointcut rpc) throws Exception { - assertThat(rpc.matches(Object.class.getMethod("hashCode"), String.class)).isFalse(); - assertThat(rpc.matches(Object.class.getMethod("wait"), Object.class)).isFalse(); - assertThat(rpc.getPatterns()).hasSize(0); - } - - @Test - public void testExactMatch() throws Exception { - rpc.setPattern("java.lang.Object.hashCode"); - exactMatchTests(rpc); - rpc = SerializationTestUtils.serializeAndDeserialize(rpc); - exactMatchTests(rpc); - } - - protected void exactMatchTests(AbstractRegexpMethodPointcut rpc) throws Exception { - // assumes rpc.setPattern("java.lang.Object.hashCode"); - assertThat(rpc.matches(Object.class.getMethod("hashCode"), String.class)).isTrue(); - assertThat(rpc.matches(Object.class.getMethod("hashCode"), Object.class)).isTrue(); - assertThat(rpc.matches(Object.class.getMethod("wait"), Object.class)).isFalse(); - } - - @Test - public void testSpecificMatch() throws Exception { - rpc.setPattern("java.lang.String.hashCode"); - assertThat(rpc.matches(Object.class.getMethod("hashCode"), String.class)).isTrue(); - assertThat(rpc.matches(Object.class.getMethod("hashCode"), Object.class)).isFalse(); - } - - @Test - public void testWildcard() throws Exception { - rpc.setPattern(".*Object.hashCode"); - assertThat(rpc.matches(Object.class.getMethod("hashCode"), Object.class)).isTrue(); - assertThat(rpc.matches(Object.class.getMethod("wait"), Object.class)).isFalse(); - } - - @Test - public void testWildcardForOneClass() throws Exception { - rpc.setPattern("java.lang.Object.*"); - assertThat(rpc.matches(Object.class.getMethod("hashCode"), String.class)).isTrue(); - assertThat(rpc.matches(Object.class.getMethod("wait"), String.class)).isTrue(); - } - - @Test - public void testMatchesObjectClass() throws Exception { - rpc.setPattern("java.lang.Object.*"); - assertThat(rpc.matches(Exception.class.getMethod("hashCode"), IOException.class)).isTrue(); - // Doesn't match a method from Throwable - assertThat(rpc.matches(Exception.class.getMethod("getMessage"), Exception.class)).isFalse(); - } - - @Test - public void testWithExclusion() throws Exception { - this.rpc.setPattern(".*get.*"); - this.rpc.setExcludedPattern(".*Age.*"); - assertThat(this.rpc.matches(TestBean.class.getMethod("getName"), TestBean.class)).isTrue(); - assertThat(this.rpc.matches(TestBean.class.getMethod("getAge"), TestBean.class)).isFalse(); - } - -} diff --git a/spring-aop/src/test/java/org/springframework/aop/support/JdkRegexpMethodPointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/support/JdkRegexpMethodPointcutTests.java index 1e4c139274c..055dad7a8f6 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/JdkRegexpMethodPointcutTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/JdkRegexpMethodPointcutTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 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. @@ -16,14 +16,93 @@ package org.springframework.aop.support; +import java.io.IOException; + +import org.junit.jupiter.api.Test; + +import org.springframework.beans.testfixture.beans.TestBean; +import org.springframework.core.testfixture.io.SerializationTestUtils; + +import static org.assertj.core.api.Assertions.assertThat; + /** + * @author Rod Johnson + * @author Dmitriy Kopylenko + * @author Chris Beams * @author Dmitriy Kopylenko */ -public class JdkRegexpMethodPointcutTests extends AbstractRegexpMethodPointcutTests { +class JdkRegexpMethodPointcutTests { + + private AbstractRegexpMethodPointcut rpc = new JdkRegexpMethodPointcut(); + + + @Test + void noPatternSupplied() throws Exception { + noPatternSuppliedTests(rpc); + } + + @Test + void serializationWithNoPatternSupplied() throws Exception { + rpc = SerializationTestUtils.serializeAndDeserialize(rpc); + noPatternSuppliedTests(rpc); + } + + private void noPatternSuppliedTests(AbstractRegexpMethodPointcut rpc) throws Exception { + assertThat(rpc.matches(Object.class.getMethod("hashCode"), String.class)).isFalse(); + assertThat(rpc.matches(Object.class.getMethod("wait"), Object.class)).isFalse(); + assertThat(rpc.getPatterns()).isEmpty(); + } + + @Test + void exactMatch() throws Exception { + rpc.setPattern("java.lang.Object.hashCode"); + exactMatchTests(rpc); + rpc = SerializationTestUtils.serializeAndDeserialize(rpc); + exactMatchTests(rpc); + } + + private void exactMatchTests(AbstractRegexpMethodPointcut rpc) throws Exception { + // assumes rpc.setPattern("java.lang.Object.hashCode"); + assertThat(rpc.matches(Object.class.getMethod("hashCode"), String.class)).isTrue(); + assertThat(rpc.matches(Object.class.getMethod("hashCode"), Object.class)).isTrue(); + assertThat(rpc.matches(Object.class.getMethod("wait"), Object.class)).isFalse(); + } + + @Test + void specificMatch() throws Exception { + rpc.setPattern("java.lang.String.hashCode"); + assertThat(rpc.matches(Object.class.getMethod("hashCode"), String.class)).isTrue(); + assertThat(rpc.matches(Object.class.getMethod("hashCode"), Object.class)).isFalse(); + } + + @Test + void wildcard() throws Exception { + rpc.setPattern(".*Object.hashCode"); + assertThat(rpc.matches(Object.class.getMethod("hashCode"), Object.class)).isTrue(); + assertThat(rpc.matches(Object.class.getMethod("wait"), Object.class)).isFalse(); + } + + @Test + void wildcardForOneClass() throws Exception { + rpc.setPattern("java.lang.Object.*"); + assertThat(rpc.matches(Object.class.getMethod("hashCode"), String.class)).isTrue(); + assertThat(rpc.matches(Object.class.getMethod("wait"), String.class)).isTrue(); + } + + @Test + void matchesObjectClass() throws Exception { + rpc.setPattern("java.lang.Object.*"); + assertThat(rpc.matches(Exception.class.getMethod("hashCode"), IOException.class)).isTrue(); + // Doesn't match a method from Throwable + assertThat(rpc.matches(Exception.class.getMethod("getMessage"), Exception.class)).isFalse(); + } - @Override - protected AbstractRegexpMethodPointcut getRegexpMethodPointcut() { - return new JdkRegexpMethodPointcut(); + @Test + void withExclusion() throws Exception { + this.rpc.setPattern(".*get.*"); + this.rpc.setExcludedPattern(".*Age.*"); + assertThat(this.rpc.matches(TestBean.class.getMethod("getName"), TestBean.class)).isTrue(); + assertThat(this.rpc.matches(TestBean.class.getMethod("getAge"), TestBean.class)).isFalse(); } } diff --git a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperEnumTests.java b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperEnumTests.java index d6afe593f63..3dad8d527a6 100644 --- a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperEnumTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperEnumTests.java @@ -144,7 +144,7 @@ public class BeanWrapperEnumTests { bw.setAutoGrowNestedPaths(true); assertThat(gb.getStandardEnumSet()).isNull(); bw.getPropertyValue("standardEnumSet.class"); - assertThat(gb.getStandardEnumSet()).hasSize(0); + assertThat(gb.getStandardEnumSet()).isEmpty(); } @Test diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java index 1cf25a2022e..f7b9b56f59b 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java @@ -103,7 +103,7 @@ public class BeanFactoryUtilsTests { public void testHierarchicalNamesWithNoMatch() { List names = Arrays.asList( BeanFactoryUtils.beanNamesForTypeIncludingAncestors(this.listableBeanFactory, NoOp.class)); - assertThat(names).hasSize(0); + assertThat(names).isEmpty(); } @Test @@ -278,7 +278,7 @@ public class BeanFactoryUtilsTests { public void testHierarchicalNamesForAnnotationWithNoMatch() { List names = Arrays.asList( BeanFactoryUtils.beanNamesForAnnotationIncludingAncestors(this.listableBeanFactory, Override.class)); - assertThat(names).hasSize(0); + assertThat(names).isEmpty(); } @Test diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java index dc67f7e7b85..693025cee20 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java @@ -577,7 +577,7 @@ public class PropertyResourceConfigurerTests { TestBean tb = (TestBean) factory.getBean("tb"); assertThat(tb).isNotNull(); - assertThat(factory.getAliases("tb")).hasSize(0); + assertThat(factory.getAliases("tb")).isEmpty(); } @Test diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/YamlMapFactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/YamlMapFactoryBeanTests.java index b9a6adcdc13..abef27bf44d 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/YamlMapFactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/YamlMapFactoryBeanTests.java @@ -47,7 +47,7 @@ public class YamlMapFactoryBeanTests { public void testSetIgnoreResourceNotFound() { this.factory.setResolutionMethod(YamlMapFactoryBean.ResolutionMethod.OVERRIDE_AND_IGNORE); this.factory.setResources(new FileSystemResource("non-exsitent-file.yml")); - assertThat(this.factory.getObject()).hasSize(0); + assertThat(this.factory.getObject()).isEmpty(); } @Test diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java index a65718c67f0..3566ce4a14c 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java @@ -762,7 +762,7 @@ class BeanFactoryGenericsTests { assertThat(bf.getType("mock")).isNull(); assertThat(bf.getType("mock")).isNull(); Map beans = bf.getBeansOfType(Runnable.class); - assertThat(beans).hasSize(0); + assertThat(beans).isEmpty(); } @Test @@ -828,8 +828,8 @@ class BeanFactoryGenericsTests { assertThat(numberStoreNames).hasSize(2); assertThat(numberStoreNames[0]).isEqualTo("doubleStore"); assertThat(numberStoreNames[1]).isEqualTo("floatStore"); - assertThat(doubleStoreNames).hasSize(0); - assertThat(floatStoreNames).hasSize(0); + assertThat(doubleStoreNames).isEmpty(); + assertThat(floatStoreNames).isEmpty(); } @Test diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistryTests.java index f8df16623d1..47a476b3d81 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistryTests.java @@ -51,7 +51,7 @@ public class DefaultSingletonBeanRegistryTests { beanRegistry.destroySingletons(); assertThat(beanRegistry.getSingletonCount()).isEqualTo(0); - assertThat(beanRegistry.getSingletonNames()).hasSize(0); + assertThat(beanRegistry.getSingletonNames()).isEmpty(); } @Test @@ -72,7 +72,7 @@ public class DefaultSingletonBeanRegistryTests { beanRegistry.destroySingletons(); assertThat(beanRegistry.getSingletonCount()).isEqualTo(0); - assertThat(beanRegistry.getSingletonNames()).hasSize(0); + assertThat(beanRegistry.getSingletonNames()).isEmpty(); assertThat(tb.wasDestroyed()).isTrue(); } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/EventPublicationTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/EventPublicationTests.java index debc2ca067b..693e2a90540 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/EventPublicationTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/EventPublicationTests.java @@ -90,7 +90,7 @@ class EventPublicationTests { assertThat(componentDefinition1.getBeanDefinitions()).hasSize(1); BeanDefinition beanDefinition2 = componentDefinition2.getBeanDefinitions()[0]; assertThat(beanDefinition2.getPropertyValues().getPropertyValue("name").getValue()).isEqualTo(new TypedStringValue("Juergen Hoeller")); - assertThat(componentDefinition2.getBeanReferences()).hasSize(0); + assertThat(componentDefinition2.getBeanReferences()).isEmpty(); assertThat(componentDefinition2.getInnerBeanDefinitions()).hasSize(1); BeanDefinition innerBd2 = componentDefinition2.getInnerBeanDefinitions()[0]; assertThat(innerBd2.getPropertyValues().getPropertyValue("name").getValue()).isEqualTo(new TypedStringValue("Eva Schallmeiner")); diff --git a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/PropertiesEditorTests.java b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/PropertiesEditorTests.java index bad7108e4aa..7448789f1c5 100644 --- a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/PropertiesEditorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/PropertiesEditorTests.java @@ -139,7 +139,7 @@ public class PropertiesEditorTests { PropertiesEditor pe= new PropertiesEditor(); pe.setAsText(null); Properties p = (Properties) pe.getValue(); - assertThat(p).hasSize(0); + assertThat(p).isEmpty(); } @Test diff --git a/spring-context-indexer/src/test/java/org/springframework/context/index/processor/CandidateComponentsIndexerTests.java b/spring-context-indexer/src/test/java/org/springframework/context/index/processor/CandidateComponentsIndexerTests.java index be3d30dc420..629f4b51b5d 100644 --- a/spring-context-indexer/src/test/java/org/springframework/context/index/processor/CandidateComponentsIndexerTests.java +++ b/spring-context-indexer/src/test/java/org/springframework/context/index/processor/CandidateComponentsIndexerTests.java @@ -82,13 +82,13 @@ class CandidateComponentsIndexerTests { @Test void noCandidate() { CandidateComponentsMetadata metadata = compile(SampleNone.class); - assertThat(metadata.getItems()).hasSize(0); + assertThat(metadata.getItems()).isEmpty(); } @Test void noAnnotation() { CandidateComponentsMetadata metadata = compile(CandidateComponentsIndexerTests.class); - assertThat(metadata.getItems()).hasSize(0); + assertThat(metadata.getItems()).isEmpty(); } @Test @@ -214,7 +214,7 @@ class CandidateComponentsIndexerTests { @Test void embeddedNonStaticCandidateAreIgnored() { CandidateComponentsMetadata metadata = compile(SampleNonStaticEmbedded.class); - assertThat(metadata.getItems()).hasSize(0); + assertThat(metadata.getItems()).isEmpty(); } private void testComponent(Class... classes) { diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CacheRemoveAllOperationTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CacheRemoveAllOperationTests.java index beed4c7730b..17ef7dc3faf 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CacheRemoveAllOperationTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CacheRemoveAllOperationTests.java @@ -42,7 +42,7 @@ public class CacheRemoveAllOperationTests extends AbstractCacheOperationTests candidates = provider.findCandidateComponents("bogus"); - assertThat(candidates).hasSize(0); + assertThat(candidates).isEmpty(); } @Test @@ -138,7 +138,7 @@ class ClassPathScanningCandidateComponentProviderTests { ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(true); provider.setResourceLoader(new DefaultResourceLoader(TEST_BASE_CLASSLOADER)); Set candidates = provider.findCandidateComponents("bogus"); - assertThat(candidates).hasSize(0); + assertThat(candidates).isEmpty(); } @Test @@ -279,7 +279,7 @@ class ClassPathScanningCandidateComponentProviderTests { void withNoFilters() { ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false); Set candidates = provider.findCandidateComponents(TEST_BASE_PACKAGE); - assertThat(candidates).hasSize(0); + assertThat(candidates).isEmpty(); } @Test diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java index 22774cd1749..c21783c9c81 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java @@ -682,10 +682,10 @@ class ConfigurationClassPostProcessorTests { assertThat(beanNames).contains("stringRepo"); beanNames = beanFactory.getBeanNamesForType(ResolvableType.forClassWithGenerics(Repository.class, String.class)); - assertThat(beanNames).hasSize(0); + assertThat(beanNames).isEmpty(); beanNames = beanFactory.getBeanNamesForType(ResolvableType.forClassWithGenerics(Repository.class, String.class)); - assertThat(beanNames).hasSize(0); + assertThat(beanNames).isEmpty(); } @Test @@ -1040,7 +1040,7 @@ class ConfigurationClassPostProcessorTests { ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(VarargConfiguration.class); VarargConfiguration bean = ctx.getBean(VarargConfiguration.class); assertThat(bean.testBeans).isNotNull(); - assertThat(bean.testBeans).hasSize(0); + assertThat(bean.testBeans).isEmpty(); ctx.close(); } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassWithConditionTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassWithConditionTests.java index 768b11e460b..19f388f8bc0 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassWithConditionTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassWithConditionTests.java @@ -138,7 +138,7 @@ public class ConfigurationClassWithConditionTests { @Test public void conditionOnOverriddenMethodHonored() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConfigWithBeanSkipped.class); - assertThat(context.getBeansOfType(ExampleBean.class)).hasSize(0); + assertThat(context.getBeansOfType(ExampleBean.class)).isEmpty(); } @Test diff --git a/spring-context/src/test/java/org/springframework/context/support/DefaultLifecycleProcessorTests.java b/spring-context/src/test/java/org/springframework/context/support/DefaultLifecycleProcessorTests.java index 76ae95e9704..9bcfa4e7a69 100644 --- a/spring-context/src/test/java/org/springframework/context/support/DefaultLifecycleProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/DefaultLifecycleProcessorTests.java @@ -116,7 +116,7 @@ class DefaultLifecycleProcessorTests { assertThat(bean.isRunning()).isFalse(); context.refresh(); assertThat(bean.isRunning()).isFalse(); - assertThat(startedBeans).hasSize(0); + assertThat(startedBeans).isEmpty(); context.start(); assertThat(bean.isRunning()).isTrue(); assertThat(startedBeans).hasSize(1); diff --git a/spring-context/src/test/java/org/springframework/context/support/ResourceBundleMessageSourceTests.java b/spring-context/src/test/java/org/springframework/context/support/ResourceBundleMessageSourceTests.java index a3a443453dd..f2f133e9612 100644 --- a/spring-context/src/test/java/org/springframework/context/support/ResourceBundleMessageSourceTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/ResourceBundleMessageSourceTests.java @@ -414,7 +414,7 @@ class ResourceBundleMessageSourceTests { assertThat(filenames.get(0)).isEqualTo("messages__UK_POSIX"); filenames = ms.calculateFilenamesForLocale("messages", new Locale("", "", "POSIX")); - assertThat(filenames).hasSize(0); + assertThat(filenames).isEmpty(); } @Test diff --git a/spring-context/src/test/java/org/springframework/ui/ModelMapTests.java b/spring-context/src/test/java/org/springframework/ui/ModelMapTests.java index 76f66fa5d78..26381e7c833 100644 --- a/spring-context/src/test/java/org/springframework/ui/ModelMapTests.java +++ b/spring-context/src/test/java/org/springframework/ui/ModelMapTests.java @@ -44,7 +44,7 @@ public class ModelMapTests { @Test public void testNoArgCtorYieldsEmptyModel() throws Exception { - assertThat(new ModelMap()).hasSize(0); + assertThat(new ModelMap()).isEmpty(); } /* @@ -117,7 +117,7 @@ public class ModelMapTests { public void testOneArgCtorWithEmptyCollection() throws Exception { ModelMap model = new ModelMap(new HashSet<>()); // must not add if collection is empty... - assertThat(model).hasSize(0); + assertThat(model).isEmpty(); } @Test @@ -134,21 +134,21 @@ public class ModelMapTests { assertThat(model).hasSize(1); int[] ints = (int[]) model.get("intList"); assertThat(ints).isNotNull(); - assertThat(ints).hasSize(0); + assertThat(ints).isEmpty(); } @Test public void testAddAllObjectsWithNullMap() throws Exception { ModelMap model = new ModelMap(); model.addAllAttributes((Map) null); - assertThat(model).hasSize(0); + assertThat(model).isEmpty(); } @Test public void testAddAllObjectsWithNullCollection() throws Exception { ModelMap model = new ModelMap(); model.addAllAttributes((Collection) null); - assertThat(model).hasSize(0); + assertThat(model).isEmpty(); } @Test diff --git a/spring-core-test/src/test/java/org/springframework/core/test/tools/DynamicJavaFileManagerTests.java b/spring-core-test/src/test/java/org/springframework/core/test/tools/DynamicJavaFileManagerTests.java index 5f6e2442586..474c506bf70 100644 --- a/spring-core-test/src/test/java/org/springframework/core/test/tools/DynamicJavaFileManagerTests.java +++ b/spring-core-test/src/test/java/org/springframework/core/test/tools/DynamicJavaFileManagerTests.java @@ -136,7 +136,7 @@ class DynamicJavaFileManagerTests { void listWithoutClassKindDoesNotReturnClasses() throws IOException { Iterable listed = this.fileManager.list( this.location, "com.example", EnumSet.of(Kind.SOURCE), true); - assertThat(listed).hasSize(0); + assertThat(listed).isEmpty(); } @Test diff --git a/spring-core/src/test/java/org/springframework/core/ConstantsTests.java b/spring-core/src/test/java/org/springframework/core/ConstantsTests.java index a994c4f4b9c..ee2156319f0 100644 --- a/spring-core/src/test/java/org/springframework/core/ConstantsTests.java +++ b/spring-core/src/test/java/org/springframework/core/ConstantsTests.java @@ -217,7 +217,7 @@ class ConstantsTests { assertThat(c.getSize()).isEqualTo(0); final Set values = c.getValues(""); assertThat(values).isNotNull(); - assertThat(values).hasSize(0); + assertThat(values).isEmpty(); } @Test diff --git a/spring-core/src/test/java/org/springframework/core/LocalVariableTableParameterNameDiscovererTests.java b/spring-core/src/test/java/org/springframework/core/LocalVariableTableParameterNameDiscovererTests.java index 5288ff6dbdf..e0605d108c7 100644 --- a/spring-core/src/test/java/org/springframework/core/LocalVariableTableParameterNameDiscovererTests.java +++ b/spring-core/src/test/java/org/springframework/core/LocalVariableTableParameterNameDiscovererTests.java @@ -200,7 +200,7 @@ class LocalVariableTableParameterNameDiscovererTests { m = clazz.getMethod("getDate"); names = discoverer.getParameterNames(m); - assertThat(names).hasSize(0); + assertThat(names).isEmpty(); } @Disabled("Ignored because Ubuntu packages OpenJDK with debug symbols enabled. See SPR-8078.") diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java index 91859cf89c3..7b100eb49cb 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java @@ -706,17 +706,17 @@ class AnnotationUtilsTests { // Java 8 MyRepeatable[] array = clazz.getDeclaredAnnotationsByType(MyRepeatable.class); assertThat(array).isNotNull(); - assertThat(array).hasSize(0); + assertThat(array).isEmpty(); // Spring Set set = getDeclaredRepeatableAnnotations(clazz, MyRepeatable.class, MyRepeatableContainer.class); assertThat(set).isNotNull(); - assertThat(set).hasSize(0); + assertThat(set).isEmpty(); // When container type is omitted and therefore inferred from @Repeatable set = getDeclaredRepeatableAnnotations(clazz, MyRepeatable.class); assertThat(set).isNotNull(); - assertThat(set).hasSize(0); + assertThat(set).isEmpty(); } @Test diff --git a/spring-core/src/test/java/org/springframework/core/annotation/ComposedRepeatableAnnotationsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/ComposedRepeatableAnnotationsTests.java index 620eedf84ca..6ea71b90742 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/ComposedRepeatableAnnotationsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/ComposedRepeatableAnnotationsTests.java @@ -112,7 +112,7 @@ class ComposedRepeatableAnnotationsTests { Class element = SubNoninheritedRepeatableClass.class; Set annotations = getMergedRepeatableAnnotations(element, Noninherited.class); assertThat(annotations).isNotNull(); - assertThat(annotations).hasSize(0); + assertThat(annotations).isEmpty(); } @Test diff --git a/spring-core/src/test/java/org/springframework/core/annotation/MultipleComposedAnnotationsOnSingleAnnotatedElementTests.java b/spring-core/src/test/java/org/springframework/core/annotation/MultipleComposedAnnotationsOnSingleAnnotatedElementTests.java index 5bb172e5b2f..844c17fdf9e 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/MultipleComposedAnnotationsOnSingleAnnotatedElementTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/MultipleComposedAnnotationsOnSingleAnnotatedElementTests.java @@ -76,7 +76,7 @@ class MultipleComposedAnnotationsOnSingleAnnotatedElementTests { Class element = SubMultipleNoninheritedComposedCachesClass.class; Set cacheables = getAllMergedAnnotations(element, Cacheable.class); assertThat(cacheables).isNotNull(); - assertThat(cacheables).hasSize(0); + assertThat(cacheables).isEmpty(); } @Test @@ -89,7 +89,7 @@ class MultipleComposedAnnotationsOnSingleAnnotatedElementTests { Class element = MultipleComposedCachesOnInterfaceClass.class; Set cacheables = getAllMergedAnnotations(element, Cacheable.class); assertThat(cacheables).isNotNull(); - assertThat(cacheables).hasSize(0); + assertThat(cacheables).isEmpty(); } @Test @@ -109,7 +109,7 @@ class MultipleComposedAnnotationsOnSingleAnnotatedElementTests { void getMultipleComposedAnnotationsOnBridgeMethod() throws Exception { Set cacheables = getAllMergedAnnotations(getBridgeMethod(), Cacheable.class); assertThat(cacheables).isNotNull(); - assertThat(cacheables).hasSize(0); + assertThat(cacheables).isEmpty(); } @Test diff --git a/spring-core/src/test/java/org/springframework/core/convert/TypeDescriptorTests.java b/spring-core/src/test/java/org/springframework/core/convert/TypeDescriptorTests.java index 90a36277253..c48a8105d5b 100644 --- a/spring-core/src/test/java/org/springframework/core/convert/TypeDescriptorTests.java +++ b/spring-core/src/test/java/org/springframework/core/convert/TypeDescriptorTests.java @@ -65,7 +65,7 @@ class TypeDescriptorTests { assertThat(desc.getName()).isEqualTo("int"); assertThat(desc.toString()).isEqualTo("int"); assertThat(desc.isPrimitive()).isTrue(); - assertThat(desc.getAnnotations()).hasSize(0); + assertThat(desc.getAnnotations()).isEmpty(); assertThat(desc.isCollection()).isFalse(); assertThat(desc.isMap()).isFalse(); } @@ -78,7 +78,7 @@ class TypeDescriptorTests { assertThat(desc.getName()).isEqualTo("java.lang.String"); assertThat(desc.toString()).isEqualTo("java.lang.String"); assertThat(!desc.isPrimitive()).isTrue(); - assertThat(desc.getAnnotations()).hasSize(0); + assertThat(desc.getAnnotations()).isEmpty(); assertThat(desc.isCollection()).isFalse(); assertThat(desc.isArray()).isFalse(); assertThat(desc.isMap()).isFalse(); @@ -93,7 +93,7 @@ class TypeDescriptorTests { assertThat(desc.getName()).isEqualTo("java.util.List"); assertThat(desc.toString()).isEqualTo("java.util.List>>>"); assertThat(!desc.isPrimitive()).isTrue(); - assertThat(desc.getAnnotations()).hasSize(0); + assertThat(desc.getAnnotations()).isEmpty(); assertThat(desc.isCollection()).isTrue(); assertThat(desc.isArray()).isFalse(); assertThat(desc.getElementTypeDescriptor().getType()).isEqualTo(List.class); @@ -114,7 +114,7 @@ class TypeDescriptorTests { assertThat(desc.getName()).isEqualTo("java.util.List"); assertThat(desc.toString()).isEqualTo("java.util.List"); assertThat(!desc.isPrimitive()).isTrue(); - assertThat(desc.getAnnotations()).hasSize(0); + assertThat(desc.getAnnotations()).isEmpty(); assertThat(desc.isCollection()).isTrue(); assertThat(desc.isArray()).isFalse(); assertThat((Object) desc.getElementTypeDescriptor()).isNull(); @@ -130,7 +130,7 @@ class TypeDescriptorTests { assertThat(desc.getName()).isEqualTo("java.lang.Integer[]"); assertThat(desc.toString()).isEqualTo("java.lang.Integer[]"); assertThat(!desc.isPrimitive()).isTrue(); - assertThat(desc.getAnnotations()).hasSize(0); + assertThat(desc.getAnnotations()).isEmpty(); assertThat(desc.isCollection()).isFalse(); assertThat(desc.isArray()).isTrue(); assertThat(desc.getElementTypeDescriptor().getType()).isEqualTo(Integer.class); @@ -147,7 +147,7 @@ class TypeDescriptorTests { assertThat(desc.getName()).isEqualTo("java.util.Map"); assertThat(desc.toString()).isEqualTo("java.util.Map>"); assertThat(!desc.isPrimitive()).isTrue(); - assertThat(desc.getAnnotations()).hasSize(0); + assertThat(desc.getAnnotations()).isEmpty(); assertThat(desc.isCollection()).isFalse(); assertThat(desc.isArray()).isFalse(); assertThat(desc.isMap()).isTrue(); @@ -463,7 +463,7 @@ class TypeDescriptorTests { assertThat(desc.getName()).isEqualTo("java.util.List"); assertThat(desc.toString()).isEqualTo("java.util.List"); assertThat(!desc.isPrimitive()).isTrue(); - assertThat(desc.getAnnotations()).hasSize(0); + assertThat(desc.getAnnotations()).isEmpty(); assertThat(desc.isCollection()).isTrue(); assertThat(desc.isArray()).isFalse(); assertThat(desc.getElementTypeDescriptor().getType()).isEqualTo(Integer.class); @@ -479,7 +479,7 @@ class TypeDescriptorTests { assertThat(desc.getName()).isEqualTo("java.util.List"); assertThat(desc.toString()).isEqualTo("java.util.List>"); assertThat(!desc.isPrimitive()).isTrue(); - assertThat(desc.getAnnotations()).hasSize(0); + assertThat(desc.getAnnotations()).isEmpty(); assertThat(desc.isCollection()).isTrue(); assertThat(desc.isArray()).isFalse(); assertThat(desc.getElementTypeDescriptor().getType()).isEqualTo(List.class); @@ -495,7 +495,7 @@ class TypeDescriptorTests { assertThat(desc.getName()).isEqualTo("java.util.Map"); assertThat(desc.toString()).isEqualTo("java.util.Map"); assertThat(!desc.isPrimitive()).isTrue(); - assertThat(desc.getAnnotations()).hasSize(0); + assertThat(desc.getAnnotations()).isEmpty(); assertThat(desc.isCollection()).isFalse(); assertThat(desc.isArray()).isFalse(); assertThat(desc.isMap()).isTrue(); @@ -512,7 +512,7 @@ class TypeDescriptorTests { assertThat(desc.getName()).isEqualTo("java.util.Map"); assertThat(desc.toString()).isEqualTo("java.util.Map>"); assertThat(!desc.isPrimitive()).isTrue(); - assertThat(desc.getAnnotations()).hasSize(0); + assertThat(desc.getAnnotations()).isEmpty(); assertThat(desc.isCollection()).isFalse(); assertThat(desc.isArray()).isFalse(); assertThat(desc.isMap()).isTrue(); diff --git a/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java b/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java index c0a74d29a5e..a82108ca57a 100644 --- a/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java +++ b/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java @@ -335,7 +335,7 @@ class GenericConversionServiceTests { TypeDescriptor sourceType = TypeDescriptor.forObject(list); TypeDescriptor targetType = TypeDescriptor.valueOf(String[].class); assertThat(conversionService.canConvert(sourceType, targetType)).isTrue(); - assertThat(((String[]) conversionService.convert(list, sourceType, targetType))).hasSize(0); + assertThat(((String[]) conversionService.convert(list, sourceType, targetType))).isEmpty(); } @Test diff --git a/spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.java b/spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.java index 6256832b2f6..beeaf18e8ea 100644 --- a/spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.java @@ -89,7 +89,7 @@ class PropertySourceTests { assertThat(propertySources.remove(PropertySource.named("ps1"))).isTrue(); assertThat(propertySources).hasSize(1); assertThat(propertySources.remove(PropertySource.named("ps1"))).isTrue(); - assertThat(propertySources).hasSize(0); + assertThat(propertySources).isEmpty(); PropertySource ps2 = new MapPropertySource("ps2", map2); propertySources.add(ps1); diff --git a/spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java b/spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java index 74242111f20..4768f8c3cd2 100644 --- a/spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java @@ -113,7 +113,7 @@ public class StandardEnvironmentTests { @Test void activeProfilesIsEmptyByDefault() { - assertThat(environment.getActiveProfiles()).hasSize(0); + assertThat(environment.getActiveProfiles()).isEmpty(); } @Test @@ -172,7 +172,7 @@ public class StandardEnvironmentTests { @Test void addActiveProfile() { - assertThat(environment.getActiveProfiles()).hasSize(0); + assertThat(environment.getActiveProfiles()).isEmpty(); environment.setActiveProfiles("local", "embedded"); assertThat(environment.getActiveProfiles()).contains("local", "embedded"); assertThat(environment.getActiveProfiles()).hasSize(2); @@ -218,9 +218,9 @@ public class StandardEnvironmentTests { @Test void getActiveProfiles_systemPropertiesEmpty() { - assertThat(environment.getActiveProfiles()).hasSize(0); + assertThat(environment.getActiveProfiles()).isEmpty(); System.setProperty(ACTIVE_PROFILES_PROPERTY_NAME, ""); - assertThat(environment.getActiveProfiles()).hasSize(0); + assertThat(environment.getActiveProfiles()).isEmpty(); System.clearProperty(ACTIVE_PROFILES_PROPERTY_NAME); } @@ -256,7 +256,7 @@ public class StandardEnvironmentTests { @Test void setDefaultProfiles() { environment.setDefaultProfiles(); - assertThat(environment.getDefaultProfiles()).hasSize(0); + assertThat(environment.getDefaultProfiles()).isEmpty(); environment.setDefaultProfiles("pd1"); assertThat(Arrays.asList(environment.getDefaultProfiles())).contains("pd1"); environment.setDefaultProfiles("pd2", "pd3"); diff --git a/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java b/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java index d411c598ebc..2066b056a74 100644 --- a/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java @@ -90,7 +90,7 @@ class AnnotationMetadataTests { assertThat(metadata.isConcrete()).isTrue(); assertThat(metadata.hasSuperClass()).isTrue(); assertThat(metadata.getSuperClassName()).isEqualTo(AnnotatedComponent.class.getName()); - assertThat(metadata.getInterfaceNames()).hasSize(0); + assertThat(metadata.getInterfaceNames()).isEmpty(); assertThat(metadata.isAnnotated(Component.class.getName())).isFalse(); assertThat(metadata.isAnnotated(Scope.class.getName())).isFalse(); assertThat(metadata.isAnnotated(SpecialAttr.class.getName())).isFalse(); @@ -114,7 +114,7 @@ class AnnotationMetadataTests { assertThat(metadata.getAnnotationAttributes(Component.class.getName())).isNull(); assertThat(metadata.getAnnotationAttributes(MetaAnnotation.class.getName(), false)).isNull(); assertThat(metadata.getAnnotationAttributes(MetaAnnotation.class.getName(), true)).isNull(); - assertThat(metadata.getAnnotatedMethods(DirectAnnotation.class.getName())).hasSize(0); + assertThat(metadata.getAnnotatedMethods(DirectAnnotation.class.getName())).isEmpty(); assertThat(metadata.isAnnotated(IsAnnotatedAnnotation.class.getName())).isFalse(); assertThat(metadata.getAllAnnotationAttributes(DirectAnnotation.class.getName())).isNull(); } @@ -144,7 +144,7 @@ class AnnotationMetadataTests { assertThat(metadata.getInterfaceNames()).hasSize(2); assertThat(metadata.getInterfaceNames()[0]).isEqualTo(ClassMetadata.class.getName()); assertThat(metadata.getInterfaceNames()[1]).isEqualTo(AnnotatedTypeMetadata.class.getName()); - assertThat(metadata.getAnnotationTypes()).hasSize(0); + assertThat(metadata.getAnnotationTypes()).isEmpty(); } @Test @@ -363,7 +363,7 @@ class AnnotationMetadataTests { allMeta = metadata.getAllAnnotationAttributes(DirectAnnotation.class.getName()).get("additional"); assertThat(new HashSet<>(allMeta)).isEqualTo(new HashSet(Arrays.asList("direct", ""))); assertThat(metadata.getAnnotationAttributes(DirectAnnotation.class.getName()).get("additional")).isEqualTo(""); - assertThat(((String[]) metadata.getAnnotationAttributes(DirectAnnotation.class.getName()).get("additionalArray"))).hasSize(0); + assertThat(((String[]) metadata.getAnnotationAttributes(DirectAnnotation.class.getName()).get("additionalArray"))).isEmpty(); } { // perform tests with classValuesAsString = true AnnotationAttributes specialAttrs = (AnnotationAttributes) metadata.getAnnotationAttributes( diff --git a/spring-core/src/test/java/org/springframework/util/AntPathMatcherTests.java b/spring-core/src/test/java/org/springframework/util/AntPathMatcherTests.java index cee574910b7..5f1256a7067 100644 --- a/spring-core/src/test/java/org/springframework/util/AntPathMatcherTests.java +++ b/spring-core/src/test/java/org/springframework/util/AntPathMatcherTests.java @@ -647,7 +647,7 @@ class AntPathMatcherTests { @Test void preventCreatingStringMatchersIfPathDoesNotStartsWithPatternPrefix() { pathMatcher.setCachePatterns(true); - assertThat(pathMatcher.stringMatcherCache).hasSize(0); + assertThat(pathMatcher.stringMatcherCache).isEmpty(); pathMatcher.match("test?", "test"); assertThat(pathMatcher.stringMatcherCache).hasSize(1); @@ -662,7 +662,7 @@ class AntPathMatcherTests { @Test void creatingStringMatchersIfPatternPrefixCannotDetermineIfPathMatch() { pathMatcher.setCachePatterns(true); - assertThat(pathMatcher.stringMatcherCache).hasSize(0); + assertThat(pathMatcher.stringMatcherCache).isEmpty(); pathMatcher.match("test", "testian"); pathMatcher.match("test?", "testFf"); diff --git a/spring-core/src/test/java/org/springframework/util/ConcurrentReferenceHashMapTests.java b/spring-core/src/test/java/org/springframework/util/ConcurrentReferenceHashMapTests.java index ca9c41147c4..36ed20ae497 100644 --- a/spring-core/src/test/java/org/springframework/util/ConcurrentReferenceHashMapTests.java +++ b/spring-core/src/test/java/org/springframework/util/ConcurrentReferenceHashMapTests.java @@ -126,7 +126,7 @@ class ConcurrentReferenceHashMapTests { @Test void shouldPutAndGet() { // NOTE we are using mock references so we don't need to worry about GC - assertThat(this.map).hasSize(0); + assertThat(this.map).isEmpty(); this.map.put(123, "123"); assertThat(this.map.get(123)).isEqualTo("123"); assertThat(this.map).hasSize(1); @@ -327,7 +327,7 @@ class ConcurrentReferenceHashMapTests { @Test void shouldGetSize() { - assertThat(this.map).hasSize(0); + assertThat(this.map).isEmpty(); this.map.put(123, "123"); this.map.put(123, null); this.map.put(456, "456"); @@ -400,7 +400,7 @@ class ConcurrentReferenceHashMapTests { this.map.put(456, null); this.map.put(null, "789"); this.map.clear(); - assertThat(this.map).hasSize(0); + assertThat(this.map).isEmpty(); assertThat(this.map.containsKey(123)).isFalse(); assertThat(this.map.containsKey(456)).isFalse(); assertThat(this.map.containsKey(null)).isFalse(); diff --git a/spring-core/src/test/java/org/springframework/util/LinkedCaseInsensitiveMapTests.java b/spring-core/src/test/java/org/springframework/util/LinkedCaseInsensitiveMapTests.java index 0d80474d617..c7a64620731 100644 --- a/spring-core/src/test/java/org/springframework/util/LinkedCaseInsensitiveMapTests.java +++ b/spring-core/src/test/java/org/springframework/util/LinkedCaseInsensitiveMapTests.java @@ -159,7 +159,7 @@ class LinkedCaseInsensitiveMapTests { void removeFromKeySetViaIterator() { map.put("key", "value"); nextAndRemove(map.keySet().iterator()); - assertThat(map).hasSize(0); + assertThat(map).isEmpty(); map.computeIfAbsent("key", k -> "newvalue"); assertThat(map.get("key")).isEqualTo("newvalue"); } @@ -168,7 +168,7 @@ class LinkedCaseInsensitiveMapTests { void clearFromValues() { map.put("key", "value"); map.values().clear(); - assertThat(map).hasSize(0); + assertThat(map).isEmpty(); map.computeIfAbsent("key", k -> "newvalue"); assertThat(map.get("key")).isEqualTo("newvalue"); } @@ -177,7 +177,7 @@ class LinkedCaseInsensitiveMapTests { void removeFromValues() { map.put("key", "value"); map.values().remove("value"); - assertThat(map).hasSize(0); + assertThat(map).isEmpty(); map.computeIfAbsent("key", k -> "newvalue"); assertThat(map.get("key")).isEqualTo("newvalue"); } @@ -186,7 +186,7 @@ class LinkedCaseInsensitiveMapTests { void removeFromValuesViaIterator() { map.put("key", "value"); nextAndRemove(map.values().iterator()); - assertThat(map).hasSize(0); + assertThat(map).isEmpty(); map.computeIfAbsent("key", k -> "newvalue"); assertThat(map.get("key")).isEqualTo("newvalue"); } @@ -195,7 +195,7 @@ class LinkedCaseInsensitiveMapTests { void clearFromEntrySet() { map.put("key", "value"); map.entrySet().clear(); - assertThat(map).hasSize(0); + assertThat(map).isEmpty(); map.computeIfAbsent("key", k -> "newvalue"); assertThat(map.get("key")).isEqualTo("newvalue"); } @@ -204,7 +204,7 @@ class LinkedCaseInsensitiveMapTests { void removeFromEntrySet() { map.put("key", "value"); map.entrySet().remove(map.entrySet().iterator().next()); - assertThat(map).hasSize(0); + assertThat(map).isEmpty(); map.computeIfAbsent("key", k -> "newvalue"); assertThat(map.get("key")).isEqualTo("newvalue"); } @@ -213,7 +213,7 @@ class LinkedCaseInsensitiveMapTests { void removeFromEntrySetViaIterator() { map.put("key", "value"); nextAndRemove(map.entrySet().iterator()); - assertThat(map).hasSize(0); + assertThat(map).isEmpty(); map.computeIfAbsent("key", k -> "newvalue"); assertThat(map.get("key")).isEqualTo("newvalue"); } diff --git a/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java b/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java index 886af71d68c..84d61ecea36 100644 --- a/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java @@ -151,14 +151,14 @@ class ObjectUtilsTests { void toObjectArrayWithNull() { Object[] objects = ObjectUtils.toObjectArray(null); assertThat(objects).isNotNull(); - assertThat(objects).hasSize(0); + assertThat(objects).isEmpty(); } @Test void toObjectArrayWithEmptyPrimitiveArray() { Object[] objects = ObjectUtils.toObjectArray(new byte[] {}); assertThat(objects).isNotNull(); - assertThat(objects).hasSize(0); + assertThat(objects).isEmpty(); } @Test diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterUtilsTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterUtilsTests.java index c7edd322d6e..23c4e6e838c 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterUtilsTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterUtilsTests.java @@ -249,7 +249,7 @@ public class NamedParameterUtilsTests { String expectedSql = "select foo from bar where baz = b:{}z"; String sql = "select foo from bar where baz = b:{}z"; ParsedSql parsedSql = NamedParameterUtils.parseSqlStatement(sql); - assertThat(parsedSql.getParameterNames()).hasSize(0); + assertThat(parsedSql.getParameterNames()).isEmpty(); String finalSql = NamedParameterUtils.substituteNamedParameters(parsedSql, null); assertThat(finalSql).isEqualTo(expectedSql); @@ -257,7 +257,7 @@ public class NamedParameterUtilsTests { String sql2 = "select foo from bar where baz = 'b:{p1}z'"; ParsedSql parsedSql2 = NamedParameterUtils.parseSqlStatement(sql2); - assertThat(parsedSql2.getParameterNames()).hasSize(0); + assertThat(parsedSql2.getParameterNames()).isEmpty(); String finalSql2 = NamedParameterUtils.substituteNamedParameters(parsedSql2, null); assertThat(finalSql2).isEqualTo(expectedSql2); } diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/object/BatchSqlUpdateTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/object/BatchSqlUpdateTests.java index 495706ded66..cc3eb59253c 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/object/BatchSqlUpdateTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/object/BatchSqlUpdateTests.java @@ -81,7 +81,7 @@ public class BatchSqlUpdateTests { } else { assertThat(update.getQueueCount()).isEqualTo(2); - assertThat(update.getRowsAffected()).hasSize(0); + assertThat(update.getRowsAffected()).isEmpty(); } int[] actualRowsAffected = update.flush(); @@ -102,7 +102,7 @@ public class BatchSqlUpdateTests { assertThat(actualRowsAffected[1]).isEqualTo(rowsAffected[1]); update.reset(); - assertThat(update.getRowsAffected()).hasSize(0); + assertThat(update.getRowsAffected()).isEmpty(); verify(preparedStatement).setObject(1, ids[0], Types.INTEGER); verify(preparedStatement).setObject(1, ids[1], Types.INTEGER); diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLErrorCodesFactoryTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLErrorCodesFactoryTests.java index 37ba2d746da..7ec92cfdf95 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLErrorCodesFactoryTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLErrorCodesFactoryTests.java @@ -206,7 +206,7 @@ public class SQLErrorCodesFactoryTests { // Should have failed to load without error TestSQLErrorCodesFactory sf = new TestSQLErrorCodesFactory(); assertThat(sf.getErrorCodes("XX").getBadSqlGrammarCodes().length == 0).isTrue(); - assertThat(sf.getErrorCodes("Oracle").getBadSqlGrammarCodes()).hasSize(0); + assertThat(sf.getErrorCodes("Oracle").getBadSqlGrammarCodes()).isEmpty(); } /** @@ -371,8 +371,8 @@ public class SQLErrorCodesFactoryTests { } private void assertIsEmpty(SQLErrorCodes sec) { - assertThat(sec.getBadSqlGrammarCodes()).hasSize(0); - assertThat(sec.getDataIntegrityViolationCodes()).hasSize(0); + assertThat(sec.getBadSqlGrammarCodes()).isEmpty(); + assertThat(sec.getDataIntegrityViolationCodes()).isEmpty(); } } diff --git a/spring-jms/src/test/java/org/springframework/jms/annotation/EnableJmsTests.java b/spring-jms/src/test/java/org/springframework/jms/annotation/EnableJmsTests.java index 27820f03395..96a46c31b51 100644 --- a/spring-jms/src/test/java/org/springframework/jms/annotation/EnableJmsTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/annotation/EnableJmsTests.java @@ -193,7 +193,7 @@ class EnableJmsTests extends AbstractJmsAnnotationDrivenTests { EnableJmsDefaultContainerFactoryConfig.class, LazyBean.class); JmsListenerContainerTestFactory defaultFactory = context.getBean("jmsListenerContainerFactory", JmsListenerContainerTestFactory.class); - assertThat(defaultFactory.getListenerContainers()).hasSize(0); + assertThat(defaultFactory.getListenerContainers()).isEmpty(); context.getBean(LazyBean.class); // trigger lazy resolution assertThat(defaultFactory.getListenerContainers()).hasSize(1); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistryTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistryTests.java index 18025975e2f..1ffa96613ed 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistryTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistryTests.java @@ -53,17 +53,17 @@ public class DefaultSubscriptionRegistryTests { this.registry.registerSubscription(subscribeMessage(null, subsId, dest)); MultiValueMap actual = this.registry.findSubscriptions(createMessage(dest)); assertThat(actual).isNotNull(); - assertThat(actual).hasSize(0); + assertThat(actual).isEmpty(); this.registry.registerSubscription(subscribeMessage(sessId, null, dest)); actual = this.registry.findSubscriptions(createMessage(dest)); assertThat(actual).isNotNull(); - assertThat(actual).hasSize(0); + assertThat(actual).isEmpty(); this.registry.registerSubscription(subscribeMessage(sessId, subsId, null)); actual = this.registry.findSubscriptions(createMessage(dest)); assertThat(actual).isNotNull(); - assertThat(actual).hasSize(0); + assertThat(actual).isEmpty(); } @Test @@ -210,7 +210,7 @@ public class DefaultSubscriptionRegistryTests { actual = this.registry.findSubscriptions(destNasdaqIbmMessage); assertThat(actual).isNotNull(); - assertThat(actual).hasSize(0); + assertThat(actual).isEmpty(); } @Test // SPR-11755 @@ -296,7 +296,7 @@ public class DefaultSubscriptionRegistryTests { actual = this.registry.findSubscriptions(createMessage(destination)); assertThat(actual).isNotNull(); - assertThat(actual).hasSize(0); + assertThat(actual).isEmpty(); } @Test diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/BufferingStompDecoderTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/BufferingStompDecoderTests.java index 0a63ebb9eca..bea4cafd579 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/BufferingStompDecoderTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/BufferingStompDecoderTests.java @@ -99,7 +99,7 @@ public class BufferingStompDecoderTests { String chunk2 = "\nPayload2a"; messages = stompDecoder.decode(toByteBuffer(chunk2)); - assertThat(messages).hasSize(0); + assertThat(messages).isEmpty(); assertThat(stompDecoder.getBufferSize()).isEqualTo(33); assertThat((int) stompDecoder.getExpectedContentLength()).isEqualTo(contentLength); @@ -127,7 +127,7 @@ public class BufferingStompDecoderTests { String chunk2 = "\nPayload2a"; messages = stompDecoder.decode(toByteBuffer(chunk2)); - assertThat(messages).hasSize(0); + assertThat(messages).isEmpty(); assertThat(stompDecoder.getBufferSize()).isEqualTo(23); assertThat(stompDecoder.getExpectedContentLength()).isNull(); @@ -171,7 +171,7 @@ public class BufferingStompDecoderTests { String chunk = "MESSAG"; List> messages = stompDecoder.decode(toByteBuffer(chunk)); - assertThat(messages).hasSize(0); + assertThat(messages).isEmpty(); } // SPR-13416 @@ -182,7 +182,7 @@ public class BufferingStompDecoderTests { String chunk = "SEND\na:long\\"; List> messages = stompDecoder.decode(toByteBuffer(chunk)); - assertThat(messages).hasSize(0); + assertThat(messages).isEmpty(); } @Test diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompDecoderTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompDecoderTests.java index 2d10dd59148..4ae350c2292 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompDecoderTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompDecoderTests.java @@ -45,8 +45,8 @@ public class StompDecoderTests { StompHeaderAccessor headers = StompHeaderAccessor.wrap(frame); assertThat(headers.getCommand()).isEqualTo(StompCommand.DISCONNECT); - assertThat(headers.toNativeHeaderMap()).hasSize(0); - assertThat(frame.getPayload()).hasSize(0); + assertThat(headers.toNativeHeaderMap()).isEmpty(); + assertThat(frame.getPayload()).isEmpty(); } @Test @@ -55,8 +55,8 @@ public class StompDecoderTests { StompHeaderAccessor headers = StompHeaderAccessor.wrap(frame); assertThat(headers.getCommand()).isEqualTo(StompCommand.DISCONNECT); - assertThat(headers.toNativeHeaderMap()).hasSize(0); - assertThat(frame.getPayload()).hasSize(0); + assertThat(headers.toNativeHeaderMap()).isEmpty(); + assertThat(frame.getPayload()).isEmpty(); } @Test @@ -73,7 +73,7 @@ public class StompDecoderTests { assertThat(headers.getFirstNativeHeader("accept-version")).isEqualTo("1.1"); assertThat(headers.getHost()).isEqualTo("github.org"); - assertThat(frame.getPayload()).hasSize(0); + assertThat(frame.getPayload()).isEmpty(); } @Test @@ -173,7 +173,7 @@ public class StompDecoderTests { assertThat(headers.getFirstNativeHeader("accept-version")).isEqualTo("1.1"); assertThat(headers.getFirstNativeHeader("key")).isEqualTo("\\value"); - assertThat(frame.getPayload()).hasSize(0); + assertThat(frame.getPayload()).isEmpty(); } @Test @@ -220,7 +220,7 @@ public class StompDecoderTests { assertThat(headers.getFirstNativeHeader("accept-version")).isEqualTo("1.1"); assertThat(headers.getFirstNativeHeader("key")).isEqualTo(""); - assertThat(frame.getPayload()).hasSize(0); + assertThat(frame.getPayload()).isEmpty(); } @Test diff --git a/spring-messaging/src/test/java/org/springframework/messaging/support/ChannelInterceptorTests.java b/spring-messaging/src/test/java/org/springframework/messaging/support/ChannelInterceptorTests.java index 3f5e1b8394f..7c02fe64ad4 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/support/ChannelInterceptorTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/support/ChannelInterceptorTests.java @@ -79,7 +79,7 @@ public class ChannelInterceptorTests { assertThat(interceptor1.getCounter().get()).isEqualTo(1); assertThat(interceptor2.getCounter().get()).isEqualTo(1); - assertThat(this.messageHandler.getMessages()).hasSize(0); + assertThat(this.messageHandler.getMessages()).isEmpty(); assertThat(interceptor1.wasAfterCompletionInvoked()).isTrue(); assertThat(interceptor2.wasAfterCompletionInvoked()).isFalse(); } diff --git a/spring-messaging/src/test/java/org/springframework/messaging/support/MessageHeaderAccessorTests.java b/spring-messaging/src/test/java/org/springframework/messaging/support/MessageHeaderAccessorTests.java index 80bc4bf2fe8..94977c88cd4 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/support/MessageHeaderAccessorTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/support/MessageHeaderAccessorTests.java @@ -44,7 +44,7 @@ public class MessageHeaderAccessorTests { @Test public void newEmptyHeaders() { MessageHeaderAccessor accessor = new MessageHeaderAccessor(); - assertThat(accessor.toMap()).hasSize(0); + assertThat(accessor.toMap()).isEmpty(); } @Test diff --git a/spring-messaging/src/test/java/org/springframework/messaging/support/NativeMessageHeaderAccessorTests.java b/spring-messaging/src/test/java/org/springframework/messaging/support/NativeMessageHeaderAccessorTests.java index 1dd8aefd9f7..f7e25e71801 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/support/NativeMessageHeaderAccessorTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/support/NativeMessageHeaderAccessorTests.java @@ -79,7 +79,7 @@ public class NativeMessageHeaderAccessorTests { NativeMessageHeaderAccessor headerAccessor = new NativeMessageHeaderAccessor((Message) null); Map actual = headerAccessor.toMap(); - assertThat(actual).hasSize(0); + assertThat(actual).isEmpty(); Map> actualNativeHeaders = headerAccessor.toNativeHeaderMap(); assertThat(actualNativeHeaders).isEqualTo(Collections.emptyMap()); diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractContainerEntityManagerFactoryIntegrationTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractContainerEntityManagerFactoryIntegrationTests.java index 16bf248b9a1..654b26cc0dd 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractContainerEntityManagerFactoryIntegrationTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractContainerEntityManagerFactoryIntegrationTests.java @@ -186,7 +186,7 @@ public abstract class AbstractContainerEntityManagerFactoryIntegrationTests EntityManager em = entityManagerFactory.createEntityManager(); Query q = em.createQuery("select p from Person as p"); List people = q.getResultList(); - assertThat(people).hasSize(0); + assertThat(people).isEmpty(); assertThatExceptionOfType(NoResultException.class).isThrownBy(q::getSingleResult); } @@ -198,7 +198,7 @@ public abstract class AbstractContainerEntityManagerFactoryIntegrationTests EntityManager em = entityManagerFactory.createEntityManager(); Query q = em.createQuery("select p from Person as p"); List people = q.getResultList(); - assertThat(people).hasSize(0); + assertThat(people).isEmpty(); assertThatExceptionOfType(NoResultException.class).isThrownBy(q::getSingleResult); } @@ -208,7 +208,7 @@ public abstract class AbstractContainerEntityManagerFactoryIntegrationTests Query q = this.sharedEntityManager.createQuery("select p from Person as p"); q.setFlushMode(FlushModeType.AUTO); List people = q.getResultList(); - assertThat(people).hasSize(0); + assertThat(people).isEmpty(); assertThatExceptionOfType(NoResultException.class).isThrownBy(q::getSingleResult); } @@ -221,7 +221,7 @@ public abstract class AbstractContainerEntityManagerFactoryIntegrationTests Query q = em.createQuery("select p from Person as p"); q.setFlushMode(FlushModeType.AUTO); List people = q.getResultList(); - assertThat(people).hasSize(0); + assertThat(people).isEmpty(); assertThatException() .isThrownBy(q::getSingleResult) .withMessageContaining("closed"); diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/PersistenceXmlParsingTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/PersistenceXmlParsingTests.java index fb064f01e82..91f797d9396 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/PersistenceXmlParsingTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/PersistenceXmlParsingTests.java @@ -95,7 +95,7 @@ public class PersistenceXmlParsingTests { assertThat(info[0].getMappingFileNames()).hasSize(1); assertThat(info[0].getMappingFileNames().get(0)).isEqualTo("mappings.xml"); - assertThat(info[0].getProperties().keySet()).hasSize(0); + assertThat(info[0].getProperties().keySet()).isEmpty(); assertThat(info[0].excludeUnlistedClasses()).as("Exclude unlisted should default false in 1.0.").isFalse(); } @@ -115,7 +115,7 @@ public class PersistenceXmlParsingTests { assertThat(info[0].getJarFileUrls().get(0)).isEqualTo(new ClassPathResource("order.jar").getURL()); assertThat(info[0].getJarFileUrls().get(1)).isEqualTo(new ClassPathResource("order-supplemental.jar").getURL()); - assertThat(info[0].getProperties().keySet()).hasSize(0); + assertThat(info[0].getProperties().keySet()).isEmpty(); assertThat(info[0].getJtaDataSource()).isNull(); assertThat(info[0].getNonJtaDataSource()).isNull(); @@ -148,7 +148,7 @@ public class PersistenceXmlParsingTests { assertThat(info[0].excludeUnlistedClasses()).as("Exclude unlisted should be true when no value.").isTrue(); assertThat(info[0].getTransactionType()).isSameAs(PersistenceUnitTransactionType.RESOURCE_LOCAL); - assertThat(info[0].getProperties().keySet()).hasSize(0); + assertThat(info[0].getProperties().keySet()).isEmpty(); builder.clear(); } @@ -173,7 +173,7 @@ public class PersistenceXmlParsingTests { assertThat(info[0].getJarFileUrls().get(1)).isEqualTo(new ClassPathResource("order-supplemental.jar").getURL()); assertThat(info[0].getPersistenceProviderClassName()).isEqualTo("com.acme.AcmePersistence"); - assertThat(info[0].getProperties().keySet()).hasSize(0); + assertThat(info[0].getProperties().keySet()).isEmpty(); assertThat(info[0].excludeUnlistedClasses()).as("Exclude unlisted should default false in 1.0.").isFalse(); } @@ -249,7 +249,7 @@ public class PersistenceXmlParsingTests { PersistenceUnitInfo[] info = reader.readPersistenceUnitInfos(resource); assertThat(info).hasSize(1); assertThat(info[0].getPersistenceUnitName()).isEqualTo("pu"); - assertThat(info[0].getProperties().keySet()).hasSize(0); + assertThat(info[0].getProperties().keySet()).isEmpty(); assertThat(info[0].excludeUnlistedClasses()).as("Exclude unlisted should default false in 1.0.").isFalse(); } diff --git a/spring-test/src/test/java/org/springframework/mock/web/MockHttpServletRequestTests.java b/spring-test/src/test/java/org/springframework/mock/web/MockHttpServletRequestTests.java index 419c92844d9..098463694ab 100644 --- a/spring-test/src/test/java/org/springframework/mock/web/MockHttpServletRequestTests.java +++ b/spring-test/src/test/java/org/springframework/mock/web/MockHttpServletRequestTests.java @@ -273,7 +273,7 @@ class MockHttpServletRequestTests { request.addParameters(params); assertThat(request.getParameterMap()).hasSize(3); request.removeAllParameters(); - assertThat(request.getParameterMap()).hasSize(0); + assertThat(request.getParameterMap()).isEmpty(); } @Test diff --git a/spring-test/src/test/java/org/springframework/mock/web/MockServletContextTests.java b/spring-test/src/test/java/org/springframework/mock/web/MockServletContextTests.java index 1dd50081e13..9ebf8b5726d 100644 --- a/spring-test/src/test/java/org/springframework/mock/web/MockServletContextTests.java +++ b/spring-test/src/test/java/org/springframework/mock/web/MockServletContextTests.java @@ -180,7 +180,7 @@ class MockServletContextTests { void getServletRegistrations() { Map servletRegistrations = servletContext.getServletRegistrations(); assertThat(servletRegistrations).isNotNull(); - assertThat(servletRegistrations).hasSize(0); + assertThat(servletRegistrations).isEmpty(); } /** @@ -198,7 +198,7 @@ class MockServletContextTests { void getFilterRegistrations() { Map filterRegistrations = servletContext.getFilterRegistrations(); assertThat(filterRegistrations).isNotNull(); - assertThat(filterRegistrations).hasSize(0); + assertThat(filterRegistrations).isEmpty(); } } diff --git a/spring-test/src/test/java/org/springframework/test/context/TestContextConcurrencyTests.java b/spring-test/src/test/java/org/springframework/test/context/TestContextConcurrencyTests.java index d7fff78cf58..0f6fddbab7d 100644 --- a/spring-test/src/test/java/org/springframework/test/context/TestContextConcurrencyTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/TestContextConcurrencyTests.java @@ -77,7 +77,7 @@ class TestContextConcurrencyTests { }); assertThat(actualMethods).isEqualTo(expectedMethods); }); - assertThat(tcm.getTestContext().attributeNames()).hasSize(0); + assertThat(tcm.getTestContext().attributeNames()).isEmpty(); } diff --git a/spring-test/src/test/java/org/springframework/test/context/support/AnnotationConfigContextLoaderUtilsTests.java b/spring-test/src/test/java/org/springframework/test/context/support/AnnotationConfigContextLoaderUtilsTests.java index c567fe3c772..c895117b42c 100644 --- a/spring-test/src/test/java/org/springframework/test/context/support/AnnotationConfigContextLoaderUtilsTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/support/AnnotationConfigContextLoaderUtilsTests.java @@ -47,7 +47,7 @@ class AnnotationConfigContextLoaderUtilsTests { void detectDefaultConfigurationClassesWithoutConfigurationClass() { Class[] configClasses = detectDefaultConfigurationClasses(NoConfigTestCase.class); assertThat(configClasses).isNotNull(); - assertThat(configClasses).hasSize(0); + assertThat(configClasses).isEmpty(); } @Test diff --git a/spring-test/src/test/java/org/springframework/test/context/support/ContextLoaderUtilsContextHierarchyTests.java b/spring-test/src/test/java/org/springframework/test/context/support/ContextLoaderUtilsContextHierarchyTests.java index a67234c8f47..a5ff240f2a0 100644 --- a/spring-test/src/test/java/org/springframework/test/context/support/ContextLoaderUtilsContextHierarchyTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/support/ContextLoaderUtilsContextHierarchyTests.java @@ -340,8 +340,8 @@ class ContextLoaderUtilsContextHierarchyTests extends AbstractContextConfigurati assertThat(alphaConfig).hasSize(2); assertThat(alphaConfig.get(0).getLocations()).hasSize(1); assertThat(alphaConfig.get(0).getLocations()[0]).isEqualTo("1-A.xml"); - assertThat(alphaConfig.get(0).getInitializers()).hasSize(0); - assertThat(alphaConfig.get(1).getLocations()).hasSize(0); + assertThat(alphaConfig.get(0).getInitializers()).isEmpty(); + assertThat(alphaConfig.get(1).getLocations()).isEmpty(); assertThat(alphaConfig.get(1).getInitializers()).hasSize(1); assertThat(alphaConfig.get(1).getInitializers()[0]).isEqualTo(DummyApplicationContextInitializer.class); @@ -349,8 +349,8 @@ class ContextLoaderUtilsContextHierarchyTests extends AbstractContextConfigurati assertThat(betaConfig).hasSize(2); assertThat(betaConfig.get(0).getLocations()).hasSize(1); assertThat(betaConfig.get(0).getLocations()[0]).isEqualTo("1-B.xml"); - assertThat(betaConfig.get(0).getInitializers()).hasSize(0); - assertThat(betaConfig.get(1).getLocations()).hasSize(0); + assertThat(betaConfig.get(0).getInitializers()).isEmpty(); + assertThat(betaConfig.get(1).getLocations()).isEmpty(); assertThat(betaConfig.get(1).getInitializers()).hasSize(1); assertThat(betaConfig.get(1).getInitializers()[0]).isEqualTo(DummyApplicationContextInitializer.class); } diff --git a/spring-test/src/test/java/org/springframework/test/context/support/TestPropertySourceUtilsTests.java b/spring-test/src/test/java/org/springframework/test/context/support/TestPropertySourceUtilsTests.java index b24f537bab6..5f6fb354a12 100644 --- a/spring-test/src/test/java/org/springframework/test/context/support/TestPropertySourceUtilsTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/support/TestPropertySourceUtilsTests.java @@ -215,7 +215,7 @@ class TestPropertySourceUtilsTests { MutablePropertySources propertySources = environment.getPropertySources(); propertySources.remove(MockPropertySource.MOCK_PROPERTIES_PROPERTY_SOURCE_NAME); - assertThat(propertySources).hasSize(0); + assertThat(propertySources).isEmpty(); String pair = "key = value"; ByteArrayResource resource = new ByteArrayResource(pair.getBytes(), "from inlined property: " + pair); @@ -275,10 +275,10 @@ class TestPropertySourceUtilsTests { ConfigurableEnvironment environment = new MockEnvironment(); MutablePropertySources propertySources = environment.getPropertySources(); propertySources.remove(MockPropertySource.MOCK_PROPERTIES_PROPERTY_SOURCE_NAME); - assertThat(propertySources).hasSize(0); + assertThat(propertySources).isEmpty(); addInlinedPropertiesToEnvironment(environment, asArray(" ")); assertThat(propertySources).hasSize(1); - assertThat(((Map) propertySources.iterator().next().getSource())).hasSize(0); + assertThat(((Map) propertySources.iterator().next().getSource())).isEmpty(); } @Test diff --git a/spring-test/src/test/java/org/springframework/test/web/client/response/ResponseCreatorsTests.java b/spring-test/src/test/java/org/springframework/test/web/client/response/ResponseCreatorsTests.java index c7b3377496e..9b995c616c0 100644 --- a/spring-test/src/test/java/org/springframework/test/web/client/response/ResponseCreatorsTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/client/response/ResponseCreatorsTests.java @@ -46,7 +46,7 @@ class ResponseCreatorsTests { assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(response.getHeaders().isEmpty()).isTrue(); - assertThat(StreamUtils.copyToByteArray(response.getBody())).hasSize(0); + assertThat(StreamUtils.copyToByteArray(response.getBody())).isEmpty(); } @Test @@ -77,7 +77,7 @@ class ResponseCreatorsTests { assertThat(response.getStatusCode()).isEqualTo(HttpStatus.CREATED); assertThat(response.getHeaders().getLocation()).isEqualTo(location); - assertThat(StreamUtils.copyToByteArray(response.getBody())).hasSize(0); + assertThat(StreamUtils.copyToByteArray(response.getBody())).isEmpty(); } @Test @@ -86,7 +86,7 @@ class ResponseCreatorsTests { MockClientHttpResponse response = (MockClientHttpResponse) responseCreator.createResponse(null); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.ACCEPTED); - assertThat(StreamUtils.copyToByteArray(response.getBody())).hasSize(0); + assertThat(StreamUtils.copyToByteArray(response.getBody())).isEmpty(); } @Test @@ -96,7 +96,7 @@ class ResponseCreatorsTests { assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT); assertThat(response.getHeaders().isEmpty()).isTrue(); - assertThat(StreamUtils.copyToByteArray(response.getBody())).hasSize(0); + assertThat(StreamUtils.copyToByteArray(response.getBody())).isEmpty(); } @Test @@ -106,7 +106,7 @@ class ResponseCreatorsTests { assertThat(response.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST); assertThat(response.getHeaders().isEmpty()).isTrue(); - assertThat(StreamUtils.copyToByteArray(response.getBody())).hasSize(0); + assertThat(StreamUtils.copyToByteArray(response.getBody())).isEmpty(); } @Test @@ -116,7 +116,7 @@ class ResponseCreatorsTests { assertThat(response.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED); assertThat(response.getHeaders().isEmpty()).isTrue(); - assertThat(StreamUtils.copyToByteArray(response.getBody())).hasSize(0); + assertThat(StreamUtils.copyToByteArray(response.getBody())).isEmpty(); } @Test @@ -125,7 +125,7 @@ class ResponseCreatorsTests { MockClientHttpResponse response = (MockClientHttpResponse) responseCreator.createResponse(null); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.FORBIDDEN); - assertThat(StreamUtils.copyToByteArray(response.getBody())).hasSize(0); + assertThat(StreamUtils.copyToByteArray(response.getBody())).isEmpty(); } @Test @@ -134,7 +134,7 @@ class ResponseCreatorsTests { MockClientHttpResponse response = (MockClientHttpResponse) responseCreator.createResponse(null); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); - assertThat(StreamUtils.copyToByteArray(response.getBody())).hasSize(0); + assertThat(StreamUtils.copyToByteArray(response.getBody())).isEmpty(); } @Test @@ -143,7 +143,7 @@ class ResponseCreatorsTests { MockClientHttpResponse response = (MockClientHttpResponse) responseCreator.createResponse(null); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.CONFLICT); - assertThat(StreamUtils.copyToByteArray(response.getBody())).hasSize(0); + assertThat(StreamUtils.copyToByteArray(response.getBody())).isEmpty(); } @Test @@ -153,7 +153,7 @@ class ResponseCreatorsTests { assertThat(response.getStatusCode()).isEqualTo(HttpStatus.TOO_MANY_REQUESTS); assertThat(response.getHeaders()).doesNotContainKey(HttpHeaders.RETRY_AFTER); - assertThat(StreamUtils.copyToByteArray(response.getBody())).hasSize(0); + assertThat(StreamUtils.copyToByteArray(response.getBody())).isEmpty(); } @Test @@ -163,7 +163,7 @@ class ResponseCreatorsTests { assertThat(response.getStatusCode()).isEqualTo(HttpStatus.TOO_MANY_REQUESTS); assertThat(response.getHeaders().getFirst(HttpHeaders.RETRY_AFTER)).isEqualTo("512"); - assertThat(StreamUtils.copyToByteArray(response.getBody())).hasSize(0); + assertThat(StreamUtils.copyToByteArray(response.getBody())).isEmpty(); } @Test @@ -173,7 +173,7 @@ class ResponseCreatorsTests { assertThat(response.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR); assertThat(response.getHeaders().isEmpty()).isTrue(); - assertThat(StreamUtils.copyToByteArray(response.getBody())).hasSize(0); + assertThat(StreamUtils.copyToByteArray(response.getBody())).isEmpty(); } @Test @@ -182,7 +182,7 @@ class ResponseCreatorsTests { MockClientHttpResponse response = (MockClientHttpResponse) responseCreator.createResponse(null); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.BAD_GATEWAY); - assertThat(StreamUtils.copyToByteArray(response.getBody())).hasSize(0); + assertThat(StreamUtils.copyToByteArray(response.getBody())).isEmpty(); } @Test @@ -191,7 +191,7 @@ class ResponseCreatorsTests { MockClientHttpResponse response = (MockClientHttpResponse) responseCreator.createResponse(null); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.SERVICE_UNAVAILABLE); - assertThat(StreamUtils.copyToByteArray(response.getBody())).hasSize(0); + assertThat(StreamUtils.copyToByteArray(response.getBody())).isEmpty(); } @Test @@ -200,7 +200,7 @@ class ResponseCreatorsTests { MockClientHttpResponse response = (MockClientHttpResponse) responseCreator.createResponse(null); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.GATEWAY_TIMEOUT); - assertThat(StreamUtils.copyToByteArray(response.getBody())).hasSize(0); + assertThat(StreamUtils.copyToByteArray(response.getBody())).isEmpty(); } @Test @@ -210,7 +210,7 @@ class ResponseCreatorsTests { assertThat(response.getStatusCode()).isEqualTo(HttpStatus.FORBIDDEN); assertThat(response.getHeaders().isEmpty()).isTrue(); - assertThat(StreamUtils.copyToByteArray(response.getBody())).hasSize(0); + assertThat(StreamUtils.copyToByteArray(response.getBody())).isEmpty(); } @Test diff --git a/spring-web/src/test/java/org/springframework/http/HttpHeadersTests.java b/spring-web/src/test/java/org/springframework/http/HttpHeadersTests.java index b699f5772ae..0f6b044c310 100644 --- a/spring-web/src/test/java/org/springframework/http/HttpHeadersTests.java +++ b/spring-web/src/test/java/org/springframework/http/HttpHeadersTests.java @@ -619,9 +619,9 @@ public class HttpHeadersTests { // clear() keySet.clear(); assertThat(keySet.isEmpty()).isTrue(); - assertThat(keySet).hasSize(0); + assertThat(keySet).isEmpty(); assertThat(headers.isEmpty()).isTrue(); - assertThat(headers).hasSize(0); + assertThat(headers).isEmpty(); // Unsupported operations assertThatExceptionOfType(UnsupportedOperationException.class) diff --git a/spring-web/src/test/java/org/springframework/http/server/ServletServerHttpRequestTests.java b/spring-web/src/test/java/org/springframework/http/server/ServletServerHttpRequestTests.java index 6b24f916134..4132e706758 100644 --- a/spring-web/src/test/java/org/springframework/http/server/ServletServerHttpRequestTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/ServletServerHttpRequestTests.java @@ -155,7 +155,7 @@ public class ServletServerHttpRequestTests { void getHeadersWithWildcardContentType() { mockRequest.setContentType("*/*"); mockRequest.removeHeader("Content-Type"); - assertThat(request.getHeaders()).as("Invalid content-type should not raise exception").hasSize(0); + assertThat(request.getHeaders()).as("Invalid content-type should not raise exception").isEmpty(); } @Test diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/ChannelSendOperatorTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/ChannelSendOperatorTests.java index dd39d77cf07..b3a94b79a18 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/ChannelSendOperatorTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/ChannelSendOperatorTests.java @@ -66,7 +66,7 @@ class ChannelSendOperatorTests { assertThat(signal).isNotNull(); assertThat(signal.isOnComplete()).as("Unexpected signal: " + signal).isTrue(); - assertThat(this.writer.items).hasSize(0); + assertThat(this.writer.items).isEmpty(); assertThat(this.writer.completed).isTrue(); } diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/HeadersAdaptersTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/HeadersAdaptersTests.java index bfd67748e38..8fdfc3c5efc 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/HeadersAdaptersTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/HeadersAdaptersTests.java @@ -110,7 +110,7 @@ class HeadersAdaptersTests { headers.add("TestHeader", "first"); assertThat(headers.keySet()).hasSize(1); headers.keySet().removeIf("TestHeader"::equals); - assertThat(headers.keySet()).hasSize(0); + assertThat(headers.keySet()).isEmpty(); } @ParameterizedHeadersTest diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpRequestTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpRequestTests.java index 2d77d3c2137..14561a1e0ac 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpRequestTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpRequestTests.java @@ -53,7 +53,7 @@ public class ServerHttpRequestTests { @Test public void queryParamsNone() throws Exception { MultiValueMap params = createRequest("/path").getQueryParams(); - assertThat(params).hasSize(0); + assertThat(params).isEmpty(); } @Test diff --git a/spring-web/src/test/java/org/springframework/web/util/WebUtilsTests.java b/spring-web/src/test/java/org/springframework/web/util/WebUtilsTests.java index d64fc24243e..e9d95d582c0 100644 --- a/spring-web/src/test/java/org/springframework/web/util/WebUtilsTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/WebUtilsTests.java @@ -63,7 +63,7 @@ public class WebUtilsTests { MultiValueMap variables; variables = WebUtils.parseMatrixVariables(null); - assertThat(variables).hasSize(0); + assertThat(variables).isEmpty(); variables = WebUtils.parseMatrixVariables("year"); assertThat(variables).hasSize(1); diff --git a/spring-web/src/test/java/org/springframework/web/util/pattern/PathPatternTests.java b/spring-web/src/test/java/org/springframework/web/util/pattern/PathPatternTests.java index 10d46806883..c8c16b73ca7 100644 --- a/spring-web/src/test/java/org/springframework/web/util/pattern/PathPatternTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/pattern/PathPatternTests.java @@ -577,7 +577,7 @@ public class PathPatternTests { pri = getPathRemaining(pp, "/aaa/bbb"); assertThat(pri.getPathRemaining().value()).isEqualTo(""); assertThat(pri.getPathMatched().value()).isEqualTo("/aaa/bbb"); - assertThat(pri.getUriVariables()).hasSize(0); + assertThat(pri.getUriVariables()).isEmpty(); pp = parse("/*/{foo}/b*"); pri = getPathRemaining(pp, "/foo"); @@ -807,7 +807,7 @@ public class PathPatternTests { assertThat((Object) checkCapture("/{one}/", "//")).isNull(); assertThat((Object) checkCapture("", "/abc")).isNull(); - assertThat(checkCapture("", "").getUriVariables()).hasSize(0); + assertThat(checkCapture("", "").getUriVariables()).isEmpty(); checkCapture("{id}", "99", "id", "99"); checkCapture("/customer/{customerId}", "/customer/78", "customerId", "78"); checkCapture("/customer/{customerId}/banana", "/customer/42/banana", "customerId", @@ -817,7 +817,7 @@ public class PathPatternTests { "apple"); checkCapture("/{bla}.*", "/testing.html", "bla", "testing"); PathPattern.PathMatchInfo extracted = checkCapture("/abc", "/abc"); - assertThat(extracted.getUriVariables()).hasSize(0); + assertThat(extracted.getUriVariables()).isEmpty(); checkCapture("/{bla}/foo","/a/foo"); } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/config/ResourceHandlerRegistryTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/config/ResourceHandlerRegistryTests.java index 5871af621c2..a88884c0983 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/config/ResourceHandlerRegistryTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/config/ResourceHandlerRegistryTests.java @@ -161,7 +161,7 @@ class ResourceHandlerRegistryTests { assertThat(resolvers.get(1)).isInstanceOf(PathResourceResolver.class); List transformers = handler.getResourceTransformers(); - assertThat(transformers).hasSize(0); + assertThat(transformers).isEmpty(); } @Test diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/config/ViewResolverRegistryTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/config/ViewResolverRegistryTests.java index 17795b8ce06..1eb91e75f70 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/config/ViewResolverRegistryTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/config/ViewResolverRegistryTests.java @@ -71,7 +71,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(); } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMappingInfoTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMappingInfoTests.java index 1f0f05308fc..b0fbbe4d5d8 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMappingInfoTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMappingInfoTests.java @@ -56,7 +56,7 @@ public class RequestMappingInfoTests { PathPattern emptyPattern = (new PathPatternParser()).parse(""); assertThat(info.getPatternsCondition().getPatterns()).isEqualTo(Collections.singleton(emptyPattern)); - assertThat(info.getMethodsCondition().getMethods()).hasSize(0); + assertThat(info.getMethodsCondition().getMethods()).isEmpty(); assertThat(info.getConsumesCondition().isEmpty()).isTrue(); assertThat(info.getProducesCondition().isEmpty()).isTrue(); assertThat(info.getParamsCondition()).isNotNull(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelInitializerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelInitializerTests.java index 822bb37d55c..c9af818e604 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelInitializerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelInitializerTests.java @@ -141,7 +141,7 @@ public class ModelInitializerTests { WebSession session = this.exchange.getSession().block(Duration.ZERO); assertThat(session).isNotNull(); - assertThat(session.getAttributes()).hasSize(0); + assertThat(session.getAttributes()).isEmpty(); context.saveModel(); assertThat(session.getAttributes()).hasSize(1); @@ -198,7 +198,7 @@ public class ModelInitializerTests { context.getSessionStatus().setComplete(); context.saveModel(); - assertThat(session.getAttributes()).hasSize(0); + assertThat(session.getAttributes()).isEmpty(); } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandlerTests.java index 702ff2ce699..767d3a09171 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandlerTests.java @@ -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()).hasSize(0); + assertThat(exchange.getResponse().getHeaders()).isEmpty(); assertResponseBodyIsEmpty(exchange); } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/DefaultRenderingBuilderTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/DefaultRenderingBuilderTests.java index d507c559507..1a5288216cf 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/DefaultRenderingBuilderTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/DefaultRenderingBuilderTests.java @@ -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()).hasSize(0); + assertThat(rendering.headers()).isEmpty(); } @Test diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfigurationTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfigurationTests.java index 28f046b14cb..5ac3850750a 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfigurationTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfigurationTests.java @@ -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(); } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ViewResolverRegistryTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ViewResolverRegistryTests.java index 6efb0da4270..a43199a096e 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ViewResolverRegistryTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ViewResolverRegistryTests.java @@ -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(); } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupportTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupportTests.java index a83ff4e4182..c8c7efd52cf 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupportTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupportTests.java @@ -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(); } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/function/ResourceHandlerFunctionTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/function/ResourceHandlerFunctionTests.java index 71c44d84896..93835fb29b6 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/function/ResourceHandlerFunctionTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/function/ResourceHandlerFunctionTests.java @@ -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(); } } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/HandlerMethodMappingTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/HandlerMethodMappingTests.java index 60154336441..b45fa0f7328 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/HandlerMethodMappingTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/HandlerMethodMappingTests.java @@ -165,7 +165,7 @@ public class HandlerMethodMappingTests { mapping1.setApplicationContext(new StaticApplicationContext(cxt)); mapping1.afterPropertiesSet(); - assertThat(mapping1.getHandlerMethods()).hasSize(0); + assertThat(mapping1.getHandlerMethods()).isEmpty(); AbstractHandlerMethodMapping mapping2 = new MyHandlerMethodMapping(); mapping2.setDetectHandlerMethodsInAncestorContexts(true); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoTests.java index 2e3a50e0370..87843e1efb0 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoTests.java @@ -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(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/HttpEntityMethodProcessorMockTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/HttpEntityMethodProcessorMockTests.java index 834e8491c64..455bd0c894a 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/HttpEntityMethodProcessorMockTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/HttpEntityMethodProcessorMockTests.java @@ -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); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/support/AnnotationConfigDispatcherServletInitializerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/support/AnnotationConfigDispatcherServletInitializerTests.java index 3ba093508e9..67a106595d4 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/support/AnnotationConfigDispatcherServletInitializerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/support/AnnotationConfigDispatcherServletInitializerTests.java @@ -179,7 +179,7 @@ public class AnnotationConfigDispatcherServletInitializerTests { initializer.onStartup(servletContext); - assertThat(filterRegistrations).hasSize(0); + assertThat(filterRegistrations).isEmpty(); } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/UrlTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/UrlTagTests.java index 031be3ea321..761a49c97f0 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/UrlTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/UrlTagTests.java @@ -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 diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/BaseViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/BaseViewTests.java index 13bcaff034d..910a7016300 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/BaseViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/BaseViewTests.java @@ -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(); } /** diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebMvcStompEndpointRegistryTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebMvcStompEndpointRegistryTests.java index 593fd21d874..aeab3506bcc 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebMvcStompEndpointRegistryTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebMvcStompEndpointRegistryTests.java @@ -72,7 +72,7 @@ public class WebMvcStompEndpointRegistryTests { @Test public void handlerMapping() { SimpleUrlHandlerMapping hm = (SimpleUrlHandlerMapping) this.endpointRegistry.getHandlerMapping(); - assertThat(hm.getUrlMap()).hasSize(0); + assertThat(hm.getUrlMap()).isEmpty(); UrlPathHelper pathHelper = new UrlPathHelper(); this.endpointRegistry.setUrlPathHelper(pathHelper); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompSubProtocolHandlerTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompSubProtocolHandlerTests.java index 27af3b014f5..40edce46f02 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompSubProtocolHandlerTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompSubProtocolHandlerTests.java @@ -332,7 +332,7 @@ public class StompSubProtocolHandlerTests { assertThat(stompAccessor.getPasscode()).isEqualTo("guest"); assertThat(stompAccessor.getHeartbeat()).isEqualTo(new long[] {10000, 10000}); assertThat(stompAccessor.getAcceptVersion()).isEqualTo(new HashSet<>(Arrays.asList("1.1","1.0"))); - assertThat(this.session.getSentMessages()).hasSize(0); + assertThat(this.session.getSentMessages()).isEmpty(); } @Test