Skip to content

Commit 61370d0

Browse files
committed
integration test style changed: try/catch -> expectThrows
1 parent e886fd3 commit 61370d0

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

server/src/test/java/org/elasticsearch/search/sort/FieldSortIT.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,20 +1487,20 @@ public void testNestedSort() throws IOException, InterruptedException, Execution
14871487
assertThat(hits[0].getSortValues()[0], is("bar"));
14881488
assertThat(hits[1].getSortValues()[0], is("abc"));
14891489

1490-
try {
1491-
client().prepareSearch()
1492-
.setQuery(matchAllQuery())
1493-
.addSort(SortBuilders
1494-
.fieldSort("nested.bar.foo")
1495-
.setNestedSort(new NestedSortBuilder("nested")
1496-
.setNestedSort(new NestedSortBuilder("nested.bar")
1497-
.setMaxChildren(1)))
1498-
.order(SortOrder.DESC))
1499-
.get();
1500-
} catch (SearchPhaseExecutionException e) {
1501-
for (ShardSearchFailure shardSearchFailure : e.shardFailures()) {
1502-
assertThat(shardSearchFailure.toString(), containsString("[max_children is only supported on top level of nested sort]"));
1503-
}
1490+
{
1491+
SearchPhaseExecutionException exc = expectThrows(SearchPhaseExecutionException.class,
1492+
() -> client().prepareSearch()
1493+
.setQuery(matchAllQuery())
1494+
.addSort(SortBuilders
1495+
.fieldSort("nested.bar.foo")
1496+
.setNestedSort(new NestedSortBuilder("nested")
1497+
.setNestedSort(new NestedSortBuilder("nested.bar")
1498+
.setMaxChildren(1)))
1499+
.order(SortOrder.DESC))
1500+
.get()
1501+
);
1502+
assertThat(exc.toString(),
1503+
containsString("max_children is only supported on top level of nested sort"));
15041504
}
15051505

15061506
// We sort on nested sub field

0 commit comments

Comments
 (0)