mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-17 08:24:13 +00:00
Convert assertThat(x instanceof X).isFalse() to assertThat(x).isNotInstanceOf()
Search: assertThat\((.+?) instanceof (.+?)\)(.*?)\.isFalse\(\) Replace: assertThat($1)$3.isNotInstanceOf($2.class) See gh-36504
This commit is contained in:
+3
-3
@@ -84,7 +84,7 @@ class AopNamespaceHandlerScopeIntegrationTests {
|
||||
assertThat(requestScoped).as("Should be target class proxy").isInstanceOf(TestBean.class);
|
||||
|
||||
assertThat(AopUtils.isAopProxy(testBean)).as("Should be AOP proxy").isTrue();
|
||||
assertThat(testBean instanceof TestBean).as("Regular bean should be JDK proxy").isFalse();
|
||||
assertThat(testBean).as("Regular bean should be JDK proxy").isNotInstanceOf(TestBean.class);
|
||||
|
||||
String rob = "Rob Harrop";
|
||||
String bram = "Bram Smeets";
|
||||
@@ -109,12 +109,12 @@ class AopNamespaceHandlerScopeIntegrationTests {
|
||||
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request));
|
||||
|
||||
assertThat(AopUtils.isAopProxy(sessionScoped)).as("Should be AOP proxy").isTrue();
|
||||
assertThat(sessionScoped instanceof TestBean).as("Should not be target class proxy").isFalse();
|
||||
assertThat(sessionScoped).as("Should not be target class proxy").isNotInstanceOf(TestBean.class);
|
||||
|
||||
assertThat(sessionScopedAlias).isSameAs(sessionScoped);
|
||||
|
||||
assertThat(AopUtils.isAopProxy(testBean)).as("Should be AOP proxy").isTrue();
|
||||
assertThat(testBean instanceof TestBean).as("Regular bean should be JDK proxy").isFalse();
|
||||
assertThat(testBean).as("Regular bean should be JDK proxy").isNotInstanceOf(TestBean.class);
|
||||
|
||||
String rob = "Rob Harrop";
|
||||
String bram = "Bram Smeets";
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ class ExposeBeanNameAdvisorsTests {
|
||||
pf.addAdvisor(ExposeBeanNameAdvisors.createAdvisorWithoutIntroduction(beanName));
|
||||
ITestBean proxy = (ITestBean) pf.getProxy();
|
||||
|
||||
assertThat(proxy instanceof NamedBean).as("No introduction").isFalse();
|
||||
assertThat(proxy).as("No introduction").isNotInstanceOf(NamedBean.class);
|
||||
// Requires binding
|
||||
proxy.getAge();
|
||||
}
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ class BeanNamePointcutAtAspectTests {
|
||||
|
||||
@Test
|
||||
void nonMatchingBeanName() {
|
||||
assertThat(testBean3 instanceof Advised).as("Didn't expect a proxy").isFalse();
|
||||
assertThat(testBean3).as("Didn't expect a proxy").isNotInstanceOf(Advised.class);
|
||||
|
||||
testBean3.setAge(20);
|
||||
assertThat(counterAspect.count).isEqualTo(0);
|
||||
|
||||
+5
-5
@@ -84,14 +84,14 @@ class BeanNamePointcutTests {
|
||||
|
||||
@Test
|
||||
void nonMatchingBeanName() {
|
||||
assertThat(this.testBean2 instanceof Advised).as("Non-matching bean must *not* be advised (proxied)").isFalse();
|
||||
assertThat(this.testBean2).as("Non-matching bean must *not* be advised (proxied)").isNotInstanceOf(Advised.class);
|
||||
this.testBean2.setAge(20);
|
||||
assertThat(this.counterAspect.getCount()).as("Advice must *not* have been executed").isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void nonMatchingNestedBeanName() {
|
||||
assertThat(this.testBeanContainingNestedBean.getDoctor() instanceof Advised).as("Non-matching bean must *not* be advised (proxied)").isFalse();
|
||||
assertThat(this.testBeanContainingNestedBean.getDoctor()).as("Non-matching bean must *not* be advised (proxied)").isNotInstanceOf(Advised.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -101,12 +101,12 @@ class BeanNamePointcutTests {
|
||||
assertThat(this.testFactoryBean1.get("myKey")).isEqualTo("myValue");
|
||||
assertThat(this.counterAspect.getCount()).as("Advice not executed: must have been").isEqualTo(2);
|
||||
FactoryBean<?> fb = (FactoryBean<?>) ctx.getBean("&testFactoryBean1");
|
||||
assertThat((fb instanceof Advised)).as("FactoryBean itself must *not* be advised").isFalse();
|
||||
assertThat((fb)).as("FactoryBean itself must *not* be advised").isNotInstanceOf(Advised.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void matchingFactoryBeanItself() {
|
||||
assertThat((this.testFactoryBean2 instanceof Advised)).as("Matching bean must *not* be advised (proxied)").isFalse();
|
||||
assertThat((this.testFactoryBean2)).as("Matching bean must *not* be advised (proxied)").isNotInstanceOf(Advised.class);
|
||||
FactoryBean<?> fb = (FactoryBean<?>) ctx.getBean("&testFactoryBean2");
|
||||
assertThat(fb).as("FactoryBean itself must be advised").isInstanceOf(Advised.class);
|
||||
assertThat(Map.class.isAssignableFrom(fb.getObjectType())).isTrue();
|
||||
@@ -117,7 +117,7 @@ class BeanNamePointcutTests {
|
||||
@Test
|
||||
void pointcutAdvisorCombination() {
|
||||
assertThat(this.interceptThis).as("Matching bean must be advised (proxied)").isInstanceOf(Advised.class);
|
||||
assertThat(this.dontInterceptThis instanceof Advised).as("Non-matching bean must *not* be advised (proxied)").isFalse();
|
||||
assertThat(this.dontInterceptThis).as("Non-matching bean must *not* be advised (proxied)").isNotInstanceOf(Advised.class);
|
||||
interceptThis.setAge(20);
|
||||
assertThat(testInterceptor.interceptionCount).isEqualTo(1);
|
||||
dontInterceptThis.setAge(20);
|
||||
|
||||
+1
-1
@@ -854,7 +854,7 @@ abstract class AbstractAopProxyTests {
|
||||
assertThat(proxied.getAge()).isEqualTo(10);
|
||||
assertThat(mba.getCalls()).isEqualTo(1);
|
||||
|
||||
assertThat(proxied instanceof Advised).as("Cannot be cast to Advised").isFalse();
|
||||
assertThat(proxied).as("Cannot be cast to Advised").isNotInstanceOf(Advised.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+1
-1
@@ -153,7 +153,7 @@ class ScopingTests {
|
||||
// get hidden bean
|
||||
Object bean = ctx.getBean("scopedTarget." + beanName);
|
||||
|
||||
assertThat(bean instanceof ScopedObject).isFalse();
|
||||
assertThat(bean).isNotInstanceOf(ScopedObject.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+4
-4
@@ -67,13 +67,13 @@ class LocaleContextHolderTests {
|
||||
LocaleContextHolder.setLocale(Locale.GERMAN);
|
||||
assertThat(LocaleContextHolder.getLocale()).isEqualTo(Locale.GERMAN);
|
||||
assertThat(LocaleContextHolder.getTimeZone()).isEqualTo(TimeZone.getDefault());
|
||||
assertThat(LocaleContextHolder.getLocaleContext() instanceof TimeZoneAwareLocaleContext).isFalse();
|
||||
assertThat(LocaleContextHolder.getLocaleContext()).isNotInstanceOf(TimeZoneAwareLocaleContext.class);
|
||||
assertThat(LocaleContextHolder.getLocaleContext().getLocale()).isEqualTo(Locale.GERMAN);
|
||||
|
||||
LocaleContextHolder.setLocale(Locale.GERMANY);
|
||||
assertThat(LocaleContextHolder.getLocale()).isEqualTo(Locale.GERMANY);
|
||||
assertThat(LocaleContextHolder.getTimeZone()).isEqualTo(TimeZone.getDefault());
|
||||
assertThat(LocaleContextHolder.getLocaleContext() instanceof TimeZoneAwareLocaleContext).isFalse();
|
||||
assertThat(LocaleContextHolder.getLocaleContext()).isNotInstanceOf(TimeZoneAwareLocaleContext.class);
|
||||
assertThat(LocaleContextHolder.getLocaleContext().getLocale()).isEqualTo(Locale.GERMANY);
|
||||
|
||||
LocaleContextHolder.setLocale(null);
|
||||
@@ -119,7 +119,7 @@ class LocaleContextHolderTests {
|
||||
LocaleContextHolder.setLocale(Locale.GERMANY);
|
||||
assertThat(LocaleContextHolder.getLocale()).isEqualTo(Locale.GERMANY);
|
||||
assertThat(LocaleContextHolder.getTimeZone()).isEqualTo(TimeZone.getDefault());
|
||||
assertThat(LocaleContextHolder.getLocaleContext() instanceof TimeZoneAwareLocaleContext).isFalse();
|
||||
assertThat(LocaleContextHolder.getLocaleContext()).isNotInstanceOf(TimeZoneAwareLocaleContext.class);
|
||||
assertThat(LocaleContextHolder.getLocaleContext().getLocale()).isEqualTo(Locale.GERMANY);
|
||||
|
||||
LocaleContextHolder.setTimeZone(TimeZone.getTimeZone("GMT+1"));
|
||||
@@ -139,7 +139,7 @@ class LocaleContextHolderTests {
|
||||
LocaleContextHolder.setTimeZone(null);
|
||||
assertThat(LocaleContextHolder.getLocale()).isEqualTo(Locale.GERMAN);
|
||||
assertThat(LocaleContextHolder.getTimeZone()).isEqualTo(TimeZone.getDefault());
|
||||
assertThat(LocaleContextHolder.getLocaleContext() instanceof TimeZoneAwareLocaleContext).isFalse();
|
||||
assertThat(LocaleContextHolder.getLocaleContext()).isNotInstanceOf(TimeZoneAwareLocaleContext.class);
|
||||
assertThat(LocaleContextHolder.getLocaleContext().getLocale()).isEqualTo(Locale.GERMAN);
|
||||
|
||||
LocaleContextHolder.setTimeZone(TimeZone.getTimeZone("GMT+2"));
|
||||
|
||||
+12
-12
@@ -78,8 +78,8 @@ class GroovyScriptFactoryTests {
|
||||
assertThat(AopUtils.isAopProxy(calc)).as("Shouldn't get proxy when refresh is disabled").isFalse();
|
||||
assertThat(AopUtils.isAopProxy(messenger)).as("Shouldn't get proxy when refresh is disabled").isFalse();
|
||||
|
||||
assertThat(calc instanceof Refreshable).as("Scripted object should not be instance of Refreshable").isFalse();
|
||||
assertThat(messenger instanceof Refreshable).as("Scripted object should not be instance of Refreshable").isFalse();
|
||||
assertThat(calc).as("Scripted object should not be instance of Refreshable").isNotInstanceOf(Refreshable.class);
|
||||
assertThat(messenger).as("Scripted object should not be instance of Refreshable").isNotInstanceOf(Refreshable.class);
|
||||
|
||||
assertThat(calc).isEqualTo(calc);
|
||||
assertThat(messenger).isEqualTo(messenger);
|
||||
@@ -107,8 +107,8 @@ class GroovyScriptFactoryTests {
|
||||
assertThat(AopUtils.isAopProxy(calc)).as("Shouldn't get proxy when refresh is disabled").isFalse();
|
||||
assertThat(AopUtils.isAopProxy(messenger)).as("Shouldn't get proxy when refresh is disabled").isFalse();
|
||||
|
||||
assertThat(calc instanceof Refreshable).as("Scripted object should not be instance of Refreshable").isFalse();
|
||||
assertThat(messenger instanceof Refreshable).as("Scripted object should not be instance of Refreshable").isFalse();
|
||||
assertThat(calc).as("Scripted object should not be instance of Refreshable").isNotInstanceOf(Refreshable.class);
|
||||
assertThat(messenger).as("Scripted object should not be instance of Refreshable").isNotInstanceOf(Refreshable.class);
|
||||
|
||||
assertThat(calc).isEqualTo(calc);
|
||||
assertThat(messenger).isEqualTo(messenger);
|
||||
@@ -130,7 +130,7 @@ class GroovyScriptFactoryTests {
|
||||
ConfigurableMessenger messenger2 = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
|
||||
|
||||
assertThat(AopUtils.isAopProxy(messenger)).as("Shouldn't get proxy when refresh is disabled").isFalse();
|
||||
assertThat(messenger instanceof Refreshable).as("Scripted object should not be instance of Refreshable").isFalse();
|
||||
assertThat(messenger).as("Scripted object should not be instance of Refreshable").isNotInstanceOf(Refreshable.class);
|
||||
|
||||
assertThat(messenger2).isNotSameAs(messenger);
|
||||
assertThat(messenger2.getClass()).isSameAs(messenger.getClass());
|
||||
@@ -149,7 +149,7 @@ class GroovyScriptFactoryTests {
|
||||
ConfigurableMessenger messenger2 = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
|
||||
|
||||
assertThat(AopUtils.isAopProxy(messenger)).as("Shouldn't get proxy when refresh is disabled").isFalse();
|
||||
assertThat(messenger instanceof Refreshable).as("Scripted object should not be instance of Refreshable").isFalse();
|
||||
assertThat(messenger).as("Scripted object should not be instance of Refreshable").isNotInstanceOf(Refreshable.class);
|
||||
|
||||
assertThat(messenger2).isNotSameAs(messenger);
|
||||
assertThat(messenger2.getClass()).isSameAs(messenger.getClass());
|
||||
@@ -168,7 +168,7 @@ class GroovyScriptFactoryTests {
|
||||
Messenger messenger = (Messenger) ctx.getBean("messengerInstance");
|
||||
|
||||
assertThat(AopUtils.isAopProxy(messenger)).as("Shouldn't get proxy when refresh is disabled").isFalse();
|
||||
assertThat(messenger instanceof Refreshable).as("Scripted object should not be instance of Refreshable").isFalse();
|
||||
assertThat(messenger).as("Scripted object should not be instance of Refreshable").isNotInstanceOf(Refreshable.class);
|
||||
|
||||
String desiredMessage = "Hello World!";
|
||||
assertThat(messenger.getMessage()).as("Message is incorrect").isEqualTo(desiredMessage);
|
||||
@@ -182,7 +182,7 @@ class GroovyScriptFactoryTests {
|
||||
Messenger messenger = (Messenger) ctx.getBean("messengerInstance");
|
||||
|
||||
assertThat(AopUtils.isAopProxy(messenger)).as("Shouldn't get proxy when refresh is disabled").isFalse();
|
||||
assertThat(messenger instanceof Refreshable).as("Scripted object should not be instance of Refreshable").isFalse();
|
||||
assertThat(messenger).as("Scripted object should not be instance of Refreshable").isNotInstanceOf(Refreshable.class);
|
||||
|
||||
String desiredMessage = "Hello World!";
|
||||
assertThat(messenger.getMessage()).as("Message is incorrect").isEqualTo(desiredMessage);
|
||||
@@ -196,7 +196,7 @@ class GroovyScriptFactoryTests {
|
||||
Messenger messenger = (Messenger) ctx.getBean("messengerInstanceInline");
|
||||
|
||||
assertThat(AopUtils.isAopProxy(messenger)).as("Shouldn't get proxy when refresh is disabled").isFalse();
|
||||
assertThat(messenger instanceof Refreshable).as("Scripted object should not be instance of Refreshable").isFalse();
|
||||
assertThat(messenger).as("Scripted object should not be instance of Refreshable").isNotInstanceOf(Refreshable.class);
|
||||
|
||||
String desiredMessage = "Hello World!";
|
||||
assertThat(messenger.getMessage()).as("Message is incorrect").isEqualTo(desiredMessage);
|
||||
@@ -210,7 +210,7 @@ class GroovyScriptFactoryTests {
|
||||
Messenger messenger = (Messenger) ctx.getBean("messengerInstanceInline");
|
||||
|
||||
assertThat(AopUtils.isAopProxy(messenger)).as("Shouldn't get proxy when refresh is disabled").isFalse();
|
||||
assertThat(messenger instanceof Refreshable).as("Scripted object should not be instance of Refreshable").isFalse();
|
||||
assertThat(messenger).as("Scripted object should not be instance of Refreshable").isNotInstanceOf(Refreshable.class);
|
||||
|
||||
String desiredMessage = "Hello World!";
|
||||
assertThat(messenger.getMessage()).as("Message is incorrect").isEqualTo(desiredMessage);
|
||||
@@ -355,7 +355,7 @@ class GroovyScriptFactoryTests {
|
||||
CallCounter countingAspect = (CallCounter) ctx.getBean("getMessageAspect");
|
||||
|
||||
assertThat(AopUtils.isAopProxy(messenger)).isTrue();
|
||||
assertThat(messenger instanceof Refreshable).isFalse();
|
||||
assertThat(messenger).isNotInstanceOf(Refreshable.class);
|
||||
assertThat(countingAspect.getCalls()).isEqualTo(0);
|
||||
assertThat(messenger.getMessage()).isEqualTo("Hello World!");
|
||||
assertThat(countingAspect.getCalls()).isEqualTo(1);
|
||||
@@ -387,7 +387,7 @@ class GroovyScriptFactoryTests {
|
||||
assertThat(ObjectUtils.containsElement(bd.getDependsOn(), "messenger")).isTrue();
|
||||
Calculator calculator = (Calculator) ctx.getBean("calculator");
|
||||
assertThat(calculator).isNotNull();
|
||||
assertThat(calculator instanceof Refreshable).isFalse();
|
||||
assertThat(calculator).isNotInstanceOf(Refreshable.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+1
-1
@@ -128,7 +128,7 @@ class EncodedResourceResolverTests {
|
||||
|
||||
assertThat(resolved.getDescription()).isEqualTo(getResource(file).getDescription());
|
||||
assertThat(resolved.getFilename()).isEqualTo(getResource(file).getFilename());
|
||||
assertThat(resolved instanceof HttpResource).isFalse();
|
||||
assertThat(resolved).isNotInstanceOf(HttpResource.class);
|
||||
}
|
||||
|
||||
@Test // SPR-13149
|
||||
|
||||
+1
-1
@@ -116,7 +116,7 @@ class EncodedResourceResolverTests {
|
||||
|
||||
assertThat(resolved.getDescription()).isEqualTo(getResource(file).getDescription());
|
||||
assertThat(resolved.getFilename()).isEqualTo(getResource(file).getFilename());
|
||||
assertThat(resolved instanceof HttpResource).isFalse();
|
||||
assertThat(resolved).isNotInstanceOf(HttpResource.class);
|
||||
}
|
||||
|
||||
@Test // SPR-13149
|
||||
|
||||
Reference in New Issue
Block a user