|
39 | 39 | import java.util.concurrent.Future;
|
40 | 40 | import java.util.stream.Collectors;
|
41 | 41 |
|
42 |
| -import com.couchbase.client.java.kv.UpsertOptions; |
43 | 42 | import org.junit.jupiter.api.BeforeEach;
|
44 | 43 | import org.junit.jupiter.api.Test;
|
45 | 44 | import org.springframework.beans.factory.annotation.Autowired;
|
|
89 | 88 | import com.couchbase.client.java.json.JsonArray;
|
90 | 89 | import com.couchbase.client.java.kv.GetResult;
|
91 | 90 | import com.couchbase.client.java.kv.MutationState;
|
| 91 | +import com.couchbase.client.java.kv.UpsertOptions; |
92 | 92 | import com.couchbase.client.java.query.QueryOptions;
|
93 | 93 | import com.couchbase.client.java.query.QueryScanConsistency;
|
94 | 94 |
|
@@ -188,9 +188,9 @@ void annotatedFieldFindName() {
|
188 | 188 | Person person2 = personRepository.findById(person.getId().toString()).get();
|
189 | 189 | assertEquals(person.getSalutation(), person2.getSalutation());
|
190 | 190 | // needs fix from datacouch_1184
|
191 |
| - //List<Person> persons3 = personRepository.findBySalutation("Mrs"); |
192 |
| - //assertEquals(1, persons3.size()); |
193 |
| - //assertEquals(person.getSalutation(), persons3.get(0).getSalutation()); |
| 191 | + // List<Person> persons3 = personRepository.findBySalutation("Mrs"); |
| 192 | + // assertEquals(1, persons3.size()); |
| 193 | + // assertEquals(person.getSalutation(), persons3.get(0).getSalutation()); |
194 | 194 | } finally {
|
195 | 195 | personRepository.deleteById(person.getId().toString());
|
196 | 196 | }
|
@@ -476,13 +476,13 @@ void count() {
|
476 | 476 | }
|
477 | 477 | }
|
478 | 478 |
|
479 |
| - @Test |
480 |
| - void badCount(){ |
| 479 | + @Test |
| 480 | + void badCount() { |
481 | 481 | assertThrows(CouchbaseQueryExecutionException.class, () -> airportRepository.countBad());
|
482 | 482 | }
|
483 | 483 |
|
484 |
| - @Test |
485 |
| - void goodCount(){ |
| 484 | + @Test |
| 485 | + void goodCount() { |
486 | 486 | airportRepository.countGood();
|
487 | 487 | }
|
488 | 488 |
|
@@ -528,6 +528,38 @@ void threadSafeParametersTest() throws Exception {
|
528 | 528 | }
|
529 | 529 | }
|
530 | 530 |
|
| 531 | + @Test |
| 532 | + void distinct() { |
| 533 | + String[] iatas = { "JFK", "IAD", "SFO", "SJC", "SEA", "LAX", "PHX" }; |
| 534 | + String[] icaos = { "ic0", "ic1", "ic0", "ic1", "ic0", "ic1", "ic0" }; |
| 535 | + |
| 536 | + try { |
| 537 | + for (int i = 0; i < iatas.length; i++) { |
| 538 | + Airport airport = new Airport("airports::" + iatas[i], iatas[i] /*iata*/, icaos[i] /* icao */); |
| 539 | + couchbaseTemplate.insertById(Airport.class).one(airport); |
| 540 | + } |
| 541 | + |
| 542 | + // distinct icao - parser requires 'By' on the end or it does not match pattern. |
| 543 | + List<Airport> airports1 = airportRepository.findDistinctIcaoBy(); |
| 544 | + assertEquals(2, airports1.size()); |
| 545 | + |
| 546 | + List<Airport> airports2 = airportRepository.findDistinctIcaoAndIataBy(); |
| 547 | + assertEquals(7, airports2.size()); |
| 548 | + |
| 549 | + // count( distinct { iata, icao } ) |
| 550 | + long count1 = airportRepository.countDistinctIcaoAndIataBy(); |
| 551 | + assertEquals(7, count1); |
| 552 | + |
| 553 | + // count( distinct { icao } ) |
| 554 | + long count2 = airportRepository.countDistinctIcaoBy(); |
| 555 | + assertEquals(2, count2); |
| 556 | + |
| 557 | + } finally { |
| 558 | + couchbaseTemplate.removeById() |
| 559 | + .all(Arrays.stream(iatas).map((iata) -> "airports::" + iata).collect(Collectors.toSet())); |
| 560 | + } |
| 561 | + } |
| 562 | + |
531 | 563 | @Test
|
532 | 564 | void stringQueryTest() throws Exception {
|
533 | 565 | Airport airport = new Airport("airports::vie", "vie", "lowx");
|
|
0 commit comments