8
8
import org .hibernate .boot .registry .StandardServiceRegistryBuilder ;
9
9
import org .hibernate .cfg .Configuration ;
10
10
import org .hibernate .reactive .BaseReactiveTest ;
11
+ import org .hibernate .reactive .annotations .EnabledFor ;
11
12
import org .hibernate .reactive .testing .SqlStatementTracker ;
12
13
13
14
import org .junit .jupiter .api .BeforeEach ;
26
27
27
28
import static java .util .concurrent .TimeUnit .MINUTES ;
28
29
import static org .assertj .core .api .Assertions .assertThat ;
30
+ import static org .hibernate .reactive .containers .DatabaseConfiguration .DBType .POSTGRESQL ;
29
31
30
32
/**
31
33
* Test the stateless session actually execute the operations in batch.
@@ -85,7 +87,7 @@ protected void addServices(StandardServiceRegistryBuilder builder) {
85
87
}
86
88
87
89
private static boolean filter (String s ) {
88
- String [] accepted = { "insert " , "update " , "delete " };
90
+ String [] accepted = { "merge " , " insert " , "update " , "delete " };
89
91
for ( String valid : accepted ) {
90
92
if ( s .toLowerCase ().startsWith ( valid ) ) {
91
93
return true ;
@@ -94,6 +96,66 @@ private static boolean filter(String s) {
94
96
return false ;
95
97
}
96
98
99
+ @ Test
100
+ @ EnabledFor (POSTGRESQL )
101
+ public void testMutinyMergeUpsertAll (VertxTestContext context ) {
102
+ test ( context , getMutinySessionFactory ()
103
+ .withStatelessTransaction ( s -> s .upsertAll ( PIGS ) )
104
+ .invoke ( () -> assertSqlLogTracker ( "merge into pig as t using (.*)" ) )
105
+ .chain ( () -> Uni .createFrom ().completionStage ( assertExpectedResult ( PIGS ) ) )
106
+ );
107
+ }
108
+
109
+ @ Test
110
+ @ EnabledFor (POSTGRESQL )
111
+ public void testMutinyMergeUpsertAllWithBatchSize (VertxTestContext context ) {
112
+ test ( context , getMutinySessionFactory ()
113
+ .withStatelessTransaction ( s -> s .upsertAll ( 10 , PIGS ) )
114
+ .invoke ( () -> assertSqlLogTracker ( "merge into pig as t using (.*)" ) )
115
+ .chain ( () -> Uni .createFrom ().completionStage ( assertExpectedResult ( PIGS ) ) )
116
+ );
117
+ }
118
+
119
+ @ Test
120
+ @ EnabledFor (POSTGRESQL )
121
+ public void testMutinyMergeUpsertMultiple (VertxTestContext context ) {
122
+ test ( context , getMutinySessionFactory ()
123
+ .withStatelessTransaction ( s -> s .upsertMultiple ( List .of ( PIGS ) ) )
124
+ .invoke ( () -> assertSqlLogTracker ( "merge into pig as t using (.*)" ) )
125
+ .chain ( () -> Uni .createFrom ().completionStage ( assertExpectedResult ( PIGS ) ) )
126
+ );
127
+ }
128
+
129
+ @ Test
130
+ @ EnabledFor (POSTGRESQL )
131
+ public void testStageMergeUpsertAll (VertxTestContext context ) {
132
+ test ( context , getSessionFactory ()
133
+ .withStatelessTransaction ( s -> s .upsertAll ( PIGS ) )
134
+ .thenRun ( () -> assertSqlLogTracker ( "merge into pig as t using (.*)" ) )
135
+ .thenCompose ( v -> assertExpectedResult ( PIGS ) )
136
+ );
137
+ }
138
+
139
+ @ Test
140
+ @ EnabledFor (POSTGRESQL )
141
+ public void testStageMergeUpsertAllWithBatchSize (VertxTestContext context ) {
142
+ test ( context , getSessionFactory ()
143
+ .withStatelessTransaction ( s -> s .upsertAll ( 10 , PIGS ) )
144
+ .thenRun (() -> assertSqlLogTracker ( "merge into pig as t using (.*)" ) )
145
+ .thenCompose ( v -> assertExpectedResult ( PIGS ) )
146
+ );
147
+ }
148
+
149
+ @ Test
150
+ @ EnabledFor (POSTGRESQL )
151
+ public void testStageMergeUpsertMultiple (VertxTestContext context ) {
152
+ test ( context , getSessionFactory ()
153
+ .withStatelessTransaction ( s -> s .upsertMultiple ( List .of ( PIGS ) ) )
154
+ .thenRun ( () -> assertSqlLogTracker ( "merge into pig as t using (.*)" ) )
155
+ .thenCompose ( v -> assertExpectedResult ( PIGS ) )
156
+ );
157
+ }
158
+
97
159
@ Test
98
160
public void testMutinyBatchingInsert (VertxTestContext context ) {
99
161
test ( context , getMutinySessionFactory ()
0 commit comments