3838import org .opensearch .action .search .SearchRequest ;
3939import org .opensearch .action .search .SearchResponse ;
4040import org .opensearch .cluster .metadata .MappingMetadata ;
41+ import org .opensearch .common .settings .Settings ;
42+ import org .opensearch .common .util .concurrent .ThreadContext ;
4143import org .opensearch .common .xcontent .XContentType ;
4244import org .opensearch .core .action .ActionListener ;
4345import org .opensearch .core .common .bytes .BytesReference ;
5254import org .opensearch .search .aggregations .bucket .sampler .InternalSampler ;
5355import org .opensearch .search .aggregations .metrics .InternalTopHits ;
5456import org .opensearch .search .builder .SearchSourceBuilder ;
57+ import org .opensearch .threadpool .ThreadPool ;
5558import org .opensearch .transport .client .AdminClient ;
5659import org .opensearch .transport .client .Client ;
5760import org .opensearch .transport .client .IndicesAdminClient ;
@@ -68,9 +71,14 @@ private Client setupBasicClientMocks() {
6871 Client client = mock (Client .class );
6972 AdminClient adminClient = mock (AdminClient .class );
7073 IndicesAdminClient indicesAdminClient = mock (IndicesAdminClient .class );
74+ ThreadPool threadPool = mock (ThreadPool .class );
75+ Settings settings = Settings .builder ().build ();
76+ ThreadContext threadContext = new ThreadContext (settings );
7177
7278 when (client .admin ()).thenReturn (adminClient );
7379 when (adminClient .indices ()).thenReturn (indicesAdminClient );
80+ when (client .threadPool ()).thenReturn (threadPool );
81+ when (threadPool .getThreadContext ()).thenReturn (threadContext );
7482
7583 return client ;
7684 }
@@ -184,6 +192,8 @@ public void testRunTask_WithEmptyMappings() {
184192
185193 when (getMappingsResponse .getMappings ()).thenReturn (new HashMap <>());
186194 setupGetMappingsCall (client , getMappingsResponse );
195+ sdkClient = mock (SdkClient .class );
196+ mockUpdateSuccess (sdkClient );
187197
188198 StatisticalDataTask task = new StatisticalDataTask ("test-index" , client , sdkClient );
189199 task .runTask ("tenant-id" , listener );
0 commit comments