fix test
This commit is contained in:
parent
8bd915a004
commit
20f8a2dbf3
|
@ -7,12 +7,14 @@
|
|||
package org.hibernate.orm.test.jpa.cascade2;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.TransientObjectException;
|
||||
|
||||
import org.hibernate.TransientObjectException;
|
||||
import org.hibernate.TransientPropertyValueException;
|
||||
import org.hibernate.orm.test.jpa.model.AbstractJPATest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.hibernate.testing.orm.junit.ExtraAssertions.assertTyping;
|
||||
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
|
@ -65,6 +67,7 @@ public class CascadeTest extends AbstractJPATest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testManyToOneGeneratedIds() {
|
||||
// NOTES: Child defines a many-to-one back to its Parent. This
|
||||
// association does not define persist cascading (which is natural;
|
||||
|
@ -80,8 +83,9 @@ public class CascadeTest extends AbstractJPATest {
|
|||
s.getTransaction().commit();
|
||||
fail( "expecting TransientObjectException on flush" );
|
||||
}
|
||||
catch (TransientObjectException e) {
|
||||
catch (IllegalStateException e) {
|
||||
// expected result
|
||||
assertInstanceOf( TransientPropertyValueException.class, e.getCause() );
|
||||
s.getTransaction().rollback();
|
||||
}
|
||||
finally {
|
||||
|
@ -95,6 +99,7 @@ public class CascadeTest extends AbstractJPATest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testManyToOneAssignedIds() {
|
||||
// NOTES: Child defines a many-to-one back to its Parent. This
|
||||
// association does not define persist cascading (which is natural;
|
||||
|
@ -110,8 +115,9 @@ public class CascadeTest extends AbstractJPATest {
|
|||
s.getTransaction().commit();
|
||||
fail( "expecting TransientObjectException on flush" );
|
||||
}
|
||||
catch (TransientObjectException e) {
|
||||
catch (IllegalStateException e) {
|
||||
// expected result
|
||||
assertInstanceOf( TransientPropertyValueException.class, e.getCause() );
|
||||
s.getTransaction().rollback();
|
||||
}
|
||||
finally {
|
||||
|
@ -125,6 +131,7 @@ public class CascadeTest extends AbstractJPATest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOneToOneGeneratedIds() {
|
||||
try (Session s = sessionFactory().openSession()) {
|
||||
try {
|
||||
|
@ -138,8 +145,9 @@ public class CascadeTest extends AbstractJPATest {
|
|||
s.getTransaction().commit();
|
||||
fail( "expecting TransientObjectException on flush" );
|
||||
}
|
||||
catch (TransientObjectException e) {
|
||||
catch (IllegalStateException e) {
|
||||
// expected result
|
||||
assertInstanceOf( TransientPropertyValueException.class, e.getCause() );
|
||||
s.getTransaction().rollback();
|
||||
}
|
||||
finally {
|
||||
|
@ -153,6 +161,7 @@ public class CascadeTest extends AbstractJPATest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOneToOneAssignedIds() {
|
||||
try (Session s = sessionFactory().openSession()) {
|
||||
try {
|
||||
|
@ -166,8 +175,9 @@ public class CascadeTest extends AbstractJPATest {
|
|||
s.getTransaction().commit();
|
||||
fail( "expecting TransientObjectException on flush" );
|
||||
}
|
||||
catch (TransientObjectException e) {
|
||||
catch (IllegalStateException e) {
|
||||
// expected result
|
||||
assertInstanceOf( TransientPropertyValueException.class, e.getCause() );
|
||||
s.getTransaction().rollback();
|
||||
}
|
||||
finally {
|
||||
|
@ -181,6 +191,7 @@ public class CascadeTest extends AbstractJPATest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testManyToOnePropertyRefGeneratedIds() {
|
||||
try (Session s = sessionFactory().openSession()) {
|
||||
s.beginTransaction();
|
||||
|
@ -192,8 +203,9 @@ public class CascadeTest extends AbstractJPATest {
|
|||
s.getTransaction().commit();
|
||||
fail( "expecting TransientObjectException on flush" );
|
||||
}
|
||||
catch (TransientObjectException e) {
|
||||
catch (IllegalStateException e) {
|
||||
// expected result
|
||||
assertInstanceOf( TransientPropertyValueException.class, e.getCause() );
|
||||
s.getTransaction().rollback();
|
||||
}
|
||||
finally {
|
||||
|
@ -207,6 +219,7 @@ public class CascadeTest extends AbstractJPATest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testManyToOnePropertyRefAssignedIds() {
|
||||
try (Session s = sessionFactory().openSession()) {
|
||||
s.beginTransaction();
|
||||
|
@ -218,8 +231,9 @@ public class CascadeTest extends AbstractJPATest {
|
|||
s.getTransaction().commit();
|
||||
fail( "expecting TransientObjectException on flush" );
|
||||
}
|
||||
catch (TransientObjectException e) {
|
||||
catch (IllegalStateException e) {
|
||||
// expected result
|
||||
assertInstanceOf( TransientPropertyValueException.class, e.getCause() );
|
||||
s.getTransaction().rollback();
|
||||
}
|
||||
finally {
|
||||
|
@ -233,6 +247,7 @@ public class CascadeTest extends AbstractJPATest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOneToOnePropertyRefGeneratedIds() {
|
||||
try (Session s = sessionFactory().openSession()) {
|
||||
s.beginTransaction();
|
||||
|
@ -245,8 +260,9 @@ public class CascadeTest extends AbstractJPATest {
|
|||
s.getTransaction().commit();
|
||||
fail( "expecting TransientObjectException on flush" );
|
||||
}
|
||||
catch (TransientObjectException e) {
|
||||
catch (IllegalStateException e) {
|
||||
// expected result
|
||||
assertInstanceOf( TransientPropertyValueException.class, e.getCause() );
|
||||
s.getTransaction().rollback();
|
||||
}
|
||||
finally {
|
||||
|
@ -260,6 +276,7 @@ public class CascadeTest extends AbstractJPATest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOneToOnePropertyRefAssignedIds() {
|
||||
try (Session s = sessionFactory().openSession()) {
|
||||
s.beginTransaction();
|
||||
|
@ -272,8 +289,9 @@ public class CascadeTest extends AbstractJPATest {
|
|||
s.getTransaction().commit();
|
||||
fail( "expecting TransientObjectException on flush" );
|
||||
}
|
||||
catch (TransientObjectException e) {
|
||||
catch (IllegalStateException e) {
|
||||
// expected result
|
||||
assertInstanceOf( TransientPropertyValueException.class, e.getCause() );
|
||||
s.getTransaction().rollback();
|
||||
}
|
||||
finally {
|
||||
|
|
Loading…
Reference in New Issue