Replace assertThat(x instanceof y).isTrue() with assertThat(x).isInstanceOf(y.class)

Search for   : assertThat\((.+) instanceof (\w+)\)\.isTrue\(\)
Replace with : assertThat($1).isInstanceOf($2.class)

Search for   : assertThat\((.+) instanceof (\w+)\)\.isFalse\(\)
Replace with : assertThat($1).isNotInstanceOf($2.class)

Closes gh-31760
This commit is contained in:
Yanming Zhou
2023-12-06 11:16:22 +08:00
committed by Brian Clozel
parent 59815cefce
commit 66e405525b
18 changed files with 62 additions and 62 deletions

View File

@@ -155,7 +155,7 @@ public class BeanFactoryUtilsTests {
assertThat(beans.get("t1")).isEqualTo(t1);
assertThat(beans.get("t2")).isEqualTo(t2);
assertThat(beans.get("t3")).isEqualTo(t3.getObject());
assertThat(beans.get("t4") instanceof TestBean).isTrue();
assertThat(beans.get("t4")).isInstanceOf(TestBean.class);
beans = BeanFactoryUtils.beansOfTypeIncludingAncestors(lbf, DummyFactory.class, true, true);
assertThat(beans).hasSize(2);
@@ -191,7 +191,7 @@ public class BeanFactoryUtilsTests {
assertThat(beans.get("t1")).isEqualTo(t1);
assertThat(beans.get("t2")).isEqualTo(t2);
assertThat(beans.get("t3")).isEqualTo(t3.getObject());
assertThat(beans.get("t4") instanceof TestBean).isTrue();
assertThat(beans.get("t4")).isInstanceOf(TestBean.class);
// t3 and t4 are found here as of Spring 2.0, since they are pre-registered
// singleton instances, while testFactory1 and testFactory are *not* found
// because they are FactoryBean definitions that haven't been initialized yet.
@@ -210,11 +210,11 @@ public class BeanFactoryUtilsTests {
assertThat(beans.get("test3")).isEqualTo(test3);
assertThat(beans.get("test")).isEqualTo(test);
assertThat(beans.get("testFactory1")).isEqualTo(testFactory1);
assertThat(beans.get("testFactory2") instanceof TestBean).isTrue();
assertThat(beans.get("testFactory2")).isInstanceOf(TestBean.class);
assertThat(beans.get("t1")).isEqualTo(t1);
assertThat(beans.get("t2")).isEqualTo(t2);
assertThat(beans.get("t3")).isEqualTo(t3.getObject());
assertThat(beans.get("t4") instanceof TestBean).isTrue();
assertThat(beans.get("t4")).isInstanceOf(TestBean.class);
beans = BeanFactoryUtils.beansOfTypeIncludingAncestors(this.listableBeanFactory, DummyFactory.class, true, true);
assertThat(beans).hasSize(4);
@@ -257,7 +257,7 @@ public class BeanFactoryUtilsTests {
assertThat(beans.get("test3")).isEqualTo(test3);
assertThat(beans.get("test")).isEqualTo(test);
assertThat(beans.get("testFactory1")).isEqualTo(testFactory1);
assertThat(beans.get("testFactory2") instanceof TestBean).isTrue();
assertThat(beans.get("testFactory2")).isInstanceOf(TestBean.class);
beans = BeanFactoryUtils.beansOfTypeIncludingAncestors(this.listableBeanFactory, DummyFactory.class, true, true);
assertThat(beans).hasSize(2);

View File

@@ -85,7 +85,7 @@ public class InjectAnnotationBeanPostProcessorTests {
bf.getBean("testBean");
}
catch (BeanCreationException ex) {
assertThat(ex.getRootCause() instanceof IllegalStateException).isTrue();
assertThat(ex.getRootCause()).isInstanceOf(IllegalStateException.class);
}
}

View File

@@ -66,7 +66,7 @@ public class CustomScopeConfigurerTests {
CustomScopeConfigurer figurer = new CustomScopeConfigurer();
figurer.setScopes(scopes);
figurer.postProcessBeanFactory(factory);
assertThat(factory.getRegisteredScope(FOO_SCOPE) instanceof NoOpScope).isTrue();
assertThat(factory.getRegisteredScope(FOO_SCOPE)).isInstanceOf(NoOpScope.class);
}
@Test
@@ -76,7 +76,7 @@ public class CustomScopeConfigurerTests {
CustomScopeConfigurer figurer = new CustomScopeConfigurer();
figurer.setScopes(scopes);
figurer.postProcessBeanFactory(factory);
assertThat(factory.getRegisteredScope(FOO_SCOPE) instanceof NoOpScope).isTrue();
assertThat(factory.getRegisteredScope(FOO_SCOPE)).isInstanceOf(NoOpScope.class);
}
@Test

View File

@@ -49,7 +49,7 @@ public class PropertyPathFactoryBeanTests {
assertThat(xbf.getType("otb.spouse")).isEqualTo(ITestBean.class);
Object result1 = xbf.getBean("otb.spouse");
Object result2 = xbf.getBean("otb.spouse");
assertThat(result1 instanceof TestBean).isTrue();
assertThat(result1).isInstanceOf(TestBean.class);
assertThat(result1).isSameAs(result2);
assertThat(((TestBean) result1).getAge()).isEqualTo(99);
}
@@ -63,9 +63,9 @@ public class PropertyPathFactoryBeanTests {
Object result1 = xbf.getBean("tb.spouse");
Object result2 = xbf.getBean("propertyPath3");
Object result3 = xbf.getBean("propertyPath3");
assertThat(result1 instanceof TestBean).isTrue();
assertThat(result2 instanceof TestBean).isTrue();
assertThat(result3 instanceof TestBean).isTrue();
assertThat(result1).isInstanceOf(TestBean.class);
assertThat(result2).isInstanceOf(TestBean.class);
assertThat(result3).isInstanceOf(TestBean.class);
assertThat(((TestBean) result1).getAge()).isEqualTo(11);
assertThat(((TestBean) result2).getAge()).isEqualTo(11);
assertThat(((TestBean) result3).getAge()).isEqualTo(11);

View File

@@ -198,10 +198,10 @@ public class ServiceLocatorFactoryBeanTests {
assertThat(testBean3).isNotSameAs(testBean2);
assertThat(testBean4).isNotSameAs(testBean2);
assertThat(testBean4).isNotSameAs(testBean3);
assertThat(testBean1 instanceof ExtendedTestService).isFalse();
assertThat(testBean2 instanceof ExtendedTestService).isFalse();
assertThat(testBean3 instanceof ExtendedTestService).isFalse();
assertThat(testBean4 instanceof ExtendedTestService).isTrue();
assertThat(testBean1).isNotInstanceOf(ExtendedTestService.class);
assertThat(testBean2).isNotInstanceOf(ExtendedTestService.class);
assertThat(testBean3).isNotInstanceOf(ExtendedTestService.class);
assertThat(testBean4).isInstanceOf(ExtendedTestService.class);
}
@Test

View File

@@ -99,7 +99,7 @@ public class YamlMapFactoryBeanTests {
assertThat(map).hasSize(1);
assertThat(map.containsKey("foo")).isTrue();
Object object = map.get("foo");
assertThat(object instanceof LinkedHashMap).isTrue();
assertThat(object).isInstanceOf(LinkedHashMap.class);
@SuppressWarnings("unchecked")
Map<String, Object> sub = (Map<String, Object>) object;
assertThat(sub.containsKey("key1.key2")).isTrue();
@@ -114,7 +114,7 @@ public class YamlMapFactoryBeanTests {
assertThat(map).hasSize(1);
assertThat(map.containsKey("foo")).isTrue();
Object object = map.get("foo");
assertThat(object instanceof LinkedHashMap).isTrue();
assertThat(object).isInstanceOf(LinkedHashMap.class);
@SuppressWarnings("unchecked")
Map<String, Object> sub = (Map<String, Object>) object;
assertThat(sub).hasSize(1);

View File

@@ -48,7 +48,7 @@ class ServiceLoaderTests {
bd.getPropertyValues().add("serviceType", DocumentBuilderFactory.class.getName());
bf.registerBeanDefinition("service", bd);
ServiceLoader<?> serviceLoader = (ServiceLoader<?>) bf.getBean("service");
assertThat(serviceLoader.iterator().next() instanceof DocumentBuilderFactory).isTrue();
assertThat(serviceLoader).element(0).isInstanceOf(DocumentBuilderFactory.class);
}
@Test
@@ -57,7 +57,7 @@ class ServiceLoaderTests {
RootBeanDefinition bd = new RootBeanDefinition(ServiceFactoryBean.class);
bd.getPropertyValues().add("serviceType", DocumentBuilderFactory.class.getName());
bf.registerBeanDefinition("service", bd);
assertThat(bf.getBean("service") instanceof DocumentBuilderFactory).isTrue();
assertThat(bf.getBean("service")).isInstanceOf(DocumentBuilderFactory.class);
}
@Test
@@ -67,7 +67,7 @@ class ServiceLoaderTests {
bd.getPropertyValues().add("serviceType", DocumentBuilderFactory.class.getName());
bf.registerBeanDefinition("service", bd);
List<?> serviceList = (List<?>) bf.getBean("service");
assertThat(serviceList.get(0) instanceof DocumentBuilderFactory).isTrue();
assertThat(serviceList).element(0).isInstanceOf(DocumentBuilderFactory.class);
}
}

View File

@@ -66,7 +66,7 @@ public class CollectionMergingTests {
List<?> list = bean.getSomeList();
assertThat(list).isNotNull();
assertThat(list).hasSize(3);
assertThat(list.get(2) instanceof TestBean).isTrue();
assertThat(list.get(2)).isInstanceOf(TestBean.class);
}
@Test
@@ -87,7 +87,7 @@ public class CollectionMergingTests {
Iterator it = set.iterator();
it.next();
Object o = it.next();
assertThat(o instanceof TestBean).isTrue();
assertThat(o).isInstanceOf(TestBean.class);
assertThat(((TestBean) o).getName()).isEqualTo("Sally");
}
@@ -108,7 +108,7 @@ public class CollectionMergingTests {
assertThat(map).isNotNull();
assertThat(map).hasSize(2);
assertThat(map.get("Rob")).isNotNull();
assertThat(map.get("Rob") instanceof TestBean).isTrue();
assertThat(map.get("Rob")).isInstanceOf(TestBean.class);
assertThat(((TestBean) map.get("Rob")).getName()).isEqualTo("Sally");
}
@@ -139,7 +139,7 @@ public class CollectionMergingTests {
assertThat(list).isNotNull();
assertThat(list).hasSize(3);
assertThat(list).element(2).isNotNull();
assertThat(list.get(2) instanceof TestBean).isTrue();
assertThat(list.get(2)).isInstanceOf(TestBean.class);
}
@Test
@@ -160,7 +160,7 @@ public class CollectionMergingTests {
Iterator it = set.iterator();
it.next();
Object o = it.next();
assertThat(o instanceof TestBean).isTrue();
assertThat(o).isInstanceOf(TestBean.class);
assertThat(((TestBean) o).getName()).isEqualTo("Sally");
}
@@ -180,7 +180,7 @@ public class CollectionMergingTests {
Map<?, ?> map = bean.getSomeMap();
assertThat(map).isNotNull();
assertThat(map).hasSize(2);
assertThat(map.get("Rob") instanceof TestBean).isTrue();
assertThat(map.get("Rob")).isInstanceOf(TestBean.class);
assertThat(((TestBean) map.get("Rob")).getName()).isEqualTo("Sally");
}

View File

@@ -70,17 +70,17 @@ public class XmlBeanCollectionTests {
ListFactoryBean listFactory = new ListFactoryBean();
listFactory.setSourceList(new LinkedList());
listFactory.afterPropertiesSet();
assertThat(listFactory.getObject() instanceof ArrayList).isTrue();
assertThat(listFactory.getObject()).isInstanceOf(ArrayList.class);
SetFactoryBean setFactory = new SetFactoryBean();
setFactory.setSourceSet(new TreeSet());
setFactory.afterPropertiesSet();
assertThat(setFactory.getObject() instanceof LinkedHashSet).isTrue();
assertThat(setFactory.getObject()).isInstanceOf(LinkedHashSet.class);
MapFactoryBean mapFactory = new MapFactoryBean();
mapFactory.setSourceMap(new TreeMap());
mapFactory.afterPropertiesSet();
assertThat(mapFactory.getObject() instanceof LinkedHashMap).isTrue();
assertThat(mapFactory.getObject()).isInstanceOf(LinkedHashMap.class);
}
@Test
@@ -202,9 +202,9 @@ public class XmlBeanCollectionTests {
TestBean jenny = (TestBean) this.beanFactory.getBean("jenny");
assertThat(hasMap.getMap().get("jenny")).isSameAs(jenny);
assertThat(hasMap.getMap().get(5).equals("david")).isTrue();
assertThat(hasMap.getMap().get("bar") instanceof Long).isTrue();
assertThat(hasMap.getMap().get("bar")).isInstanceOf(Long.class);
assertThat(hasMap.getMap().get("bar").equals(100L)).isTrue();
assertThat(hasMap.getMap().get("baz") instanceof Integer).isTrue();
assertThat(hasMap.getMap().get("baz")).isInstanceOf(Integer.class);
assertThat(hasMap.getMap().get("baz").equals(200)).isTrue();
}
@@ -364,7 +364,7 @@ public class XmlBeanCollectionTests {
@Test
public void testListFactory() {
List list = (List) this.beanFactory.getBean("listFactory");
assertThat(list instanceof LinkedList).isTrue();
assertThat(list).isInstanceOf(LinkedList.class);
assertThat(list.size()).isEqualTo(2);
assertThat(list).element(0).isEqualTo("bar");
assertThat(list).element(1).isEqualTo("jenny");
@@ -373,7 +373,7 @@ public class XmlBeanCollectionTests {
@Test
public void testPrototypeListFactory() {
List list = (List) this.beanFactory.getBean("pListFactory");
assertThat(list instanceof LinkedList).isTrue();
assertThat(list).isInstanceOf(LinkedList.class);
assertThat(list.size()).isEqualTo(2);
assertThat(list).element(0).isEqualTo("bar");
assertThat(list).element(1).isEqualTo("jenny");
@@ -382,7 +382,7 @@ public class XmlBeanCollectionTests {
@Test
public void testSetFactory() {
Set set = (Set) this.beanFactory.getBean("setFactory");
assertThat(set instanceof TreeSet).isTrue();
assertThat(set).isInstanceOf(TreeSet.class);
assertThat(set.size()).isEqualTo(2);
assertThat(set.contains("bar")).isTrue();
assertThat(set.contains("jenny")).isTrue();
@@ -391,7 +391,7 @@ public class XmlBeanCollectionTests {
@Test
public void testPrototypeSetFactory() {
Set set = (Set) this.beanFactory.getBean("pSetFactory");
assertThat(set instanceof TreeSet).isTrue();
assertThat(set).isInstanceOf(TreeSet.class);
assertThat(set.size()).isEqualTo(2);
assertThat(set.contains("bar")).isTrue();
assertThat(set.contains("jenny")).isTrue();
@@ -400,7 +400,7 @@ public class XmlBeanCollectionTests {
@Test
public void testMapFactory() {
Map map = (Map) this.beanFactory.getBean("mapFactory");
assertThat(map instanceof TreeMap).isTrue();
assertThat(map).isInstanceOf(TreeMap.class);
assertThat(map.size()).isEqualTo(2);
assertThat(map.get("foo")).isEqualTo("bar");
assertThat(map.get("jen")).isEqualTo("jenny");
@@ -409,7 +409,7 @@ public class XmlBeanCollectionTests {
@Test
public void testPrototypeMapFactory() {
Map map = (Map) this.beanFactory.getBean("pMapFactory");
assertThat(map instanceof TreeMap).isTrue();
assertThat(map).isInstanceOf(TreeMap.class);
assertThat(map.size()).isEqualTo(2);
assertThat(map.get("foo")).isEqualTo("bar");
assertThat(map.get("jen")).isEqualTo("jenny");

View File

@@ -59,7 +59,7 @@ public class CustomCollectionEditorTests {
editor.setValue(new int[] {0, 1, 2});
Object value = editor.getValue();
assertThat(value).isNotNull();
assertThat(value instanceof ArrayList).isTrue();
assertThat(value).isInstanceOf(ArrayList.class);
List<?> list = (List<?>) value;
assertThat(list).as("There must be 3 elements in the converted collection").hasSize(3);
assertThat(list).element(0).isEqualTo(0);
@@ -83,7 +83,7 @@ public class CustomCollectionEditorTests {
editor.setValue("0, 1, 2");
Object value = editor.getValue();
assertThat(value).isNotNull();
assertThat(value instanceof ArrayList).isTrue();
assertThat(value).isInstanceOf(ArrayList.class);
List<?> list = (List<?>) value;
assertThat(list).as("There must be 1 element in the converted collection").hasSize(1);
assertThat(list).element(0).isEqualTo("0, 1, 2");

View File

@@ -39,7 +39,7 @@ public class FileEditorTests {
fileEditor.setAsText("classpath:" + ClassUtils.classPackageAsResourcePath(getClass()) + "/" +
ClassUtils.getShortName(getClass()) + ".class");
Object value = fileEditor.getValue();
assertThat(value instanceof File).isTrue();
assertThat(value).isInstanceOf(File.class);
File file = (File) value;
assertThat(file).exists();
}
@@ -56,7 +56,7 @@ public class FileEditorTests {
PropertyEditor fileEditor = new FileEditor();
fileEditor.setAsText("file:no_way_this_file_is_found.doc");
Object value = fileEditor.getValue();
assertThat(value instanceof File).isTrue();
assertThat(value).isInstanceOf(File.class);
File file = (File) value;
assertThat(file).doesNotExist();
}
@@ -66,7 +66,7 @@ public class FileEditorTests {
PropertyEditor fileEditor = new FileEditor();
fileEditor.setAsText("/no_way_this_file_is_found.doc");
Object value = fileEditor.getValue();
assertThat(value instanceof File).isTrue();
assertThat(value).isInstanceOf(File.class);
File file = (File) value;
assertThat(file).doesNotExist();
}
@@ -78,7 +78,7 @@ public class FileEditorTests {
ClassUtils.getShortName(getClass()) + ".class";
fileEditor.setAsText(fileName);
Object value = fileEditor.getValue();
assertThat(value instanceof File).isTrue();
assertThat(value).isInstanceOf(File.class);
File file = (File) value;
assertThat(file).exists();
String absolutePath = file.getAbsolutePath().replace('\\', '/');
@@ -92,7 +92,7 @@ public class FileEditorTests {
ClassUtils.getShortName(getClass()) + ".clazz";
fileEditor.setAsText(fileName);
Object value = fileEditor.getValue();
assertThat(value instanceof File).isTrue();
assertThat(value).isInstanceOf(File.class);
File file = (File) value;
assertThat(file).doesNotExist();
String absolutePath = file.getAbsolutePath().replace('\\', '/');

View File

@@ -50,7 +50,7 @@ public class InputStreamEditorTests {
editor.setAsText(resource);
Object value = editor.getValue();
assertThat(value).isNotNull();
assertThat(value instanceof InputStream).isTrue();
assertThat(value).isInstanceOf(InputStream.class);
stream = (InputStream) value;
assertThat(stream.available()).isGreaterThan(0);
}

View File

@@ -160,7 +160,7 @@ public class PropertiesEditorTests {
pe.setValue(map);
Object value = pe.getValue();
assertThat(value).isNotNull();
assertThat(value instanceof Properties).isTrue();
assertThat(value).isInstanceOf(Properties.class);
Properties props = (Properties) value;
assertThat(props).hasSize(3);
assertThat(props.getProperty("one")).isEqualTo("1");

View File

@@ -50,7 +50,7 @@ public class ReaderEditorTests {
editor.setAsText(resource);
Object value = editor.getValue();
assertThat(value).isNotNull();
assertThat(value instanceof Reader).isTrue();
assertThat(value).isInstanceOf(Reader.class);
reader = (Reader) value;
assertThat(reader.ready()).isTrue();
}

View File

@@ -56,7 +56,7 @@ public class URIEditorTests {
PropertyEditor uriEditor = new URIEditor();
uriEditor.setAsText(" https://www.springframework.org ");
Object value = uriEditor.getValue();
assertThat(value instanceof URI).isTrue();
assertThat(value).isInstanceOf(URI.class);
URI uri = (URI) value;
assertThat(uri.toString()).isEqualTo("https://www.springframework.org");
}
@@ -67,7 +67,7 @@ public class URIEditorTests {
uriEditor.setAsText("classpath:" + ClassUtils.classPackageAsResourcePath(getClass()) +
"/" + ClassUtils.getShortName(getClass()) + ".class");
Object value = uriEditor.getValue();
assertThat(value instanceof URI).isTrue();
assertThat(value).isInstanceOf(URI.class);
URI uri = (URI) value;
assertThat(uriEditor.getAsText()).isEqualTo(uri.toString());
assertThat(uri.getScheme()).doesNotStartWith("classpath");
@@ -79,7 +79,7 @@ public class URIEditorTests {
uriEditor.setAsText(" classpath:" + ClassUtils.classPackageAsResourcePath(getClass()) +
"/" + ClassUtils.getShortName(getClass()) + ".class ");
Object value = uriEditor.getValue();
assertThat(value instanceof URI).isTrue();
assertThat(value).isInstanceOf(URI.class);
URI uri = (URI) value;
assertThat(uriEditor.getAsText()).isEqualTo(uri.toString());
assertThat(uri.getScheme()).doesNotStartWith("classpath");
@@ -90,7 +90,7 @@ public class URIEditorTests {
PropertyEditor uriEditor = new URIEditor();
uriEditor.setAsText("classpath:test.txt");
Object value = uriEditor.getValue();
assertThat(value instanceof URI).isTrue();
assertThat(value).isInstanceOf(URI.class);
URI uri = (URI) value;
assertThat(uriEditor.getAsText()).isEqualTo(uri.toString());
assertThat(uri.getScheme()).startsWith("classpath");
@@ -115,7 +115,7 @@ public class URIEditorTests {
PropertyEditor uriEditor = new URIEditor();
uriEditor.setAsText("https://example.com/spaces and \u20AC");
Object value = uriEditor.getValue();
assertThat(value instanceof URI).isTrue();
assertThat(value).isInstanceOf(URI.class);
URI uri = (URI) value;
assertThat(uriEditor.getAsText()).isEqualTo(uri.toString());
assertThat(uri.toASCIIString()).isEqualTo("https://example.com/spaces%20and%20%E2%82%AC");
@@ -126,7 +126,7 @@ public class URIEditorTests {
PropertyEditor uriEditor = new URIEditor(false);
uriEditor.setAsText("https://example.com/spaces%20and%20%E2%82%AC");
Object value = uriEditor.getValue();
assertThat(value instanceof URI).isTrue();
assertThat(value).isInstanceOf(URI.class);
URI uri = (URI) value;
assertThat(uriEditor.getAsText()).isEqualTo(uri.toString());
assertThat(uri.toASCIIString()).isEqualTo("https://example.com/spaces%20and%20%E2%82%AC");
@@ -137,7 +137,7 @@ public class URIEditorTests {
PropertyEditor uriEditor = new URIEditor();
uriEditor.setAsText(uriSpec);
Object value = uriEditor.getValue();
assertThat(value instanceof URI).isTrue();
assertThat(value).isInstanceOf(URI.class);
URI uri = (URI) value;
assertThat(uri.toString()).isEqualTo(uriSpec);
}

View File

@@ -43,7 +43,7 @@ public class URLEditorTests {
PropertyEditor urlEditor = new URLEditor();
urlEditor.setAsText("mailto:juergen.hoeller@interface21.com");
Object value = urlEditor.getValue();
assertThat(value instanceof URL).isTrue();
assertThat(value).isInstanceOf(URL.class);
URL url = (URL) value;
assertThat(urlEditor.getAsText()).isEqualTo(url.toExternalForm());
}
@@ -53,7 +53,7 @@ public class URLEditorTests {
PropertyEditor urlEditor = new URLEditor();
urlEditor.setAsText("https://www.springframework.org");
Object value = urlEditor.getValue();
assertThat(value instanceof URL).isTrue();
assertThat(value).isInstanceOf(URL.class);
URL url = (URL) value;
assertThat(urlEditor.getAsText()).isEqualTo(url.toExternalForm());
}
@@ -64,7 +64,7 @@ public class URLEditorTests {
urlEditor.setAsText("classpath:" + ClassUtils.classPackageAsResourcePath(getClass()) +
"/" + ClassUtils.getShortName(getClass()) + ".class");
Object value = urlEditor.getValue();
assertThat(value instanceof URL).isTrue();
assertThat(value).isInstanceOf(URL.class);
URL url = (URL) value;
assertThat(urlEditor.getAsText()).isEqualTo(url.toExternalForm());
assertThat(url.getProtocol()).doesNotStartWith("classpath");

View File

@@ -49,12 +49,12 @@ public class HibernateEntityManagerFactoryIntegrationTests extends AbstractConta
@Test
public void testCanCastNativeEntityManagerFactoryToHibernateEntityManagerFactoryImpl() {
EntityManagerFactoryInfo emfi = (EntityManagerFactoryInfo) entityManagerFactory;
assertThat(emfi.getNativeEntityManagerFactory() instanceof SessionFactory).isTrue();
assertThat(emfi.getNativeEntityManagerFactory()).isInstanceOf(SessionFactory.class);
}
@Test
public void testCanCastSharedEntityManagerProxyToHibernateEntityManager() {
assertThat(((EntityManagerProxy) sharedEntityManager).getTargetEntityManager() instanceof Session).isTrue();
assertThat(((EntityManagerProxy) sharedEntityManager).getTargetEntityManager()).isInstanceOf(Session.class);
}
@Test

View File

@@ -199,8 +199,8 @@ public class AnnotationDrivenBeanDefinitionParserTests {
assertThat(value).isNotNull();
assertThat(value).isInstanceOf(List.class);
List<ResponseBodyAdvice<?>> converters = (List<ResponseBodyAdvice<?>>) value;
assertThat(converters.get(0) instanceof JsonViewRequestBodyAdvice).isTrue();
assertThat(converters.get(1) instanceof JsonViewResponseBodyAdvice).isTrue();
assertThat(converters).element(0).isInstanceOf(JsonViewRequestBodyAdvice.class);
assertThat(converters).element(1).isInstanceOf(JsonViewResponseBodyAdvice.class);
}
}