Skip to content

Commit c8c74d6

Browse files
fix tests
1 parent 2eae767 commit c8c74d6

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/action/HuggingFaceActionCreatorTests.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,11 +358,14 @@ public void testSend_FailsFromInvalidResponseFormat_ForRerankAction() throws IOE
358358

359359
private void assertRerankActionCreator(List<String> documents, String query, int topN, boolean returnText) throws IOException {
360360
assertThat(webServer.requests(), hasSize(1));
361-
assertNull(webServer.requests().getFirst().getUri().getQuery());
362-
assertThat(webServer.requests().getFirst().getHeader(HttpHeaders.CONTENT_TYPE), equalTo(XContentType.JSON.mediaType()));
363-
assertThat(webServer.requests().getFirst().getHeader(HttpHeaders.AUTHORIZATION), equalTo("Bearer secret"));
361+
assertNull(webServer.requests().get(0).getUri().getQuery());
362+
assertThat(
363+
webServer.requests().get(0).getHeader(HttpHeaders.CONTENT_TYPE),
364+
equalTo(XContentType.JSON.mediaTypeWithoutParameters())
365+
);
366+
assertThat(webServer.requests().get(0).getHeader(HttpHeaders.AUTHORIZATION), equalTo("Bearer secret"));
364367

365-
var requestMap = entityAsMap(webServer.requests().getFirst().getBody());
368+
var requestMap = entityAsMap(webServer.requests().get(0).getBody());
366369
assertThat(requestMap.size(), is(4));
367370
assertThat(requestMap.get("texts"), is(documents));
368371
assertThat(requestMap.get("query"), is(query));

x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/request/rerank/HuggingFaceRerankRequestTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ private void testCreateRequest(Integer topN, Boolean returnDocuments) throws IOE
5151
assertThat(httpRequest.httpRequestBase(), instanceOf(HttpPost.class));
5252
var httpPost = (HttpPost) httpRequest.httpRequestBase();
5353

54-
assertThat(httpPost.getLastHeader(HttpHeaders.CONTENT_TYPE).getValue(), is(XContentType.JSON.mediaType()));
54+
assertThat(httpPost.getLastHeader(HttpHeaders.CONTENT_TYPE).getValue(), is(XContentType.JSON.mediaTypeWithoutParameters()));
5555
assertThat(httpPost.getLastHeader(HttpHeaders.AUTHORIZATION).getValue(), is(AUTH_HEADER_VALUE));
5656

5757
var requestMap = entityAsMap(httpPost.getEntity().getContent());

x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/services/huggingface/response/HuggingFaceRerankResponseEntityTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,6 @@ private void assertMissingFieldThrowsIllegalArgumentException(String responseJso
9595
new HttpResult(mock(HttpResponse.class), responseJson.getBytes(StandardCharsets.UTF_8))
9696
)
9797
);
98-
assertThat(thrownException.getMessage(), is("Required [%s]".formatted(missingField)));
98+
assertThat(thrownException.getMessage(), is("Required [" + missingField + "]"));
9999
}
100100
}

0 commit comments

Comments
 (0)