|
9 | 9 | import java.util.Collection; |
10 | 10 | import java.util.List; |
11 | 11 |
|
| 12 | +import org.hibernate.HibernateException; |
12 | 13 | import org.hibernate.annotations.SQLDelete; |
13 | 14 | import org.hibernate.annotations.SQLInsert; |
14 | 15 | import org.hibernate.annotations.SQLUpdate; |
15 | 16 | import org.hibernate.reactive.testing.DBSelectionExtension; |
| 17 | +import org.hibernate.reactive.testing.ReactiveAssertions; |
16 | 18 |
|
17 | 19 | import org.junit.jupiter.api.Assertions; |
18 | 20 | import org.junit.jupiter.api.BeforeEach; |
|
29 | 31 | import jakarta.persistence.Table; |
30 | 32 |
|
31 | 33 | import static java.util.concurrent.TimeUnit.MINUTES; |
| 34 | +import static org.assertj.core.api.Assertions.assertThat; |
32 | 35 | import static org.hibernate.reactive.containers.DatabaseConfiguration.DBType.POSTGRESQL; |
33 | 36 | import static org.hibernate.reactive.testing.DBSelectionExtension.runOnlyFor; |
34 | 37 | import static org.junit.jupiter.api.Assertions.assertEquals; |
@@ -102,6 +105,22 @@ public void populateDb(VertxTestContext context) { |
102 | 105 | ); |
103 | 106 | } |
104 | 107 |
|
| 108 | + @Test |
| 109 | + public void testFailureWithGetSingleResultOrNull(VertxTestContext context) { |
| 110 | + test( context, ReactiveAssertions.assertThrown( HibernateException.class, getMutinySessionFactory() |
| 111 | + .withTransaction( s -> s.createNativeQuery( INSERT_SP_SQL ).getSingleResultOrNull() ) ) |
| 112 | + .invoke( e -> assertThat( e ).hasMessageContainingAll( "HR000080:", INSERT_SP_SQL ) ) |
| 113 | + ); |
| 114 | + } |
| 115 | + |
| 116 | + @Test |
| 117 | + public void testFailureWithGetSingleResult(VertxTestContext context) { |
| 118 | + test( context, ReactiveAssertions.assertThrown( HibernateException.class, getSessionFactory() |
| 119 | + .withTransaction( s -> s.createNativeQuery( INSERT_SP_SQL ).getSingleResult() ) ) |
| 120 | + .thenAccept( e -> assertThat( e ).hasMessageContainingAll( "HR000080:", INSERT_SP_SQL ) ) |
| 121 | + ); |
| 122 | + } |
| 123 | + |
105 | 124 | @Test |
106 | 125 | public void testInsertStoredProcedure(VertxTestContext context) { |
107 | 126 | test( context, openSession().thenCompose( session -> session |
|
0 commit comments