From feb03da166df43b87f1ebbba78e39907e193014e Mon Sep 17 00:00:00 2001 From: Mikhail Berezovskiy Date: Fri, 29 Aug 2025 12:30:01 -0700 Subject: [PATCH 1/3] test:nit incremental bulk missing content --- .../rest/action/document/RestBulkActionTests.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/rest/action/document/RestBulkActionTests.java b/server/src/test/java/org/elasticsearch/rest/action/document/RestBulkActionTests.java index 0b3e50974a827..902ba2f075477 100644 --- a/server/src/test/java/org/elasticsearch/rest/action/document/RestBulkActionTests.java +++ b/server/src/test/java/org/elasticsearch/rest/action/document/RestBulkActionTests.java @@ -47,6 +47,7 @@ import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.instanceOf; import static org.mockito.Mockito.mock; /** @@ -204,9 +205,8 @@ public void bulk(BulkRequest request, ActionListener listener) { } public void testIncrementalBulkMissingContent() { - assertThrows( - ElasticsearchParseException.class, - () -> new RestBulkAction( + try { + new RestBulkAction( Settings.EMPTY, ClusterSettings.createBuiltInClusterSettings(), new IncrementalBulkService(mock(Client.class), mock(IndexingPressure.class), MeterRegistry.NOOP) @@ -217,8 +217,12 @@ public void testIncrementalBulkMissingContent() { .build(), mock(RestChannel.class), mock(NodeClient.class) - ) - ); + ); + assert false : "must throw"; + } catch (Exception e) { + assertThat(e, instanceOf(ElasticsearchParseException.class)); + assertEquals("request body is required", e.getMessage()); + } } public void testIncrementalParsing() { From 7803ac33f4bacdd8182dba34cd01248ac6cdad47 Mon Sep 17 00:00:00 2001 From: Mikhail Berezovskiy Date: Tue, 2 Sep 2025 10:20:09 -0700 Subject: [PATCH 2/3] re-arrange --- .../action/document/RestBulkActionTests.java | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/rest/action/document/RestBulkActionTests.java b/server/src/test/java/org/elasticsearch/rest/action/document/RestBulkActionTests.java index 7f4c6d1fdd0ac..307ed52a032cb 100644 --- a/server/src/test/java/org/elasticsearch/rest/action/document/RestBulkActionTests.java +++ b/server/src/test/java/org/elasticsearch/rest/action/document/RestBulkActionTests.java @@ -49,6 +49,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.instanceOf; +import static org.junit.Assert.assertThrows; import static org.mockito.Mockito.mock; /** @@ -206,24 +207,24 @@ public void bulk(BulkRequest request, ActionListener listener) { } public void testIncrementalBulkMissingContent() { - try { - new RestBulkAction( - Settings.EMPTY, - ClusterSettings.createBuiltInClusterSettings(), - new IncrementalBulkService(mock(Client.class), mock(IndexingPressure.class), MeterRegistry.NOOP) - ).handleRequest( - new FakeRestRequest.Builder(xContentRegistry()).withPath("my_index/_bulk") - .withContentLength(0) - .withBody(new FakeHttpBodyStream()) - .build(), - mock(RestChannel.class), - mock(NodeClient.class) - ); - assert false : "must throw"; - } catch (Exception e) { - assertThat(e, instanceOf(ElasticsearchParseException.class)); - assertEquals("request body is required", e.getMessage()); - } + assertEquals( + "request body is required", + assertThrows( + ElasticsearchParseException.class, + () -> new RestBulkAction( + Settings.EMPTY, + ClusterSettings.createBuiltInClusterSettings(), + new IncrementalBulkService(mock(Client.class), mock(IndexingPressure.class), MeterRegistry.NOOP) + ).handleRequest( + new FakeRestRequest.Builder(xContentRegistry()).withPath("my_index/_bulk") + .withContentLength(0) + .withBody(new FakeHttpBodyStream()) + .build(), + mock(RestChannel.class), + mock(NodeClient.class) + ) + ).getMessage() + ); } public void testIncrementalParsing() { From 2687ba06db506e3413fa6d978a46c4fd4cfb0299 Mon Sep 17 00:00:00 2001 From: elasticsearchmachine Date: Tue, 2 Sep 2025 17:27:20 +0000 Subject: [PATCH 3/3] [CI] Auto commit changes from spotless --- .../elasticsearch/rest/action/document/RestBulkActionTests.java | 1 - 1 file changed, 1 deletion(-) diff --git a/server/src/test/java/org/elasticsearch/rest/action/document/RestBulkActionTests.java b/server/src/test/java/org/elasticsearch/rest/action/document/RestBulkActionTests.java index 307ed52a032cb..8bf4ee5c9cf1c 100644 --- a/server/src/test/java/org/elasticsearch/rest/action/document/RestBulkActionTests.java +++ b/server/src/test/java/org/elasticsearch/rest/action/document/RestBulkActionTests.java @@ -48,7 +48,6 @@ import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.Matchers.instanceOf; import static org.junit.Assert.assertThrows; import static org.mockito.Mockito.mock;