Skip to content

[Backport 7.17] Add tests for compact ErrorCause #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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