Replace assertThat(x.isEmpty()).isTrue() with assertThat(x).isEmpty()

Search for   : assertThat\((.+).isEmpty\(\)\).isTrue\(\)
Replace with : assertThat($1).isEmpty()

Search for   : assertThat\((.+).isEmpty\(\)\).isFalse\(\)
Replace with : assertThat($1).isNotEmpty()

Closes gh-31758
This commit is contained in:
Yanming Zhou 2023-12-06 09:34:06 +08:00 committed by Brian Clozel
parent 7b16ef90f1
commit afcd03bddc
55 changed files with 135 additions and 134 deletions

View File

@ -134,7 +134,7 @@ public class BeanFactoryUtilsTests {
StaticListableBeanFactory lbf = new StaticListableBeanFactory();
lbf.addBean("foo", new Object());
Map<String, ?> beans = BeanFactoryUtils.beansOfTypeIncludingAncestors(lbf, ITestBean.class, true, false);
assertThat(beans.isEmpty()).isTrue();
assertThat(beans).isEmpty();
}
@Test

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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();
}

View File

@ -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());
}

View File

@ -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();
}

View File

@ -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");
}

View File

@ -141,9 +141,9 @@ class ConversionServiceFactoryBeanTests {
static class ComplexConstructorArgument {
ComplexConstructorArgument(Map<String, Class<?>> 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);
}
}

View File

@ -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

View File

@ -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();
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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<Transactional> allMergedAnnotations = getAllMergedAnnotations(method, Transactional.class);
assertThat(allMergedAnnotations.isEmpty()).isTrue();
assertThat(allMergedAnnotations).isEmpty();
}
@Test

View File

@ -96,7 +96,7 @@ class CollectionToCollectionConverterTests {
@SuppressWarnings("unchecked")
ArrayList<Integer> result = (ArrayList<Integer>) conversionService.convert(list, sourceType, targetType);
assertThat(result.getClass()).isEqualTo(ArrayList.class);
assertThat(result.isEmpty()).isTrue();
assertThat(result).isEmpty();
}
@Test

View File

@ -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

View File

@ -217,7 +217,7 @@ class CollectionUtilsTests {
@Test
void conversionOfEmptyMap() {
MultiValueMap<String, String> asMultiValueMap = CollectionUtils.toMultiValueMap(new HashMap<>());
assertThat(asMultiValueMap.isEmpty()).isTrue();
assertThat(asMultiValueMap).isEmpty();
assertThat(asMultiValueMap).isEmpty();
}

View File

@ -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

View File

@ -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();

View File

@ -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

View File

@ -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();

View File

@ -52,7 +52,7 @@ public class JmsTransactionManagerTests {
@AfterEach
public void verifyTransactionSynchronizationManagerState() {
assertThat(TransactionSynchronizationManager.getResourceMap().isEmpty()).isTrue();
assertThat(TransactionSynchronizationManager.getResourceMap()).isEmpty();
assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse();
}

View File

@ -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()) {

View File

@ -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();

View File

@ -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<Person> 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(

View File

@ -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

View File

@ -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();

View File

@ -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();

View File

@ -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();
}

View File

@ -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()));

View File

@ -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();

View File

@ -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();

View File

@ -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))

View File

@ -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<String> entity = new HttpEntity<>(body);
assertThat(entity.getBody()).isSameAs(body);
assertThat(entity.getHeaders().isEmpty()).isTrue();
assertThat(entity.getHeaders()).isEmpty();
}
@Test

View File

@ -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);
}

View File

@ -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();
}
}

View File

@ -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());
}

View File

@ -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);
}

View File

@ -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

View File

@ -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();

View File

@ -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);
}

View File

@ -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

View File

@ -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();
}
}

View File

@ -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

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);
}

View File

@ -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

View File

@ -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

View File

@ -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();
}

View File

@ -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);