31
31
import org .junit .Test ;
32
32
33
33
import io .vertx .ext .unit .TestContext ;
34
+ import org .assertj .core .api .Assertions ;
34
35
35
36
import static org .hibernate .reactive .containers .DatabaseConfiguration .DBType .COCKROACHDB ;
36
37
import static org .hibernate .tool .schema .JdbcMetadaAccessStrategy .GROUPED ;
@@ -103,6 +104,8 @@ public void testValidationSucceed(TestContext context) {
103
104
104
105
@ Test
105
106
public void testUpdate (TestContext context ) {
107
+ // this test checks that the correct indexes and foreign constraints have been created
108
+ // by looking at the content of the pg_catalog schema using the following native queries.
106
109
final String indexDefinitionQuery =
107
110
"select indexdef from pg_indexes where schemaname = 'public' and tablename = ? order by indexname" ;
108
111
@@ -154,31 +157,19 @@ public void testUpdate(TestContext context) {
154
157
.thenCompose ( v -> s .createNativeQuery ( indexDefinitionQuery , String .class )
155
158
.setParameter ( 1 , "asimple" )
156
159
.getResultList ()
157
- .thenAccept ( list -> {
158
- context .assertEquals (
159
- "CREATE INDEX i_asimple_avalue_astringvalue ON postgres.public.asimple USING btree (avalue ASC, astringvalue DESC)" ,
160
- list .get ( 0 )
161
- );
162
- context .assertEquals (
163
- "CREATE INDEX i_asimple_avalue_data ON postgres.public.asimple USING btree (avalue DESC, data ASC)" ,
164
- list .get ( 1 )
165
- );
166
- context .assertEquals (
167
- "CREATE UNIQUE INDEX \" primary\" ON postgres.public.asimple USING btree (id ASC)" ,
168
- list .get ( 2 )
169
- );
170
- context .assertEquals (
171
- "CREATE UNIQUE INDEX u_asimple_astringvalue ON postgres.public.asimple USING btree (astringvalue ASC)" ,
172
- list .get ( 3 )
173
- );
174
- } )
160
+ .thenAccept ( list -> Assertions .assertThat ( list ).containsExactlyInAnyOrder (
161
+ "CREATE INDEX i_asimple_avalue_astringvalue ON postgres.public.asimple USING btree (avalue ASC, astringvalue DESC)" ,
162
+ "CREATE INDEX i_asimple_avalue_data ON postgres.public.asimple USING btree (avalue DESC, data ASC)" ,
163
+ "CREATE UNIQUE INDEX asimple_pkey ON postgres.public.asimple USING btree (id ASC)" ,
164
+ "CREATE UNIQUE INDEX u_asimple_astringvalue ON postgres.public.asimple USING btree (astringvalue ASC)"
165
+ ) )
175
166
)
176
167
.thenCompose ( v -> s .createNativeQuery ( indexDefinitionQuery , String .class )
177
168
.setParameter ( 1 , "aother" )
178
169
.getSingleResult ()
179
170
.thenAccept ( result ->
180
171
context .assertEquals (
181
- "CREATE UNIQUE INDEX \" primary \" ON postgres.public.aother USING btree (id1 ASC, id2 ASC)" ,
172
+ "CREATE UNIQUE INDEX aother_pkey ON postgres.public.aother USING btree (id1 ASC, id2 ASC)" ,
182
173
result
183
174
)
184
175
)
@@ -188,12 +179,11 @@ public void testUpdate(TestContext context) {
188
179
.getSingleResult ()
189
180
.thenAccept ( result ->
190
181
context .assertEquals (
191
- "CREATE UNIQUE INDEX \" primary \" ON postgres.public.aanother USING btree (id ASC)" ,
182
+ "CREATE UNIQUE INDEX aanother_pkey ON postgres.public.aanother USING btree (id ASC)" ,
192
183
result
193
184
)
194
185
)
195
186
)
196
- // check foreign keys
197
187
.thenCompose ( v -> s .createNativeQuery (
198
188
foreignKeyDefinitionQuery ,
199
189
String .class
0 commit comments