|
31 | 31 | import java.lang.Long;
|
32 | 32 | import java.lang.Object;
|
33 | 33 | import java.net.ConnectException;
|
| 34 | +import java.time.LocalDate; |
| 35 | +import java.time.format.DateTimeFormatter; |
34 | 36 | import java.util.Arrays;
|
35 | 37 | import java.util.Collections;
|
36 | 38 | import java.util.LinkedHashMap;
|
|
49 | 51 | import org.junit.jupiter.api.AfterEach;
|
50 | 52 | import org.junit.jupiter.api.BeforeEach;
|
51 | 53 | import org.junit.jupiter.api.Test;
|
52 |
| - |
53 | 54 | import org.springframework.dao.DataAccessResourceFailureException;
|
54 | 55 | import org.springframework.dao.OptimisticLockingFailureException;
|
55 | 56 | import org.springframework.data.annotation.Id;
|
@@ -524,7 +525,8 @@ public void aggregateShouldReturnAggregations() {
|
524 | 525 |
|
525 | 526 | @Test // DATAES-567, DATAES-767
|
526 | 527 | public void aggregateShouldErrorWhenIndexDoesNotExist() {
|
527 |
| - template.aggregate(new CriteriaQuery(Criteria.where("message").is("some message")), SampleEntity.class, |
| 528 | + template |
| 529 | + .aggregate(new CriteriaQuery(Criteria.where("message").is("some message")), SampleEntity.class, |
528 | 530 | IndexCoordinates.of("no-such-index")) //
|
529 | 531 | .as(StepVerifier::create) //
|
530 | 532 | .expectError(ElasticsearchStatusException.class);
|
@@ -981,6 +983,28 @@ public Person(String name, int age) {
|
981 | 983 |
|
982 | 984 | // --> JUST some helpers
|
983 | 985 |
|
| 986 | + @Test // #1665 |
| 987 | + void shouldBeAbleToProcessDateMathIndexNames() { |
| 988 | + |
| 989 | + String indexName = "foo-" + LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy.MM")); |
| 990 | + String dateMathIndexName = "<foo-{now/M{yyyy.MM}}>"; |
| 991 | + |
| 992 | + SampleEntity entity = randomEntity("foo"); |
| 993 | + |
| 994 | + template.save(entity, IndexCoordinates.of(dateMathIndexName)) // |
| 995 | + .as(StepVerifier::create) // |
| 996 | + .expectNext(entity) // |
| 997 | + .verifyComplete(); // |
| 998 | + |
| 999 | + template.get(entity.getId(), SampleEntity.class, IndexCoordinates.of(indexName)) // |
| 1000 | + .as(StepVerifier::create) // |
| 1001 | + .expectNext(entity) // |
| 1002 | + .verifyComplete(); // |
| 1003 | + |
| 1004 | + } |
| 1005 | + // endregion |
| 1006 | + |
| 1007 | + // region Helper functions |
984 | 1008 | private SampleEntity randomEntity(String message) {
|
985 | 1009 |
|
986 | 1010 | return SampleEntity.builder() //
|
|
0 commit comments