Skip to content

Commit

Permalink
Add tests for compact ErrorCause (#133) (#134)
Browse files Browse the repository at this point in the history
Co-authored-by: Sylvain Wallez <[email protected]>
  • Loading branch information
github-actions[bot] and swallez authored Jan 25, 2022
1 parent 6072518 commit c0df6d2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,8 @@ public JsonpMapper mapper() {
public ElasticsearchClient client() {
return client;
}

public ElasticsearchAsyncClient asyncClient() {
return new ElasticsearchAsyncClient(client._transport(), client._transportOptions());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package co.elastic.clients.elasticsearch.spec_issues;

import co.elastic.clients.elasticsearch.ElasticsearchTestServer;
import co.elastic.clients.elasticsearch._types.ErrorResponse;
import co.elastic.clients.elasticsearch.cluster.ClusterStatsResponse;
import co.elastic.clients.elasticsearch.core.SearchRequest;
import co.elastic.clients.elasticsearch.core.SearchResponse;
Expand Down Expand Up @@ -61,7 +62,17 @@ public void i0087_filterAggSubAggregation() {
resp.aggregations().get("login_filter").filter()
.aggregations().get("to_domain").sterms()
.buckets().array().get(0).key());
}

@Test
public void i0080_simpleError() {
// https://github.com/elastic/elasticsearch-java/issues/80
// When requesting a missing index, the error response in compact format.
// Fixed by adding ErrorCause.reason as a shortcut property
String json = "{\"error\":\"alias [not-existing-alias] missing\",\"status\":404}";
ErrorResponse err = fromJson(json, ErrorResponse.class);

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

@Test
Expand Down

0 comments on commit c0df6d2

Please sign in to comment.