From 2af5d236dbb69a3526537501b1f5ac1766385421 Mon Sep 17 00:00:00 2001 From: Daniel Widdis Date: Wed, 16 Oct 2024 10:12:49 -0700 Subject: [PATCH] Add missing test annotation and fix the failing test it hid Signed-off-by: Daniel Widdis --- .../sdk/client/LocalClusterIndicesClientTests.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/common/src/test/java/org/opensearch/sdk/client/LocalClusterIndicesClientTests.java b/common/src/test/java/org/opensearch/sdk/client/LocalClusterIndicesClientTests.java index 52efe8eea9..fdc78aa819 100644 --- a/common/src/test/java/org/opensearch/sdk/client/LocalClusterIndicesClientTests.java +++ b/common/src/test/java/org/opensearch/sdk/client/LocalClusterIndicesClientTests.java @@ -639,10 +639,9 @@ public void testSearchDataObject_Exception() throws IOException { .searchSourceBuilder(searchSourceBuilder) .build(); - ArgumentCaptor searchRequestCaptor = ArgumentCaptor.forClass(SearchRequest.class); PlainActionFuture exceptionalFuture = PlainActionFuture.newFuture(); exceptionalFuture.onFailure(new UnsupportedOperationException("test")); - when(mockedClient.search(searchRequestCaptor.capture())).thenReturn(exceptionalFuture); + when(mockedClient.search(any(SearchRequest.class))).thenReturn(exceptionalFuture); CompletableFuture future = sdkClient .searchDataObjectAsync(searchRequest, testThreadPool.executor(GENERAL_THREAD_POOL)) @@ -675,6 +674,7 @@ public void testSearchDataObject_NullTenantId() throws IOException { assertEquals("Tenant ID is required when multitenancy is enabled.", cause.getMessage()); } + @Test public void testSearchDataObject_NullTenantNoMultitenancy() throws IOException { // Tests no status exception if multitenancy not enabled SdkClient sdkClientNoTenant = new SdkClient(new LocalClusterIndicesClient(mockedClient, xContentRegistry), false); @@ -686,7 +686,11 @@ public void testSearchDataObject_NullTenantNoMultitenancy() throws IOException { // null tenant Id .searchSourceBuilder(searchSourceBuilder) .build(); - + + PlainActionFuture exceptionalFuture = PlainActionFuture.newFuture(); + exceptionalFuture.onFailure(new UnsupportedOperationException("test")); + when(mockedClient.search(any(SearchRequest.class))).thenReturn(exceptionalFuture); + CompletableFuture future = sdkClientNoTenant .searchDataObjectAsync(searchRequest, testThreadPool.executor(GENERAL_THREAD_POOL)) .toCompletableFuture();