From b7570ffa957254d114e161cf73e173135fb3ee54 Mon Sep 17 00:00:00 2001 From: Peter-Josef Meisch Date: Sat, 24 Jun 2023 09:39:22 +0200 Subject: [PATCH] Polishing --- ...ustomMethodRepositoryIntegrationTests.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/test/java/org/springframework/data/elasticsearch/repositories/custommethod/CustomMethodRepositoryIntegrationTests.java b/src/test/java/org/springframework/data/elasticsearch/repositories/custommethod/CustomMethodRepositoryIntegrationTests.java index 522c14e0f..c593a42a1 100644 --- a/src/test/java/org/springframework/data/elasticsearch/repositories/custommethod/CustomMethodRepositoryIntegrationTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/repositories/custommethod/CustomMethodRepositoryIntegrationTests.java @@ -1582,6 +1582,41 @@ public abstract class CustomMethodRepositoryIntegrationTests { assertThat(searchHits.getSearchHit(2).getId()).isEqualTo("oslo"); } + @Test // #2601 + void shouldUseGeoSortReverseParameter() { + GeoPoint munich = new GeoPoint(48.137154, 11.5761247); + GeoPoint berlin = new GeoPoint(52.520008, 13.404954); + GeoPoint vienna = new GeoPoint(48.20849, 16.37208); + GeoPoint oslo = new GeoPoint(59.9127, 10.7461); + + List entities = new ArrayList<>(); + + SampleEntity entity1 = new SampleEntity(); + entity1.setId("berlin"); + entity1.setLocation(berlin); + entities.add(entity1); + + SampleEntity entity2 = new SampleEntity(); + entity2.setId("vienna"); + entity2.setLocation(vienna); + entities.add(entity2); + + SampleEntity entity3 = new SampleEntity(); + entity3.setId("oslo"); + entity3.setLocation(oslo); + entities.add(entity3); + + repository.saveAll(entities); + + SearchHits searchHits = repository + .searchBy(Sort.by(new GeoDistanceOrder("location", munich).with(Sort.Direction.DESC))); + + assertThat(searchHits.getTotalHits()).isEqualTo(3); + assertThat(searchHits.getSearchHit(0).getId()).isEqualTo("oslo"); + assertThat(searchHits.getSearchHit(1).getId()).isEqualTo("berlin"); + assertThat(searchHits.getSearchHit(2).getId()).isEqualTo("vienna"); + } + @Test // DATAES-749 void shouldReturnSearchPage() { List entities = createSampleEntities("abc", 20);