Skip to content

Commit eae5ae5

Browse files
committed
Update tests while ES|QL parsing is fixed
See elastic/elasticsearch-java#903
1 parent 578a950 commit eae5ae5

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

src/test/java/fr/pilato/test/elasticsearch/hlclient/EsClientIT.java

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import co.elastic.clients.elasticsearch.transform.GetTransformResponse;
4545
import co.elastic.clients.elasticsearch.transform.PutTransformResponse;
4646
import co.elastic.clients.json.JsonData;
47+
import co.elastic.clients.json.JsonpMappingException;
4748
import co.elastic.clients.json.jackson.JacksonJsonpMapper;
4849
import co.elastic.clients.transport.ElasticsearchTransport;
4950
import co.elastic.clients.transport.TransportException;
@@ -431,7 +432,7 @@ void rangeQuery() throws IOException {
431432
client.indices().refresh(rr -> rr.index(indexName));
432433
SearchResponse<ObjectNode> response = client.search(sr -> sr.index(indexName)
433434
.query(q -> q.range(rq -> rq
434-
.number(nrq -> nrq.field("foo").from(0.0).to(1.0))
435+
.number(nrq -> nrq.field("foo").gt(0.0).lt(1.0))
435436
))
436437
, ObjectNode.class);
437438
assertNotNull(response.hits().total());
@@ -924,28 +925,39 @@ void esql() throws IOException, SQLException {
924925

925926
// Using the Raw ES|QL API
926927
try (BinaryResponse response = client.esql().query(q -> q.query(query)); InputStream is = response.content()) {
927-
// The response object is {"columns":[{"name":"country","type":"text"}],"values":[["france"]]}
928+
// The response object is {"took":5,"columns":[{"name":"name","type":"text"}],"values":[["David"]]}
928929
ObjectMapper mapper = new ObjectMapper();
929930
JsonNode node = mapper.readTree(is);
930931
assertNotNull(node);
931-
assertEquals(2, node.size());
932+
assertEquals(3, node.size());
932933
assertEquals(1, node.get("columns").size());
933934
assertEquals("name", node.get("columns").get(0).get("name").asText());
934935
assertEquals(1, node.get("values").size());
935936
assertEquals("David", node.get("values").get(0).get(0).asText());
937+
assertTrue(node.get("took").asInt() > 0);
936938
}
937939

938940
// Using the JDBC ResultSet ES|QL API
941+
// And this is now failing because of https://github.com/elastic/elasticsearch-java/pull/903
939942
try (ResultSet resultSet = client.esql().query(ResultSetEsqlAdapter.INSTANCE, query)) {
943+
fail("https://github.com/elastic/elasticsearch-java/pull/903 have been fixed. Update the code.");
940944
assertTrue(resultSet.next());
941945
assertEquals("David", resultSet.getString(1));
946+
} catch (JsonpMappingException e) {
947+
// This is expected as we have this issue https://github.com/elastic/elasticsearch-java/pull/903
942948
}
943949

944950
// Using the Object ES|QL API
945-
Iterable<Person> persons = client.esql().query(ObjectsEsqlAdapter.of(Person.class), query);
946-
for (Person person : persons) {
947-
assertNull(person.getId());
948-
assertNotNull(person.getName());
951+
// And this is now failing because of https://github.com/elastic/elasticsearch-java/pull/903
952+
try {
953+
Iterable<Person> persons = client.esql().query(ObjectsEsqlAdapter.of(Person.class), query);
954+
fail("https://github.com/elastic/elasticsearch-java/pull/903 have been fixed. Update the code.");
955+
for (Person person : persons) {
956+
assertNull(person.getId());
957+
assertNotNull(person.getName());
958+
}
959+
} catch (JsonpMappingException e) {
960+
// This is expected as we have this issue https://github.com/elastic/elasticsearch-java/pull/903
949961
}
950962
}
951963

0 commit comments

Comments
 (0)