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:
committed by
Brian Clozel
parent
7b16ef90f1
commit
afcd03bddc
@@ -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
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user