|
28 | 28 | import reactor.test.StepVerifier;
|
29 | 29 |
|
30 | 30 | import java.util.Arrays;
|
31 |
| -import java.util.Collections; |
32 | 31 | import java.util.Map;
|
33 | 32 | import java.util.stream.IntStream;
|
34 | 33 |
|
@@ -214,7 +213,7 @@ void shouldDeleteUsingQueryMethod() {
|
214 | 213 | .verifyComplete();
|
215 | 214 |
|
216 | 215 | Map<String, Object> count = jdbc.queryForMap("SELECT count(*) AS count FROM legoset");
|
217 |
| - assertThat(count).hasEntrySatisfying("count", numberOf(1)); |
| 216 | + assertThat(getCount(count)).satisfies(numberOf(1)); |
218 | 217 | }
|
219 | 218 |
|
220 | 219 | @Test // gh-335
|
@@ -293,11 +292,13 @@ public void shouldInsertItemsTransactional() {
|
293 | 292 | Mono<Map<String, Object>> nonTransactional = repository.save(legoSet2) //
|
294 | 293 | .map(it -> jdbc.queryForMap("SELECT count(*) AS count FROM legoset"));
|
295 | 294 |
|
296 |
| - transactional.as(StepVerifier::create).expectNext(Collections.singletonMap("count", 0L)).verifyComplete(); |
297 |
| - nonTransactional.as(StepVerifier::create).expectNext(Collections.singletonMap("count", 2L)).verifyComplete(); |
| 295 | + transactional.as(StepVerifier::create).assertNext(actual -> assertThat(getCount(actual)).satisfies(numberOf(0))) |
| 296 | + .verifyComplete(); |
| 297 | + nonTransactional.as(StepVerifier::create).assertNext(actual -> assertThat(getCount(actual)).satisfies(numberOf(2))) |
| 298 | + .verifyComplete(); |
298 | 299 |
|
299 |
| - Map<String, Object> count = jdbc.queryForMap("SELECT count(*) AS count FROM legoset"); |
300 |
| - assertThat(count).hasEntrySatisfying("count", numberOf(2)); |
| 300 | + Map<String, Object> map = jdbc.queryForMap("SELECT count(*) AS count FROM legoset"); |
| 301 | + assertThat(getCount(map)).satisfies(numberOf(2)); |
301 | 302 | }
|
302 | 303 |
|
303 | 304 | @Test // gh-363
|
@@ -353,6 +354,10 @@ void shouldDeleteAllAndReturnCount() {
|
353 | 354 | .verifyComplete();
|
354 | 355 | }
|
355 | 356 |
|
| 357 | + private static Object getCount(Map<String, Object> map) { |
| 358 | + return map.getOrDefault("count", map.get("COUNT")); |
| 359 | + } |
| 360 | + |
356 | 361 | private Condition<? super Object> numberOf(int expected) {
|
357 | 362 | return new Condition<>(it -> {
|
358 | 363 | return it instanceof Number && ((Number) it).intValue() == expected;
|
|
0 commit comments