Skip to content

Commit 1fd0b14

Browse files
committed
Fixing some tests.
1 parent d4d1d08 commit 1fd0b14

File tree

1 file changed

+17
-1
lines changed
  • x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql

1 file changed

+17
-1
lines changed

x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.apache.lucene.sandbox.document.HalfFloatPoint;
1212
import org.apache.lucene.util.BytesRef;
1313
import org.elasticsearch.ExceptionsHelper;
14+
import org.elasticsearch.action.ActionListener;
1415
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
1516
import org.elasticsearch.cluster.service.ClusterService;
1617
import org.elasticsearch.common.Strings;
@@ -149,6 +150,8 @@
149150
import static org.hamcrest.Matchers.instanceOf;
150151
import static org.junit.Assert.assertNotNull;
151152
import static org.junit.Assert.assertNull;
153+
import static org.mockito.ArgumentMatchers.any;
154+
import static org.mockito.Mockito.doAnswer;
152155
import static org.mockito.Mockito.mock;
153156

154157
public final class EsqlTestUtils {
@@ -377,9 +380,22 @@ public static LogicalOptimizerContext unboundLogicalOptimizerContext() {
377380
mock(ClusterService.class),
378381
mock(IndexNameExpressionResolver.class),
379382
null,
380-
mock(InferenceService.class)
383+
mockInferenceService()
381384
);
382385

386+
@SuppressWarnings("unchecked")
387+
private static InferenceService mockInferenceService() {
388+
InferenceService inferenceService = mock(InferenceService.class);
389+
doAnswer(
390+
i -> {
391+
i.getArgument(1, ActionListener.class).onResponse(emptyInferenceResolution());
392+
return null;
393+
}
394+
).when(inferenceService).resolveInferences(any(), any());
395+
396+
return inferenceService;
397+
}
398+
383399
private EsqlTestUtils() {}
384400

385401
public static Configuration configuration(QueryPragmas pragmas, String query) {

0 commit comments

Comments
 (0)