Skip to content

Commit

Permalink
Add missing test annotation and fix the failing test it hid
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Widdis <[email protected]>
  • Loading branch information
dbwiddis committed Oct 16, 2024
1 parent 696b7ba commit 2af5d23
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -639,10 +639,9 @@ public void testSearchDataObject_Exception() throws IOException {
.searchSourceBuilder(searchSourceBuilder)
.build();

ArgumentCaptor<SearchRequest> searchRequestCaptor = ArgumentCaptor.forClass(SearchRequest.class);
PlainActionFuture<SearchResponse> exceptionalFuture = PlainActionFuture.newFuture();
exceptionalFuture.onFailure(new UnsupportedOperationException("test"));
when(mockedClient.search(searchRequestCaptor.capture())).thenReturn(exceptionalFuture);
when(mockedClient.search(any(SearchRequest.class))).thenReturn(exceptionalFuture);

CompletableFuture<SearchDataObjectResponse> future = sdkClient
.searchDataObjectAsync(searchRequest, testThreadPool.executor(GENERAL_THREAD_POOL))
Expand Down Expand Up @@ -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);
Expand All @@ -686,7 +686,11 @@ public void testSearchDataObject_NullTenantNoMultitenancy() throws IOException {
// null tenant Id
.searchSourceBuilder(searchSourceBuilder)
.build();


PlainActionFuture<SearchResponse> exceptionalFuture = PlainActionFuture.newFuture();
exceptionalFuture.onFailure(new UnsupportedOperationException("test"));
when(mockedClient.search(any(SearchRequest.class))).thenReturn(exceptionalFuture);

CompletableFuture<SearchDataObjectResponse> future = sdkClientNoTenant
.searchDataObjectAsync(searchRequest, testThreadPool.executor(GENERAL_THREAD_POOL))
.toCompletableFuture();
Expand Down

0 comments on commit 2af5d23

Please sign in to comment.