diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SearchDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SearchDocumentationIT.java index 6c78c88eeec66..780f315876996 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SearchDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SearchDocumentationIT.java @@ -337,8 +337,9 @@ public void testSearchRequestAggregations() throws IOException { Range range = aggregations.get("by_company"); // <1> // end::search-request-aggregations-get-wrongCast } catch (ClassCastException ex) { - assertEquals("org.elasticsearch.search.aggregations.bucket.terms.ParsedStringTerms" - + " cannot be cast to org.elasticsearch.search.aggregations.bucket.range.Range", ex.getMessage()); + String message = ex.getMessage(); + assertThat(message, containsString("org.elasticsearch.search.aggregations.bucket.terms.ParsedStringTerms")); + assertThat(message, containsString("org.elasticsearch.search.aggregations.bucket.range.Range")); } assertEquals(3, elasticBucket.getDocCount()); assertEquals(30, avg, 0.0);