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 b774d336c72..43a9544168b 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 @@ -134,7 +134,7 @@ public class BeanFactoryUtilsTests { StaticListableBeanFactory lbf = new StaticListableBeanFactory(); lbf.addBean("foo", new Object()); Map beans = BeanFactoryUtils.beansOfTypeIncludingAncestors(lbf, ITestBean.class, true, false); - assertThat(beans.isEmpty()).isTrue(); + assertThat(beans).isEmpty(); } @Test diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java index 4c9d919f1cd..e98a21a8c71 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java @@ -1143,7 +1143,7 @@ public class AutowiredAnnotationBeanPostProcessorTests { SingleConstructorVarargBean bean = bf.getBean("annotatedBean", SingleConstructorVarargBean.class); assertThat(bean.getTestBean()).isSameAs(tb); assertThat(bean.getNestedTestBeans()).isNotNull(); - assertThat(bean.getNestedTestBeans().isEmpty()).isTrue(); + assertThat(bean.getNestedTestBeans()).isEmpty(); } @Test @@ -1172,7 +1172,7 @@ public class AutowiredAnnotationBeanPostProcessorTests { SingleConstructorRequiredCollectionBean bean = bf.getBean("annotatedBean", SingleConstructorRequiredCollectionBean.class); assertThat(bean.getTestBean()).isSameAs(tb); assertThat(bean.getNestedTestBeans()).isNotNull(); - assertThat(bean.getNestedTestBeans().isEmpty()).isTrue(); + assertThat(bean.getNestedTestBeans()).isEmpty(); } @Test @@ -1666,13 +1666,13 @@ public class AutowiredAnnotationBeanPostProcessorTests { assertThat(bean.consumeUniqueTestBean()).isNull(); List testBeans = bean.iterateTestBeans(); - assertThat(testBeans.isEmpty()).isTrue(); + assertThat(testBeans).isEmpty(); testBeans = bean.forEachTestBeans(); - assertThat(testBeans.isEmpty()).isTrue(); + assertThat(testBeans).isEmpty(); testBeans = bean.streamTestBeans(); - assertThat(testBeans.isEmpty()).isTrue(); + assertThat(testBeans).isEmpty(); testBeans = bean.sortedTestBeans(); - assertThat(testBeans.isEmpty()).isTrue(); + assertThat(testBeans).isEmpty(); } @Test diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests.java index 942f333ffbd..b8c6c0c1a92 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests.java @@ -89,8 +89,8 @@ public class PropertyPathFactoryBeanTests { TestBean spouse = (TestBean) xbf.getBean("otb.spouse"); TestBean tbWithInner = (TestBean) xbf.getBean("tbWithInner"); assertThat(tbWithInner.getSpouse()).isSameAs(spouse); - assertThat(tbWithInner.getFriends().isEmpty()).isFalse(); - assertThat(tbWithInner.getFriends()).element(0).isSameAs(spouse); + assertThat(tbWithInner.getFriends()).isNotEmpty(); + assertThat(tbWithInner.getFriends().iterator().next()).isSameAs(spouse); } @Test diff --git a/spring-context/src/test/java/org/springframework/beans/factory/xml/QualifierAnnotationTests.java b/spring-context/src/test/java/org/springframework/beans/factory/xml/QualifierAnnotationTests.java index 49236e0422a..cce2ced3c62 100644 --- a/spring-context/src/test/java/org/springframework/beans/factory/xml/QualifierAnnotationTests.java +++ b/spring-context/src/test/java/org/springframework/beans/factory/xml/QualifierAnnotationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2023 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. @@ -110,7 +110,8 @@ public class QualifierAnnotationTests { QualifiedByBeanNameTestBean testBean = (QualifiedByBeanNameTestBean) context.getBean("testBean"); Person person = testBean.getLarry(); assertThat(person.getName()).isEqualTo("LarryBean"); - assertThat(testBean.myProps != null && testBean.myProps.isEmpty()).isTrue(); + assertThat(testBean.myProps).isNotNull(); + assertThat(testBean.myProps).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 ed39f0a2e0b..54bb585e75a 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 @@ -1059,7 +1059,7 @@ class ConfigurationClassPostProcessorTests { ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(CollectionArgumentConfiguration.class); CollectionArgumentConfiguration bean = ctx.getBean(CollectionArgumentConfiguration.class); assertThat(bean.testBeans).isNotNull(); - assertThat(bean.testBeans.isEmpty()).isTrue(); + assertThat(bean.testBeans).isEmpty(); ctx.close(); } @@ -1078,7 +1078,7 @@ class ConfigurationClassPostProcessorTests { ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(MapArgumentConfiguration.class); MapArgumentConfiguration bean = ctx.getBean(MapArgumentConfiguration.class); assertThat(bean.testBeans).isNotNull(); - assertThat(bean.testBeans.isEmpty()).isTrue(); + assertThat(bean.testBeans).isEmpty(); ctx.close(); } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/LazyAutowiredAnnotationBeanPostProcessorTests.java b/spring-context/src/test/java/org/springframework/context/annotation/LazyAutowiredAnnotationBeanPostProcessorTests.java index 536f0c446eb..0eecab38364 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/LazyAutowiredAnnotationBeanPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/LazyAutowiredAnnotationBeanPostProcessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -81,7 +81,7 @@ class LazyAutowiredAnnotationBeanPostProcessorTests { FieldResourceInjectionBean bean = ac.getBean("annotatedBean", FieldResourceInjectionBean.class); assertThat(ac.getBeanFactory().containsSingleton("testBean")).isFalse(); - assertThat(bean.getTestBeans().isEmpty()).isFalse(); + assertThat(bean.getTestBeans()).isNotEmpty(); assertThat(bean.getTestBeans().get(0).getName()).isNull(); assertThat(ac.getBeanFactory().containsSingleton("testBean")).isTrue(); TestBean tb = (TestBean) ac.getBean("testBean"); @@ -156,7 +156,7 @@ class LazyAutowiredAnnotationBeanPostProcessorTests { OptionalFieldResourceInjectionBean bean = (OptionalFieldResourceInjectionBean) bf.getBean("annotatedBean"); assertThat(bean.getTestBean()).isNotNull(); assertThat(bean.getTestBeans()).isNotNull(); - assertThat(bean.getTestBeans().isEmpty()).isTrue(); + assertThat(bean.getTestBeans()).isEmpty(); assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() -> bean.getTestBean().getName()); } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/AutowiredConfigurationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/AutowiredConfigurationTests.java index 60451babbc6..781aadb9e0c 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/AutowiredConfigurationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/AutowiredConfigurationTests.java @@ -91,7 +91,7 @@ class AutowiredConfigurationTests { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( OptionalAutowiredMethodConfig.class); - assertThat(context.getBeansOfType(Colour.class).isEmpty()).isTrue(); + assertThat(context.getBeansOfType(Colour.class)).isEmpty(); assertThat(context.getBean(TestBean.class).getName()).isEmpty(); context.close(); } diff --git a/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java b/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java index 24bd440d092..1d19dba6061 100644 --- a/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java @@ -644,7 +644,7 @@ class AnnotationDrivenEventListenerTests { load(OrderedTestListener.class); OrderedTestListener listener = this.context.getBean(OrderedTestListener.class); - assertThat(listener.order.isEmpty()).isTrue(); + assertThat(listener.order).isEmpty(); this.context.publishEvent("whatever"); assertThat(listener.order).contains("first", "second", "third"); } diff --git a/spring-context/src/test/java/org/springframework/context/support/ConversionServiceFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/context/support/ConversionServiceFactoryBeanTests.java index edd23bff441..434873ca388 100644 --- a/spring-context/src/test/java/org/springframework/context/support/ConversionServiceFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/ConversionServiceFactoryBeanTests.java @@ -141,9 +141,9 @@ class ConversionServiceFactoryBeanTests { static class ComplexConstructorArgument { ComplexConstructorArgument(Map> map) { - assertThat(map.isEmpty()).isFalse(); - assertThat(map.keySet()).element(0).isInstanceOf(String.class); - assertThat(map.values()).element(0).isInstanceOf(Class.class); + assertThat(map).isNotEmpty(); + assertThat(map.keySet().iterator().next()).isInstanceOf(String.class); + assertThat(map.values().iterator().next()).isInstanceOf(Class.class); } } diff --git a/spring-context/src/test/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessorTests.java b/spring-context/src/test/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessorTests.java index 90dececdcea..07ee096636a 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessorTests.java @@ -542,7 +542,7 @@ class ScheduledAnnotationBeanPostProcessorTests { context.refresh(); ScheduledTaskHolder postProcessor = context.getBean("postProcessor", ScheduledTaskHolder.class); - assertThat(postProcessor.getScheduledTasks().isEmpty()).isTrue(); + assertThat(postProcessor.getScheduledTasks()).isEmpty(); } @ParameterizedTest diff --git a/spring-context/src/test/java/org/springframework/validation/DataBinderTests.java b/spring-context/src/test/java/org/springframework/validation/DataBinderTests.java index 89b7fb6f2af..0fcf18cebd9 100644 --- a/spring-context/src/test/java/org/springframework/validation/DataBinderTests.java +++ b/spring-context/src/test/java/org/springframework/validation/DataBinderTests.java @@ -502,7 +502,7 @@ class DataBinderTests { LocaleContextHolder.setLocale(Locale.GERMAN); try { binder.bind(pvs); - assertThat(tb.getIntegerList().isEmpty()).isTrue(); + assertThat(tb.getIntegerList()).isEmpty(); assertThat(binder.getBindingResult().getFieldValue("integerList[0]")).isEqualTo("1x2"); assertThat(binder.getBindingResult().hasFieldErrors("integerList[0]")).isTrue(); } diff --git a/spring-core-test/src/test/java/org/springframework/core/test/tools/ClassFilesTests.java b/spring-core-test/src/test/java/org/springframework/core/test/tools/ClassFilesTests.java index c43522bf066..d28a1a335ee 100644 --- a/spring-core-test/src/test/java/org/springframework/core/test/tools/ClassFilesTests.java +++ b/spring-core-test/src/test/java/org/springframework/core/test/tools/ClassFilesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -40,7 +40,7 @@ class ClassFilesTests { void noneReturnsNone() { ClassFiles none = ClassFiles.none(); assertThat(none).isNotNull(); - assertThat(none.isEmpty()).isTrue(); + assertThat(none).isEmpty(); } @Test @@ -83,13 +83,13 @@ class ClassFilesTests { @Test void isEmptyWhenEmptyReturnsTrue() { ClassFiles classFiles = ClassFiles.of(); - assertThat(classFiles.isEmpty()).isTrue(); + assertThat(classFiles).isEmpty(); } @Test void isEmptyWhenNotEmptyReturnsFalse() { ClassFiles classFiles = ClassFiles.of(CLASS_FILE_1); - assertThat(classFiles.isEmpty()).isFalse(); + assertThat(classFiles).isNotEmpty(); } @Test diff --git a/spring-core-test/src/test/java/org/springframework/core/test/tools/ResourceFilesTests.java b/spring-core-test/src/test/java/org/springframework/core/test/tools/ResourceFilesTests.java index 7d98747b602..0b599a6f2e3 100644 --- a/spring-core-test/src/test/java/org/springframework/core/test/tools/ResourceFilesTests.java +++ b/spring-core-test/src/test/java/org/springframework/core/test/tools/ResourceFilesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -41,7 +41,7 @@ class ResourceFilesTests { void noneReturnsNone() { ResourceFiles none = ResourceFiles.none(); assertThat(none).isNotNull(); - assertThat(none.isEmpty()).isTrue(); + assertThat(none).isEmpty(); } @Test @@ -85,13 +85,13 @@ class ResourceFilesTests { @Test void isEmptyWhenEmptyReturnsTrue() { ResourceFiles resourceFiles = ResourceFiles.of(); - assertThat(resourceFiles.isEmpty()).isTrue(); + assertThat(resourceFiles).isEmpty(); } @Test void isEmptyWhenNotEmptyReturnsFalse() { ResourceFiles resourceFiles = ResourceFiles.of(RESOURCE_FILE_1); - assertThat(resourceFiles.isEmpty()).isFalse(); + assertThat(resourceFiles).isNotEmpty(); } @Test diff --git a/spring-core-test/src/test/java/org/springframework/core/test/tools/SourceFilesTests.java b/spring-core-test/src/test/java/org/springframework/core/test/tools/SourceFilesTests.java index dce77f845c2..7e646098630 100644 --- a/spring-core-test/src/test/java/org/springframework/core/test/tools/SourceFilesTests.java +++ b/spring-core-test/src/test/java/org/springframework/core/test/tools/SourceFilesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -41,7 +41,7 @@ class SourceFilesTests { void noneReturnsNone() { SourceFiles none = SourceFiles.none(); assertThat(none).isNotNull(); - assertThat(none.isEmpty()).isTrue(); + assertThat(none).isEmpty(); } @Test @@ -84,13 +84,13 @@ class SourceFilesTests { @Test void isEmptyWhenEmptyReturnsTrue() { SourceFiles sourceFiles = SourceFiles.of(); - assertThat(sourceFiles.isEmpty()).isTrue(); + assertThat(sourceFiles).isEmpty(); } @Test void isEmptyWhenNotEmptyReturnsFalse() { SourceFiles sourceFiles = SourceFiles.of(SOURCE_FILE_1); - assertThat(sourceFiles.isEmpty()).isFalse(); + assertThat(sourceFiles).isNotEmpty(); } @Test diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java index 6c298003295..56e052b4168 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java @@ -171,8 +171,8 @@ class AnnotatedElementUtilsTests { @Test void getMetaAnnotationTypesOnNonAnnotatedClass() { - assertThat(getMetaAnnotationTypes(NonAnnotatedClass.class, TransactionalComponent.class).isEmpty()).isTrue(); - assertThat(getMetaAnnotationTypes(NonAnnotatedClass.class, TransactionalComponent.class.getName()).isEmpty()).isTrue(); + assertThat(getMetaAnnotationTypes(NonAnnotatedClass.class, TransactionalComponent.class)).isEmpty(); + assertThat(getMetaAnnotationTypes(NonAnnotatedClass.class, TransactionalComponent.class.getName())).isEmpty(); } @Test @@ -869,7 +869,7 @@ class AnnotatedElementUtilsTests { void getAllMergedAnnotationsOnClassWithInterface() throws Exception { Method method = TransactionalServiceImpl.class.getMethod("doIt"); Set allMergedAnnotations = getAllMergedAnnotations(method, Transactional.class); - assertThat(allMergedAnnotations.isEmpty()).isTrue(); + assertThat(allMergedAnnotations).isEmpty(); } @Test diff --git a/spring-core/src/test/java/org/springframework/core/convert/support/CollectionToCollectionConverterTests.java b/spring-core/src/test/java/org/springframework/core/convert/support/CollectionToCollectionConverterTests.java index 8973ead9867..8fcbcc7bf23 100644 --- a/spring-core/src/test/java/org/springframework/core/convert/support/CollectionToCollectionConverterTests.java +++ b/spring-core/src/test/java/org/springframework/core/convert/support/CollectionToCollectionConverterTests.java @@ -96,7 +96,7 @@ class CollectionToCollectionConverterTests { @SuppressWarnings("unchecked") ArrayList result = (ArrayList) conversionService.convert(list, sourceType, targetType); assertThat(result.getClass()).isEqualTo(ArrayList.class); - assertThat(result.isEmpty()).isTrue(); + assertThat(result).isEmpty(); } @Test 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 9e839109183..971f4b105e3 100644 --- a/spring-core/src/test/java/org/springframework/util/AntPathMatcherTests.java +++ b/spring-core/src/test/java/org/springframework/util/AntPathMatcherTests.java @@ -628,7 +628,7 @@ class AntPathMatcherTests { pathMatcher.match("test" + i, "test"); } // Cache turned off because it went beyond the threshold - assertThat(pathMatcher.stringMatcherCache.isEmpty()).isTrue(); + assertThat(pathMatcher.stringMatcherCache).isEmpty(); } @Test @@ -680,7 +680,7 @@ class AntPathMatcherTests { void cachePatternsSetToFalse() { pathMatcher.setCachePatterns(false); match(); - assertThat(pathMatcher.stringMatcherCache.isEmpty()).isTrue(); + assertThat(pathMatcher.stringMatcherCache).isEmpty(); } @Test diff --git a/spring-core/src/test/java/org/springframework/util/CollectionUtilsTests.java b/spring-core/src/test/java/org/springframework/util/CollectionUtilsTests.java index 4af5fb9b236..8d2cb0972b0 100644 --- a/spring-core/src/test/java/org/springframework/util/CollectionUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/CollectionUtilsTests.java @@ -217,7 +217,7 @@ class CollectionUtilsTests { @Test void conversionOfEmptyMap() { MultiValueMap asMultiValueMap = CollectionUtils.toMultiValueMap(new HashMap<>()); - assertThat(asMultiValueMap.isEmpty()).isTrue(); + assertThat(asMultiValueMap).isEmpty(); assertThat(asMultiValueMap).isEmpty(); } 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 61b5604e0cf..95a148ae981 100644 --- a/spring-core/src/test/java/org/springframework/util/ConcurrentReferenceHashMapTests.java +++ b/spring-core/src/test/java/org/springframework/util/ConcurrentReferenceHashMapTests.java @@ -272,7 +272,7 @@ class ConcurrentReferenceHashMapTests { assertThat(this.map.get(123)).isEqualTo("123"); assertThat(this.map.remove(123, "123")).isTrue(); assertThat(this.map.containsKey(123)).isFalse(); - assertThat(this.map.isEmpty()).isTrue(); + assertThat(this.map).isEmpty(); } @Test @@ -282,7 +282,7 @@ class ConcurrentReferenceHashMapTests { assertThat(this.map.get(123)).isNull(); assertThat(this.map.remove(123, null)).isTrue(); assertThat(this.map.containsKey(123)).isFalse(); - assertThat(this.map.isEmpty()).isTrue(); + assertThat(this.map).isEmpty(); } @Test @@ -328,11 +328,11 @@ class ConcurrentReferenceHashMapTests { @Test void shouldSupportIsEmpty() { - assertThat(this.map.isEmpty()).isTrue(); + assertThat(this.map).isEmpty(); this.map.put(123, "123"); this.map.put(123, null); this.map.put(456, "456"); - assertThat(this.map.isEmpty()).isFalse(); + assertThat(this.map).isNotEmpty(); } @Test @@ -363,14 +363,14 @@ class ConcurrentReferenceHashMapTests { assertThat(this.map.remove(123)).isNull(); assertThat(this.map.remove(456)).isEqualTo("456"); assertThat(this.map.remove(null)).isEqualTo("789"); - assertThat(this.map.isEmpty()).isTrue(); + assertThat(this.map).isEmpty(); } @Test void shouldRemoveWhenKeyIsNotInMap() { assertThat(this.map.remove(123)).isNull(); assertThat(this.map.remove(null)).isNull(); - assertThat(this.map.isEmpty()).isTrue(); + assertThat(this.map).isEmpty(); } @Test diff --git a/spring-core/src/test/java/org/springframework/util/UnmodifiableMultiValueMapTests.java b/spring-core/src/test/java/org/springframework/util/UnmodifiableMultiValueMapTests.java index 473c49f5dad..a24031a4608 100644 --- a/spring-core/src/test/java/org/springframework/util/UnmodifiableMultiValueMapTests.java +++ b/spring-core/src/test/java/org/springframework/util/UnmodifiableMultiValueMapTests.java @@ -50,7 +50,7 @@ class UnmodifiableMultiValueMapTests { assertThat(map).hasSize(1); given(mock.isEmpty()).willReturn(false); - assertThat(map.isEmpty()).isFalse(); + assertThat(map).isNotEmpty(); given(mock.containsKey("foo")).willReturn(true); assertThat(map.containsKey("foo")).isTrue(); diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java index 74cc1d0e3ad..0448991e87c 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java @@ -1449,7 +1449,7 @@ class SpelReproTests extends AbstractExpressionTests { Expression expression = parser.parseExpression("T(java.util.Arrays).asList('')"); Object value = expression.getValue(); assertThat(value).isInstanceOf(List.class); - assertThat(((List) value).isEmpty()).isTrue(); + assertThat(((List) value)).isEmpty(); } @Test diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceJtaTransactionTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceJtaTransactionTests.java index b20693ae358..cb02735f342 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceJtaTransactionTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceJtaTransactionTests.java @@ -81,7 +81,7 @@ public class DataSourceJtaTransactionTests { @AfterEach public void verifyTransactionSynchronizationManagerState() { - assertThat(TransactionSynchronizationManager.getResourceMap().isEmpty()).isTrue(); + assertThat(TransactionSynchronizationManager.getResourceMap()).isEmpty(); assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse(); assertThat(TransactionSynchronizationManager.getCurrentTransactionName()).isNull(); assertThat(TransactionSynchronizationManager.isCurrentTransactionReadOnly()).isFalse(); diff --git a/spring-jms/src/test/java/org/springframework/jms/connection/JmsTransactionManagerTests.java b/spring-jms/src/test/java/org/springframework/jms/connection/JmsTransactionManagerTests.java index 3a1a9c067ef..7928072fa2e 100644 --- a/spring-jms/src/test/java/org/springframework/jms/connection/JmsTransactionManagerTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/connection/JmsTransactionManagerTests.java @@ -52,7 +52,7 @@ public class JmsTransactionManagerTests { @AfterEach public void verifyTransactionSynchronizationManagerState() { - assertThat(TransactionSynchronizationManager.getResourceMap().isEmpty()).isTrue(); + assertThat(TransactionSynchronizationManager.getResourceMap()).isEmpty(); assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse(); } diff --git a/spring-jms/src/test/java/org/springframework/jms/core/JmsTemplateTests.java b/spring-jms/src/test/java/org/springframework/jms/core/JmsTemplateTests.java index b26da5192c0..378041de186 100644 --- a/spring-jms/src/test/java/org/springframework/jms/core/JmsTemplateTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/core/JmsTemplateTests.java @@ -241,7 +241,7 @@ class JmsTemplateTests { TransactionSynchronizationManager.clearSynchronization(); scf.destroy(); } - assertThat(TransactionSynchronizationManager.getResourceMap().isEmpty()).isTrue(); + assertThat(TransactionSynchronizationManager.getResourceMap()).isEmpty(); verify(this.connection).start(); if (useTransactedTemplate()) { diff --git a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/PayloadMethodArgumentResolverTests.java b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/PayloadMethodArgumentResolverTests.java index 4c3fab7d7f6..89d37a5107d 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/PayloadMethodArgumentResolverTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/PayloadMethodArgumentResolverTests.java @@ -133,7 +133,7 @@ public class PayloadMethodArgumentResolverTests { Message emptyStringMessage = MessageBuilder.withPayload(" ").build(); assertThat(this.resolver.resolveArgument(this.paramAnnotatedNotRequired, emptyStringMessage)).isNull(); - assertThat(((Optional) this.resolver.resolveArgument(this.paramOptional, emptyStringMessage)).isEmpty()).isTrue(); + assertThat(((Optional) this.resolver.resolveArgument(this.paramOptional, emptyStringMessage))).isEmpty(); Message emptyOptionalMessage = MessageBuilder.withPayload(Optional.empty()).build(); assertThat(this.resolver.resolveArgument(this.paramAnnotatedNotRequired, emptyOptionalMessage)).isNull(); diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/ContainerManagedEntityManagerIntegrationTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/ContainerManagedEntityManagerIntegrationTests.java index 5092edad1c7..9d78e678479 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/ContainerManagedEntityManagerIntegrationTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/ContainerManagedEntityManagerIntegrationTests.java @@ -74,7 +74,7 @@ public class ContainerManagedEntityManagerIntegrationTests extends AbstractEntit assertThat(Proxy.isProxyClass(em.getClass())).isTrue(); Query q = em.createQuery("select p from Person as p"); List people = q.getResultList(); - assertThat(people.isEmpty()).isTrue(); + assertThat(people).isEmpty(); assertThat(em.isOpen()).as("Should be open to start with").isTrue(); assertThatIllegalStateException().as("Close should not work on container managed EM").isThrownBy( diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/EntityManagerFactoryUtilsTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/EntityManagerFactoryUtilsTests.java index d1daa1ae1c8..db277655e26 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/EntityManagerFactoryUtilsTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/EntityManagerFactoryUtilsTests.java @@ -60,7 +60,7 @@ public class EntityManagerFactoryUtilsTests { // no tx active assertThat(EntityManagerFactoryUtils.doGetTransactionalEntityManager(factory, null)).isNull(); - assertThat(TransactionSynchronizationManager.getResourceMap().isEmpty()).isTrue(); + assertThat(TransactionSynchronizationManager.getResourceMap()).isEmpty(); } @Test @@ -80,7 +80,7 @@ public class EntityManagerFactoryUtilsTests { TransactionSynchronizationManager.clearSynchronization(); } - assertThat(TransactionSynchronizationManager.getResourceMap().isEmpty()).isTrue(); + assertThat(TransactionSynchronizationManager.getResourceMap()).isEmpty(); } @Test diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/support/OpenEntityManagerInViewTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/support/OpenEntityManagerInViewTests.java index 58730b29966..47e88f15dc9 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/support/OpenEntityManagerInViewTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/support/OpenEntityManagerInViewTests.java @@ -83,7 +83,7 @@ public class OpenEntityManagerInViewTests { @AfterEach public void tearDown() { - assertThat(TransactionSynchronizationManager.getResourceMap().isEmpty()).isTrue(); + assertThat(TransactionSynchronizationManager.getResourceMap()).isEmpty(); assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse(); assertThat(TransactionSynchronizationManager.isCurrentTransactionReadOnly()).isFalse(); assertThat(TransactionSynchronizationManager.isActualTransactionActive()).isFalse(); diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceContextTransactionTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceContextTransactionTests.java index 5ae10156689..877863a66ea 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceContextTransactionTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceContextTransactionTests.java @@ -70,13 +70,13 @@ class PersistenceContextTransactionTests { }; pabpp.postProcessProperties(null, bean, "bean"); - assertThat(TransactionSynchronizationManager.getResourceMap().isEmpty()).isTrue(); + assertThat(TransactionSynchronizationManager.getResourceMap()).isEmpty(); assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse(); } @AfterEach void clear() { - assertThat(TransactionSynchronizationManager.getResourceMap().isEmpty()).isTrue(); + assertThat(TransactionSynchronizationManager.getResourceMap()).isEmpty(); assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse(); assertThat(TransactionSynchronizationManager.isCurrentTransactionReadOnly()).isFalse(); assertThat(TransactionSynchronizationManager.isActualTransactionActive()).isFalse(); diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/support/SharedEntityManagerFactoryTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/support/SharedEntityManagerFactoryTests.java index 70b1d43071c..56ba47b53fc 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/support/SharedEntityManagerFactoryTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/support/SharedEntityManagerFactoryTests.java @@ -72,7 +72,7 @@ public class SharedEntityManagerFactoryTests { TransactionSynchronizationManager.unbindResource(mockEmf); } - assertThat(TransactionSynchronizationManager.getResourceMap().isEmpty()).isTrue(); + assertThat(TransactionSynchronizationManager.getResourceMap()).isEmpty(); verify(mockEm).contains(o); verify(mockEm).close(); } diff --git a/spring-test/src/test/java/org/springframework/mock/web/MockMultipartHttpServletRequestTests.java b/spring-test/src/test/java/org/springframework/mock/web/MockMultipartHttpServletRequestTests.java index e3c2c139235..2fc639e3486 100644 --- a/spring-test/src/test/java/org/springframework/mock/web/MockMultipartHttpServletRequestTests.java +++ b/spring-test/src/test/java/org/springframework/mock/web/MockMultipartHttpServletRequestTests.java @@ -49,7 +49,7 @@ class MockMultipartHttpServletRequestTests { assertThat(request.getFileNames().hasNext()).isFalse(); assertThat(request.getFile("file1")).isNull(); assertThat(request.getFile("file2")).isNull(); - assertThat(request.getFileMap().isEmpty()).isTrue(); + assertThat(request.getFileMap()).isEmpty(); request.addFile(new MockMultipartFile("file1", "myContent1".getBytes())); request.addFile(new MockMultipartFile("file2", "myOrigFilename", TEXT_PLAIN_VALUE, "myContent2".getBytes())); diff --git a/spring-tx/src/test/java/org/springframework/transaction/JndiJtaTransactionManagerTests.java b/spring-tx/src/test/java/org/springframework/transaction/JndiJtaTransactionManagerTests.java index 2ee6004ad35..20026545d8e 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/JndiJtaTransactionManagerTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/JndiJtaTransactionManagerTests.java @@ -219,7 +219,7 @@ public class JndiJtaTransactionManagerTests { */ @AfterEach public void tearDown() { - assertThat(TransactionSynchronizationManager.getResourceMap().isEmpty()).isTrue(); + assertThat(TransactionSynchronizationManager.getResourceMap()).isEmpty(); assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse(); assertThat(TransactionSynchronizationManager.getCurrentTransactionName()).isNull(); assertThat(TransactionSynchronizationManager.isCurrentTransactionReadOnly()).isFalse(); diff --git a/spring-tx/src/test/java/org/springframework/transaction/JtaTransactionManagerTests.java b/spring-tx/src/test/java/org/springframework/transaction/JtaTransactionManagerTests.java index c4ba1d2a6fe..1d3276f464a 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/JtaTransactionManagerTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/JtaTransactionManagerTests.java @@ -1296,7 +1296,7 @@ public class JtaTransactionManagerTests { */ @AfterEach public void tearDown() { - assertThat(TransactionSynchronizationManager.getResourceMap().isEmpty()).isTrue(); + assertThat(TransactionSynchronizationManager.getResourceMap()).isEmpty(); assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse(); assertThat(TransactionSynchronizationManager.getCurrentTransactionName()).isNull(); assertThat(TransactionSynchronizationManager.isCurrentTransactionReadOnly()).isFalse(); diff --git a/spring-tx/src/test/java/org/springframework/transaction/support/SimpleTransactionScopeTests.java b/spring-tx/src/test/java/org/springframework/transaction/support/SimpleTransactionScopeTests.java index 0f3d0f3772a..7c2205fd42a 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/support/SimpleTransactionScopeTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/support/SimpleTransactionScopeTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2023 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. @@ -98,7 +98,7 @@ public class SimpleTransactionScopeTests { assertThat(bean2a.wasDestroyed()).isFalse(); assertThat(bean2b.wasDestroyed()).isTrue(); - assertThat(TransactionSynchronizationManager.getResourceMap().isEmpty()).isTrue(); + assertThat(TransactionSynchronizationManager.getResourceMap()).isEmpty(); assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> context.getBean(TestBean.class)) diff --git a/spring-web/src/test/java/org/springframework/http/HttpEntityTests.java b/spring-web/src/test/java/org/springframework/http/HttpEntityTests.java index 92275f79a6b..62ae61e55d8 100644 --- a/spring-web/src/test/java/org/springframework/http/HttpEntityTests.java +++ b/spring-web/src/test/java/org/springframework/http/HttpEntityTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -35,7 +35,7 @@ public class HttpEntityTests { String body = "foo"; HttpEntity entity = new HttpEntity<>(body); assertThat(entity.getBody()).isSameAs(body); - assertThat(entity.getHeaders().isEmpty()).isTrue(); + assertThat(entity.getHeaders()).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 96bb80ae67f..f4a56581c66 100644 --- a/spring-web/src/test/java/org/springframework/http/HttpHeadersTests.java +++ b/spring-web/src/test/java/org/springframework/http/HttpHeadersTests.java @@ -587,7 +587,7 @@ public class HttpHeadersTests { // here to check the behavior of the entire contract. // isEmpty() and size() - assertThat(keySet.isEmpty()).isFalse(); + assertThat(keySet).isNotEmpty(); assertThat(keySet).hasSize(2); // contains() @@ -618,9 +618,9 @@ public class HttpHeadersTests { // clear() keySet.clear(); - assertThat(keySet.isEmpty()).isTrue(); assertThat(keySet).isEmpty(); - assertThat(headers.isEmpty()).isTrue(); + assertThat(keySet).isEmpty(); + assertThat(headers).isEmpty(); assertThat(headers).isEmpty(); // Unsupported operations @@ -665,11 +665,11 @@ public class HttpHeadersTests { String headerName = "MyHeader"; String headerValue = "value"; - assertThat(headers.isEmpty()).isTrue(); + assertThat(headers).isEmpty(); headers.add(headerName, headerValue); assertThat(headers.containsKey(headerName)).isTrue(); headers.keySet().removeIf(key -> key.equals(headerName)); - assertThat(headers.isEmpty()).isTrue(); + assertThat(headers).isEmpty(); headers.add(headerName, headerValue); assertThat(headers.get(headerName)).element(0).isEqualTo(headerValue); } @@ -679,11 +679,11 @@ public class HttpHeadersTests { String headerName = "MyHeader"; String headerValue = "value"; - assertThat(headers.isEmpty()).isTrue(); + assertThat(headers).isEmpty(); headers.add(headerName, headerValue); assertThat(headers.containsKey(headerName)).isTrue(); headers.entrySet().removeIf(entry -> entry.getKey().equals(headerName)); - assertThat(headers.isEmpty()).isTrue(); + assertThat(headers).isEmpty(); headers.add(headerName, headerValue); assertThat(headers.get(headerName)).element(0).isEqualTo(headerValue); } diff --git a/spring-web/src/test/java/org/springframework/http/MediaTypeFactoryTests.java b/spring-web/src/test/java/org/springframework/http/MediaTypeFactoryTests.java index 929d60496b4..8840e8789c5 100644 --- a/spring-web/src/test/java/org/springframework/http/MediaTypeFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/http/MediaTypeFactoryTests.java @@ -39,7 +39,7 @@ public class MediaTypeFactoryTests { public void nullParameter() { assertThat(MediaTypeFactory.getMediaType((String) null)).isNotPresent(); assertThat(MediaTypeFactory.getMediaType((Resource) null)).isNotPresent(); - assertThat(MediaTypeFactory.getMediaTypes(null).isEmpty()).isTrue(); + assertThat(MediaTypeFactory.getMediaTypes(null)).isEmpty(); } } diff --git a/spring-web/src/test/java/org/springframework/http/ResponseEntityTests.java b/spring-web/src/test/java/org/springframework/http/ResponseEntityTests.java index 8d1c1f78565..7c52e12edf1 100644 --- a/spring-web/src/test/java/org/springframework/http/ResponseEntityTests.java +++ b/spring-web/src/test/java/org/springframework/http/ResponseEntityTests.java @@ -250,7 +250,7 @@ class ResponseEntityTests { ResponseEntity.ok().headers((HttpHeaders) null).build(); assertThat(responseEntityWithEmptyHeaders.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(responseEntityWithEmptyHeaders.getHeaders().isEmpty()).isTrue(); + assertThat(responseEntityWithEmptyHeaders.getHeaders()).isEmpty(); assertThat(responseEntityWithNullHeaders.toString()).isEqualTo(responseEntityWithEmptyHeaders.toString()); } diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpResponseTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpResponseTests.java index 910bf7ae47b..b190ec153fe 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpResponseTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpResponseTests.java @@ -112,7 +112,7 @@ class ServerHttpResponseTests { assertThat(response.cookiesWritten).isFalse(); assertThat(headers).doesNotContainKeys(HttpHeaders.CONTENT_TYPE, HttpHeaders.CONTENT_LENGTH, HttpHeaders.CONTENT_ENCODING); - assertThat(response.body.isEmpty()).isTrue(); + assertThat(response.body).isEmpty(); } @Test @@ -123,7 +123,7 @@ class ServerHttpResponseTests { assertThat(response.statusCodeWritten).isTrue(); assertThat(response.headersWritten).isTrue(); assertThat(response.cookiesWritten).isTrue(); - assertThat(response.body.isEmpty()).isTrue(); + assertThat(response.body).isEmpty(); } @Test @@ -157,7 +157,7 @@ class ServerHttpResponseTests { assertThat(response.statusCodeWritten).isTrue(); assertThat(response.headersWritten).isTrue(); assertThat(response.cookiesWritten).isTrue(); - assertThat(response.body.isEmpty()).isTrue(); + assertThat(response.body).isEmpty(); assertThat(response.getCookies().getFirst("ID")).isSameAs(cookie); } diff --git a/spring-web/src/test/java/org/springframework/web/method/support/ModelAndViewContainerTests.java b/spring-web/src/test/java/org/springframework/web/method/support/ModelAndViewContainerTests.java index aa59ba6244c..e7a9db064a9 100644 --- a/spring-web/src/test/java/org/springframework/web/method/support/ModelAndViewContainerTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/support/ModelAndViewContainerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -73,7 +73,7 @@ public class ModelAndViewContainerTests { this.mavContainer.addAttribute("name", "value"); this.mavContainer.setRedirectModelScenario(true); - assertThat(this.mavContainer.getModel().isEmpty()).isTrue(); + assertThat(this.mavContainer.getModel()).isEmpty(); } @Test // SPR-14045 diff --git a/spring-web/src/test/java/org/springframework/web/util/ContentCachingRequestWrapperTests.java b/spring-web/src/test/java/org/springframework/web/util/ContentCachingRequestWrapperTests.java index f6ea6139847..82f8777a1c0 100644 --- a/spring-web/src/test/java/org/springframework/web/util/ContentCachingRequestWrapperTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/ContentCachingRequestWrapperTests.java @@ -112,7 +112,7 @@ public class ContentCachingRequestWrapperTests { ContentCachingRequestWrapper wrapper = new ContentCachingRequestWrapper(request); // getting request parameters will consume the request body - assertThat(wrapper.getParameterMap().isEmpty()).isFalse(); + assertThat(wrapper.getParameterMap()).isNotEmpty(); assertThat(new String(wrapper.getContentAsByteArray())).isEqualTo("first=value&second=foo&second=bar"); // SPR-12810 : inputstream body should be consumed assertThat(new String(wrapper.getInputStream().readAllBytes())).isEmpty(); diff --git a/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java b/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java index 95f7c9d86fd..8bc8fe645f6 100644 --- a/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java @@ -772,8 +772,8 @@ class UriComponentsBuilderTests { UriComponents uri1 = UriComponentsBuilder.fromUriString("http://test.com").build().normalize(); UriComponents uri2 = UriComponentsBuilder.fromUriString("http://test.com/").build(); - assertThat(uri1.getPathSegments().isEmpty()).isTrue(); - assertThat(uri2.getPathSegments().isEmpty()).isTrue(); + assertThat(uri1.getPathSegments()).isEmpty(); + assertThat(uri2.getPathSegments()).isEmpty(); assertThat(uri2).isNotEqualTo(uri1); } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/config/CorsRegistryTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/config/CorsRegistryTests.java index f03254e7bff..1e59f2474f1 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/config/CorsRegistryTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/config/CorsRegistryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -38,7 +38,7 @@ public class CorsRegistryTests { @Test public void noMapping() { - assertThat(this.registry.getCorsConfigurations().isEmpty()).isTrue(); + assertThat(this.registry.getCorsConfigurations()).isEmpty(); } @Test diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeStrategiesTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeStrategiesTests.java index 14b91b1d618..94f9a01ff33 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeStrategiesTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeStrategiesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2023 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. @@ -28,27 +28,27 @@ public class ExchangeStrategiesTests { @Test public void empty() { ExchangeStrategies strategies = ExchangeStrategies.empty().build(); - assertThat(strategies.messageReaders().isEmpty()).isTrue(); - assertThat(strategies.messageWriters().isEmpty()).isTrue(); + assertThat(strategies.messageReaders()).isEmpty(); + assertThat(strategies.messageWriters()).isEmpty(); } @Test public void withDefaults() { ExchangeStrategies strategies = ExchangeStrategies.withDefaults(); - assertThat(strategies.messageReaders().isEmpty()).isFalse(); - assertThat(strategies.messageWriters().isEmpty()).isFalse(); + assertThat(strategies.messageReaders()).isNotEmpty(); + assertThat(strategies.messageWriters()).isNotEmpty(); } @Test @SuppressWarnings("deprecation") public void mutate() { ExchangeStrategies strategies = ExchangeStrategies.empty().build(); - assertThat(strategies.messageReaders().isEmpty()).isTrue(); - assertThat(strategies.messageWriters().isEmpty()).isTrue(); + assertThat(strategies.messageReaders()).isEmpty(); + assertThat(strategies.messageWriters()).isEmpty(); ExchangeStrategies mutated = strategies.mutate().codecs(codecs -> codecs.registerDefaults(true)).build(); - assertThat(mutated.messageReaders().isEmpty()).isFalse(); - assertThat(mutated.messageWriters().isEmpty()).isFalse(); + assertThat(mutated.messageReaders()).isNotEmpty(); + assertThat(mutated.messageWriters()).isNotEmpty(); } } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilderTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilderTests.java index f8226bc6143..625a70e3dda 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilderTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -298,13 +298,13 @@ class DefaultServerResponseBuilderTests { .cookie(ResponseCookie.from("foo", "bar").build()) .bodyValue("body"); - assertThat(serverResponse.block().cookies().isEmpty()).isFalse(); + assertThat(serverResponse.block().cookies()).isNotEmpty(); serverResponse = ServerResponse.ok() .cookie(ResponseCookie.from("foo", "bar").build()) .bodyValue("body"); - assertThat(serverResponse.block().cookies().isEmpty()).isFalse(); + assertThat(serverResponse.block().cookies()).isNotEmpty(); } @Test diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/HandlerStrategiesTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/HandlerStrategiesTests.java index f3dc04d0bf1..21f130a3a15 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/HandlerStrategiesTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/HandlerStrategiesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2023 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. @@ -28,17 +28,17 @@ public class HandlerStrategiesTests { @Test public void empty() { HandlerStrategies strategies = HandlerStrategies.empty().build(); - assertThat(strategies.messageReaders().isEmpty()).isTrue(); - assertThat(strategies.messageWriters().isEmpty()).isTrue(); - assertThat(strategies.viewResolvers().isEmpty()).isTrue(); + assertThat(strategies.messageReaders()).isEmpty(); + assertThat(strategies.messageWriters()).isEmpty(); + assertThat(strategies.viewResolvers()).isEmpty(); } @Test public void withDefaults() { HandlerStrategies strategies = HandlerStrategies.withDefaults(); - assertThat(strategies.messageReaders().isEmpty()).isFalse(); - assertThat(strategies.messageWriters().isEmpty()).isFalse(); - assertThat(strategies.viewResolvers().isEmpty()).isTrue(); + assertThat(strategies.messageReaders()).isNotEmpty(); + assertThat(strategies.messageWriters()).isNotEmpty(); + assertThat(strategies.viewResolvers()).isEmpty(); } } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/FlashMapTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/FlashMapTests.java index 830f9f132af..0f96dd988e8 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/FlashMapTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/FlashMapTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -103,7 +103,7 @@ public class FlashMapTests { flashMap.addTargetRequestParam(" ", "abc"); flashMap.addTargetRequestParam(null, "abc"); - assertThat(flashMap.getTargetRequestParams().isEmpty()).isTrue(); + assertThat(flashMap.getTargetRequestParams()).isEmpty(); } @Test @@ -115,7 +115,7 @@ public class FlashMapTests { FlashMap flashMap = new FlashMap(); flashMap.addTargetRequestParams(params); - assertThat(flashMap.getTargetRequestParams().isEmpty()).isTrue(); + assertThat(flashMap.getTargetRequestParams()).isEmpty(); } } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/CorsRegistryTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/CorsRegistryTests.java index 9b267eb814a..fce8a595680 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/CorsRegistryTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/CorsRegistryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -43,7 +43,7 @@ public class CorsRegistryTests { @Test public void noMapping() { - assertThat(this.registry.getCorsConfigurations().isEmpty()).isTrue(); + assertThat(this.registry.getCorsConfigurations()).isEmpty(); } @Test diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/ParameterizableViewControllerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/ParameterizableViewControllerTests.java index 376a0ca3d16..948f75e929b 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/ParameterizableViewControllerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/ParameterizableViewControllerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -52,14 +52,14 @@ public class ParameterizableViewControllerTests { this.controller.setViewName(viewName); ModelAndView mav = this.controller.handleRequest(this.request, new MockHttpServletResponse()); assertThat(mav.getViewName()).isEqualTo(viewName); - assertThat(mav.getModel().isEmpty()).isTrue(); + assertThat(mav.getModel()).isEmpty(); } @Test public void handleRequestWithoutViewName() throws Exception { ModelAndView mav = this.controller.handleRequest(this.request, new MockHttpServletResponse()); assertThat(mav.getViewName()).isNull(); - assertThat(mav.getModel().isEmpty()).isTrue(); + assertThat(mav.getModel()).isEmpty(); } @Test diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/UrlFilenameViewControllerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/UrlFilenameViewControllerTests.java index 2719d65f373..b1762e6523d 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/UrlFilenameViewControllerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/UrlFilenameViewControllerTests.java @@ -54,7 +54,7 @@ class UrlFilenameViewControllerTests { MockHttpServletRequest request = requestFactory.apply("/index"); ModelAndView mv = controller.handleRequest(request, new MockHttpServletResponse()); assertThat(mv.getViewName()).isEqualTo("index"); - assertThat(mv.getModel().isEmpty()).isTrue(); + assertThat(mv.getModel()).isEmpty(); } @PathPatternsParameterizedTest @@ -63,7 +63,7 @@ class UrlFilenameViewControllerTests { MockHttpServletRequest request = requestFactory.apply("/index.html"); ModelAndView mv = controller.handleRequest(request, new MockHttpServletResponse()); assertThat(mv.getViewName()).isEqualTo("index"); - assertThat(mv.getModel().isEmpty()).isTrue(); + assertThat(mv.getModel()).isEmpty(); } @PathPatternsParameterizedTest @@ -72,7 +72,7 @@ class UrlFilenameViewControllerTests { MockHttpServletRequest request = requestFactory.apply("/index;a=A;b=B"); ModelAndView mv = controller.handleRequest(request, new MockHttpServletResponse()); assertThat(mv.getViewName()).isEqualTo("index"); - assertThat(mv.getModel().isEmpty()).isTrue(); + assertThat(mv.getModel()).isEmpty(); } @PathPatternsParameterizedTest @@ -83,7 +83,7 @@ class UrlFilenameViewControllerTests { MockHttpServletRequest request = requestFactory.apply("/index.html"); ModelAndView mv = controller.handleRequest(request, new MockHttpServletResponse()); assertThat(mv.getViewName()).isEqualTo("mypre_index_mysuf"); - assertThat(mv.getModel().isEmpty()).isTrue(); + assertThat(mv.getModel()).isEmpty(); } @PathPatternsParameterizedTest @@ -93,7 +93,7 @@ class UrlFilenameViewControllerTests { MockHttpServletRequest request = requestFactory.apply("/index.html"); ModelAndView mv = controller.handleRequest(request, new MockHttpServletResponse()); assertThat(mv.getViewName()).isEqualTo("mypre_index"); - assertThat(mv.getModel().isEmpty()).isTrue(); + assertThat(mv.getModel()).isEmpty(); } @PathPatternsParameterizedTest @@ -103,7 +103,7 @@ class UrlFilenameViewControllerTests { MockHttpServletRequest request = requestFactory.apply("/index.html"); ModelAndView mv = controller.handleRequest(request, new MockHttpServletResponse()); assertThat(mv.getViewName()).isEqualTo("index_mysuf"); - assertThat(mv.getModel().isEmpty()).isTrue(); + assertThat(mv.getModel()).isEmpty(); } @PathPatternsParameterizedTest @@ -112,7 +112,7 @@ class UrlFilenameViewControllerTests { MockHttpServletRequest request = requestFactory.apply("/docs/cvs/commit.html"); ModelAndView mv = controller.handleRequest(request, new MockHttpServletResponse()); assertThat(mv.getViewName()).isEqualTo("docs/cvs/commit"); - assertThat(mv.getModel().isEmpty()).isTrue(); + assertThat(mv.getModel()).isEmpty(); } @PathPatternsParameterizedTest @@ -122,7 +122,7 @@ class UrlFilenameViewControllerTests { exposePathInMapping(request, "/docs/**"); ModelAndView mv = controller.handleRequest(request, new MockHttpServletResponse()); assertThat(mv.getViewName()).isEqualTo("cvs/commit"); - assertThat(mv.getModel().isEmpty()).isTrue(); + assertThat(mv.getModel()).isEmpty(); } @PathPatternsParameterizedTest @@ -132,7 +132,7 @@ class UrlFilenameViewControllerTests { exposePathInMapping(request, "/docs/cvs/commit.html"); ModelAndView mv = controller.handleRequest(request, new MockHttpServletResponse()); assertThat(mv.getViewName()).isEqualTo("docs/cvs/commit"); - assertThat(mv.getModel().isEmpty()).isTrue(); + assertThat(mv.getModel()).isEmpty(); } @PathPatternsParameterizedTest @@ -143,7 +143,7 @@ class UrlFilenameViewControllerTests { ServletRequestPathUtils.parseAndCache(request); ModelAndView mv = controller.handleRequest(request, new MockHttpServletResponse()); assertThat(mv.getViewName()).isEqualTo("docs/cvs/commit"); - assertThat(mv.getModel().isEmpty()).isTrue(); + assertThat(mv.getModel()).isEmpty(); } @Test @@ -180,7 +180,7 @@ class UrlFilenameViewControllerTests { MockHttpServletRequest request = requestFactory.apply("/products/view.html"); ModelAndView mv = controller.handleRequest(request, new MockHttpServletResponse()); assertThat(mv.getViewName()).isEqualTo("products/view"); - assertThat(mv.getModel().isEmpty()).isTrue(); + assertThat(mv.getModel()).isEmpty(); } @PathPatternsParameterizedTest diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewMethodReturnValueHandlerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewMethodReturnValueHandlerTests.java index 1e528d46e5e..3980ecfbc95 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewMethodReturnValueHandlerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewMethodReturnValueHandlerTests.java @@ -140,7 +140,7 @@ public class ModelAndViewMethodReturnValueHandlerTests { ModelMap model = mavContainer.getModel(); assertThat(mavContainer.getView()).isNull(); - assertThat(mavContainer.getModel().isEmpty()).isTrue(); + assertThat(mavContainer.getModel()).isEmpty(); assertThat(model).as("RedirectAttributes should not be used if controller doesn't redirect").isNotSameAs(redirectAttributes); } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewResolverMethodReturnValueHandlerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewResolverMethodReturnValueHandlerTests.java index b4e9d900bd7..4e62166b3f0 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewResolverMethodReturnValueHandlerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewResolverMethodReturnValueHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2023 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. @@ -89,7 +89,7 @@ public class ModelAndViewResolverMethodReturnValueHandlerTests { assertThat(mavContainer.getView()).isNull(); assertThat(mavContainer.getViewName()).isNull(); - assertThat(mavContainer.getModel().isEmpty()).isTrue(); + assertThat(mavContainer.getModel()).isEmpty(); } @Test diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java index 42d4f8a0209..a1f93d7d89e 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java @@ -1671,7 +1671,7 @@ class ServletAnnotationControllerHandlerMethodTests extends AbstractServletHandl assertThat(response.getStatus()).isEqualTo(200); assertThat(response.getForwardedUrl()).isEqualTo("messages/new"); - assertThat(RequestContextUtils.getOutputFlashMap(request).isEmpty()).isTrue(); + assertThat((Map) RequestContextUtils.getOutputFlashMap(request)).isEmpty(); // POST -> success request = new MockHttpServletRequest("POST", "/messages"); @@ -1693,7 +1693,7 @@ class ServletAnnotationControllerHandlerMethodTests extends AbstractServletHandl assertThat(response.getStatus()).isEqualTo(200); assertThat(response.getContentAsString()).isEqualTo("Got: yay!"); - assertThat(RequestContextUtils.getOutputFlashMap(request).isEmpty()).isTrue(); + assertThat((Map) RequestContextUtils.getOutputFlashMap(request)).isEmpty(); } @PathPatternsParameterizedTest // SPR-15176 @@ -1719,7 +1719,7 @@ class ServletAnnotationControllerHandlerMethodTests extends AbstractServletHandl assertThat(response.getStatus()).isEqualTo(200); assertThat(response.getContentAsString()).isEqualTo("Got: yay!"); - assertThat(RequestContextUtils.getOutputFlashMap(request).isEmpty()).isTrue(); + assertThat((Map) RequestContextUtils.getOutputFlashMap(request)).isEmpty(); } @PathPatternsParameterizedTest diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/config/HandlersBeanDefinitionParserTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/config/HandlersBeanDefinitionParserTests.java index 02254ccf3c6..978d32f77e8 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/config/HandlersBeanDefinitionParserTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/config/HandlersBeanDefinitionParserTests.java @@ -97,7 +97,7 @@ public class HandlersBeanDefinitionParserTests { assertThat(handshakeHandler).isNotNull(); boolean condition1 = handshakeHandler instanceof DefaultHandshakeHandler; assertThat(condition1).isTrue(); - assertThat(handler.getHandshakeInterceptors().isEmpty()).isFalse(); + assertThat(handler.getHandshakeInterceptors()).isNotEmpty(); boolean condition = handler.getHandshakeInterceptors().get(0) instanceof OriginHandshakeInterceptor; assertThat(condition).isTrue(); } @@ -110,7 +110,7 @@ public class HandlersBeanDefinitionParserTests { assertThat(handshakeHandler).isNotNull(); boolean condition1 = handshakeHandler instanceof DefaultHandshakeHandler; assertThat(condition1).isTrue(); - assertThat(handler.getHandshakeInterceptors().isEmpty()).isFalse(); + assertThat(handler.getHandshakeInterceptors()).isNotEmpty(); boolean condition = handler.getHandshakeInterceptors().get(0) instanceof OriginHandshakeInterceptor; assertThat(condition).isTrue(); } diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/support/SockJsServiceTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/support/SockJsServiceTests.java index 2fbbdda70d0..83d1070da7a 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/support/SockJsServiceTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/support/SockJsServiceTests.java @@ -192,7 +192,7 @@ class SockJsServiceTests extends AbstractHttpRequestTests { this.servletRequest.addHeader(HttpHeaders.ACCESS_CONTROL_REQUEST_HEADERS, "Last-Modified"); resetResponseAndHandleRequest("OPTIONS", "/echo/info", HttpStatus.FORBIDDEN); CorsConfiguration corsConfiguration = this.service.getCorsConfiguration(this.servletRequest); - assertThat(corsConfiguration.getAllowedOrigins().isEmpty()).isTrue(); + assertThat(corsConfiguration.getAllowedOrigins()).isEmpty(); this.service.setAllowedOrigins(Collections.singletonList("https://mydomain1.example")); resetResponseAndHandleRequest("OPTIONS", "/echo/info", HttpStatus.FORBIDDEN);