Skip to content

Commit 73fc897

Browse files
Fixing tests
1 parent 69ab6d8 commit 73fc897

File tree

2 files changed

+30
-19
lines changed

2 files changed

+30
-19
lines changed

x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/SenderServiceTests.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,21 @@ public void testReturnsValidationException_WhenQueryIsNullForRerankTaskType() th
116116
var model = mock(Model.class);
117117
when(model.getTaskType()).thenReturn(TaskType.RERANK);
118118

119-
PlainActionFuture<InferenceServiceResults> listener = new PlainActionFuture<>();
120-
121-
testService.infer(model, null, null, null, List.of("test input"), false, Map.of(), InputType.SEARCH, null, listener);
122-
var exception = expectThrows(ValidationException.class, () -> listener.actionGet(TIMEOUT));
119+
var exception = expectThrows(
120+
ValidationException.class,
121+
() -> testService.infer(
122+
model,
123+
null,
124+
null,
125+
null,
126+
List.of("test input"),
127+
false,
128+
Map.of(),
129+
InputType.SEARCH,
130+
null,
131+
new PlainActionFuture<>()
132+
)
133+
);
123134

124135
assertThat(exception.getMessage(), containsString("Rerank task type requires a non-null query field"));
125136
}

x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/cohere/CohereServiceTests.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -899,23 +899,23 @@ public void testInfer_ReturnsValidationException_WhenSendingRerankRequest_Withou
899899
new DefaultSecretSettings(new SecureString(secret.toCharArray()))
900900
);
901901

902-
PlainActionFuture<InferenceServiceResults> listener = new PlainActionFuture<>();
903-
service.infer(
904-
model,
905-
// null query string will trigger validation error
906-
null,
907-
null,
908-
null,
909-
List.of("abc"),
910-
false,
911-
new HashMap<>(),
912-
InputType.INGEST,
913-
InferenceAction.Request.DEFAULT_TIMEOUT,
914-
listener
902+
var exception = expectThrows(
903+
ValidationException.class,
904+
() -> service.infer(
905+
model,
906+
// null query string will trigger validation error
907+
null,
908+
null,
909+
null,
910+
List.of("abc"),
911+
false,
912+
new HashMap<>(),
913+
InputType.INGEST,
914+
InferenceAction.Request.DEFAULT_TIMEOUT,
915+
new PlainActionFuture<>()
916+
)
915917
);
916918

917-
var exception = expectThrows(ValidationException.class, () -> listener.actionGet(TIMEOUT));
918-
919919
assertThat(exception.getMessage(), containsString("Rerank task type requires a non-null query field"));
920920
}
921921
}

0 commit comments

Comments
 (0)