Skip to content

Commit c85d54c

Browse files
committed
defines sort
1 parent 9db03e5 commit c85d54c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

elasticsearch-driver/src/test/java/org/eclipse/jnosql/diana/elasticsearch/document/ElasticsearchDocumentCollectionManagerTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,28 @@ public void shouldFindOrderByName() throws InterruptedException {
188188
.toArray(String[]::new);
189189

190190
assertArrayEquals(names, new String[]{"otavio", "poliana"});
191+
}
192+
193+
@Test
194+
public void shouldFindOrderByNameDesc() throws InterruptedException {
195+
final DocumentEntity poliana = DocumentEntityGerator.getEntity();
196+
final DocumentEntity otavio = DocumentEntityGerator.getEntity();
197+
poliana.add("name", "poliana");
198+
otavio.add("name", "otavio");
199+
otavio.add("_id", "id2");
200+
entityManager.insert(Arrays.asList(poliana, otavio));
201+
SECONDS.sleep(1L);
202+
DocumentQuery query = DocumentQuery.select().from("person").orderBy("name").desc().build();
203+
String[] names = entityManager.select(query).map(d -> d.find("name"))
204+
.filter(Optional::isPresent)
205+
.map(Optional::get)
206+
.map(d -> d.get(String.class))
207+
.toArray(String[]::new);
191208

209+
assertArrayEquals(names, new String[]{"poliana", "otavio"});
192210
}
193211

212+
194213
@Test
195214
public void shouldFindAll() throws InterruptedException {
196215
entityManager.insert(DocumentEntityGerator.getEntity());

0 commit comments

Comments
 (0)