Skip to content

Commit c0df6d2

Browse files
Add tests for compact ErrorCause (#133) (#134)
Co-authored-by: Sylvain Wallez <[email protected]>
1 parent 6072518 commit c0df6d2

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

java-client/src/test/java/co/elastic/clients/elasticsearch/ElasticsearchTestServer.java

+4
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,8 @@ public JsonpMapper mapper() {
108108
public ElasticsearchClient client() {
109109
return client;
110110
}
111+
112+
public ElasticsearchAsyncClient asyncClient() {
113+
return new ElasticsearchAsyncClient(client._transport(), client._transportOptions());
114+
}
111115
}

java-client/src/test/java/co/elastic/clients/elasticsearch/spec_issues/SpecIssuesTest.java

+11
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package co.elastic.clients.elasticsearch.spec_issues;
2121

2222
import co.elastic.clients.elasticsearch.ElasticsearchTestServer;
23+
import co.elastic.clients.elasticsearch._types.ErrorResponse;
2324
import co.elastic.clients.elasticsearch.cluster.ClusterStatsResponse;
2425
import co.elastic.clients.elasticsearch.core.SearchRequest;
2526
import co.elastic.clients.elasticsearch.core.SearchResponse;
@@ -61,7 +62,17 @@ public void i0087_filterAggSubAggregation() {
6162
resp.aggregations().get("login_filter").filter()
6263
.aggregations().get("to_domain").sterms()
6364
.buckets().array().get(0).key());
65+
}
66+
67+
@Test
68+
public void i0080_simpleError() {
69+
// https://github.com/elastic/elasticsearch-java/issues/80
70+
// When requesting a missing index, the error response in compact format.
71+
// Fixed by adding ErrorCause.reason as a shortcut property
72+
String json = "{\"error\":\"alias [not-existing-alias] missing\",\"status\":404}";
73+
ErrorResponse err = fromJson(json, ErrorResponse.class);
6474

75+
assertEquals("alias [not-existing-alias] missing", err.error().reason());
6576
}
6677

6778
@Test

0 commit comments

Comments
 (0)