mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-17 08:24:13 +00:00
Polishing
This commit is contained in:
+4
-7
@@ -49,8 +49,7 @@ public abstract class AbstractContainerEntityManagerFactoryIntegrationTests
|
||||
|
||||
@Test
|
||||
protected void testEntityManagerFactoryImplementsEntityManagerFactoryInfo() {
|
||||
boolean condition = entityManagerFactory instanceof EntityManagerFactoryInfo;
|
||||
assertThat(condition).as("Must have introduced config interface").isTrue();
|
||||
assertThat(entityManagerFactory).isInstanceOf(EntityManagerFactoryInfo.class);
|
||||
EntityManagerFactoryInfo emfi = (EntityManagerFactoryInfo) entityManagerFactory;
|
||||
assertThat(emfi.getPersistenceUnitName()).isEqualTo("Person");
|
||||
assertThat(emfi.getPersistenceUnitInfo()).as("PersistenceUnitInfo must be available").isNotNull();
|
||||
@@ -172,8 +171,8 @@ public abstract class AbstractContainerEntityManagerFactoryIntegrationTests
|
||||
|
||||
@Test
|
||||
void testEntityManagerProxyRejectsProgrammaticTxManagement() {
|
||||
assertThatIllegalStateException().as("Should not be able to create transactions on container managed EntityManager").isThrownBy(
|
||||
sharedEntityManager::getTransaction);
|
||||
assertThatIllegalStateException().as("Should not be able to create transactions on container managed EntityManager")
|
||||
.isThrownBy(sharedEntityManager::getTransaction);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -234,9 +233,7 @@ public abstract class AbstractContainerEntityManagerFactoryIntegrationTests
|
||||
q.setFlushMode(FlushModeType.AUTO);
|
||||
List<Person> people = q.getResultList();
|
||||
assertThat(people).isEmpty();
|
||||
assertThatException()
|
||||
.isThrownBy(q::getSingleResult)
|
||||
.withMessageContaining("closed");
|
||||
assertThatException().isThrownBy(q::getSingleResult).withMessageContaining("closed");
|
||||
// We would typically expect an IllegalStateException, but Hibernate throws a
|
||||
// PersistenceException. So we assert the contents of the exception message instead.
|
||||
|
||||
|
||||
+2
-4
@@ -88,8 +88,7 @@ class EntityManagerFactoryUtilsTests {
|
||||
IllegalStateException ise = new IllegalStateException();
|
||||
DataAccessException dex = EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(ise);
|
||||
assertThat(dex.getCause()).isSameAs(ise);
|
||||
boolean condition = dex instanceof InvalidDataAccessApiUsageException;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(dex).isInstanceOf(InvalidDataAccessApiUsageException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -97,8 +96,7 @@ class EntityManagerFactoryUtilsTests {
|
||||
IllegalArgumentException iae = new IllegalArgumentException();
|
||||
DataAccessException dex = EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(iae);
|
||||
assertThat(dex.getCause()).isSameAs(iae);
|
||||
boolean condition = dex instanceof InvalidDataAccessApiUsageException;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(dex).isInstanceOf(InvalidDataAccessApiUsageException.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-2
@@ -39,8 +39,7 @@ class EclipseLinkEntityManagerFactoryIntegrationTests extends AbstractContainerE
|
||||
|
||||
@Test
|
||||
void testCanCastSharedEntityManagerProxyToEclipseLinkEntityManager() {
|
||||
boolean condition = sharedEntityManager instanceof JpaEntityManager;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(sharedEntityManager).isInstanceOf(JpaEntityManager.class);
|
||||
JpaEntityManager eclipselinkEntityManager = (JpaEntityManager) sharedEntityManager;
|
||||
assertThat(eclipselinkEntityManager.getActiveSession()).isNotNull();
|
||||
}
|
||||
|
||||
+1
-2
@@ -48,8 +48,7 @@ class HibernateMultiEntityManagerFactoryIntegrationTests extends AbstractContain
|
||||
@Override
|
||||
@Test
|
||||
protected void testEntityManagerFactoryImplementsEntityManagerFactoryInfo() {
|
||||
boolean condition = this.entityManagerFactory instanceof EntityManagerFactoryInfo;
|
||||
assertThat(condition).as("Must have introduced config interface").isTrue();
|
||||
assertThat(this.entityManagerFactory).isInstanceOf(EntityManagerFactoryInfo.class);
|
||||
EntityManagerFactoryInfo emfi = (EntityManagerFactoryInfo) this.entityManagerFactory;
|
||||
assertThat(emfi.getPersistenceUnitName()).isEqualTo("Drivers");
|
||||
assertThat(emfi.getPersistenceUnitInfo()).as("PersistenceUnitInfo must be available").isNotNull();
|
||||
|
||||
Reference in New Issue
Block a user