Skip to content

Commit f3f43ed

Browse files
committed
Spotless tests
1 parent 64e7fcf commit f3f43ed

File tree

7 files changed

+119
-134
lines changed

7 files changed

+119
-134
lines changed

x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/action/voyageai/VoyageAIActionCreatorTests.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@
4343
import static org.elasticsearch.xpack.inference.external.http.sender.HttpRequestSenderTests.createSender;
4444
import static org.elasticsearch.xpack.inference.results.TextEmbeddingResultsTests.buildExpectationFloat;
4545
import static org.elasticsearch.xpack.inference.services.ServiceComponentsTests.createWithEmptySettings;
46-
import static org.hamcrest.Matchers.is;
47-
import static org.hamcrest.Matchers.hasSize;
4846
import static org.hamcrest.Matchers.equalTo;
47+
import static org.hamcrest.Matchers.hasSize;
48+
import static org.hamcrest.Matchers.is;
4949
import static org.mockito.Mockito.mock;
5050

5151
public class VoyageAIActionCreatorTests extends ESTestCase {
@@ -125,12 +125,18 @@ public void testCreate_VoyageAIEmbeddingsModel() throws IOException {
125125
requestMap,
126126
is(
127127
Map.of(
128-
"output_dtype","float",
129-
"truncation", true,
130-
"input_type", "query",
131-
"output_dimension",1024,
132-
"input", List.of("abc"),
133-
"model", "model"
128+
"output_dtype",
129+
"float",
130+
"truncation",
131+
true,
132+
"input_type",
133+
"query",
134+
"output_dimension",
135+
1024,
136+
"input",
137+
List.of("abc"),
138+
"model",
139+
"model"
134140
)
135141
)
136142
);

x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/action/voyageai/VoyageAIEmbeddingsActionTests.java

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
import org.elasticsearch.xpack.inference.external.action.SenderExecutableAction;
2727
import org.elasticsearch.xpack.inference.external.http.HttpClientManager;
2828
import org.elasticsearch.xpack.inference.external.http.HttpResult;
29-
import org.elasticsearch.xpack.inference.external.http.sender.VoyageAIEmbeddingsRequestManager;
3029
import org.elasticsearch.xpack.inference.external.http.sender.DocumentsOnlyInput;
3130
import org.elasticsearch.xpack.inference.external.http.sender.HttpRequestSenderTests;
3231
import org.elasticsearch.xpack.inference.external.http.sender.Sender;
32+
import org.elasticsearch.xpack.inference.external.http.sender.VoyageAIEmbeddingsRequestManager;
3333
import org.elasticsearch.xpack.inference.external.request.voyageai.VoyageAIUtils;
3434
import org.elasticsearch.xpack.inference.logging.ThrottlerManager;
3535
import org.elasticsearch.xpack.inference.services.voyageai.embeddings.VoyageAIEmbeddingType;
@@ -139,12 +139,18 @@ public void testExecute_ReturnsSuccessfulResponse() throws IOException {
139139
requestMap,
140140
equalTo(
141141
Map.of(
142-
"input", List.of("abc"),
143-
"model", "model",
144-
"input_type", "document",
145-
"output_dtype", "float",
146-
"truncation", true,
147-
"output_dimension", 1024
142+
"input",
143+
List.of("abc"),
144+
"model",
145+
"model",
146+
"input_type",
147+
"document",
148+
"output_dtype",
149+
"float",
150+
"truncation",
151+
true,
152+
"output_dimension",
153+
1024
148154
)
149155
)
150156
);
@@ -208,12 +214,18 @@ public void testExecute_ReturnsSuccessfulResponse_ForInt8ResponseType() throws I
208214
requestMap,
209215
is(
210216
Map.of(
211-
"input", List.of("abc"),
212-
"model", "model",
213-
"input_type", "document",
214-
"output_dtype", "int8",
215-
"truncation", true,
216-
"output_dimension", 1024
217+
"input",
218+
List.of("abc"),
219+
"model",
220+
"model",
221+
"input_type",
222+
"document",
223+
"output_dtype",
224+
"int8",
225+
"truncation",
226+
true,
227+
"output_dimension",
228+
1024
217229
)
218230
)
219231
);
@@ -277,12 +289,18 @@ public void testExecute_ReturnsSuccessfulResponse_ForBinaryResponseType() throws
277289
requestMap,
278290
is(
279291
Map.of(
280-
"input", List.of("abc"),
281-
"model", "model",
282-
"input_type", "document",
283-
"output_dtype", "binary",
284-
"truncation", true,
285-
"output_dimension", 1024
292+
"input",
293+
List.of("abc"),
294+
"model",
295+
"model",
296+
"input_type",
297+
"document",
298+
"output_dtype",
299+
"binary",
300+
"truncation",
301+
true,
302+
"output_dimension",
303+
1024
286304
)
287305
)
288306
);

x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/voyageai/VoyageAIEmbeddingsRequestEntityTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
import org.elasticsearch.xpack.inference.services.ConfigurationParseContext;
1818
import org.elasticsearch.xpack.inference.services.ServiceFields;
1919
import org.elasticsearch.xpack.inference.services.voyageai.VoyageAIServiceSettings;
20-
import org.elasticsearch.xpack.inference.services.voyageai.embeddings.VoyageAIEmbeddingsTaskSettings;
2120
import org.elasticsearch.xpack.inference.services.voyageai.embeddings.VoyageAIEmbeddingsServiceSettings;
21+
import org.elasticsearch.xpack.inference.services.voyageai.embeddings.VoyageAIEmbeddingsTaskSettings;
2222
import org.hamcrest.MatcherAssert;
2323

2424
import java.io.IOException;

x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/voyageai/VoyageAIEmbeddingsRequestTests.java

Lines changed: 49 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,16 @@ public void testCreateRequest_UrlDefined() throws IOException {
4747
);
4848

4949
var requestMap = entityAsMap(httpPost.getEntity().getContent());
50-
MatcherAssert.assertThat(requestMap, is(Map.of(
51-
"input", List.of("abc"),
52-
"model", "model",
53-
"output_dtype", "float"
54-
)));
50+
MatcherAssert.assertThat(requestMap, is(Map.of("input", List.of("abc"), "model", "model", "output_dtype", "float")));
5551
}
5652

5753
public void testCreateRequest_AllOptionsDefined() throws IOException {
5854
var request = createRequest(
5955
List.of("abc"),
6056
VoyageAIEmbeddingsModelTests.createModel(
6157
"url",
62-
"secret", new VoyageAIEmbeddingsTaskSettings(InputType.INGEST, null),
58+
"secret",
59+
new VoyageAIEmbeddingsTaskSettings(InputType.INGEST, null),
6360
null,
6461
null,
6562
"model"
@@ -80,20 +77,19 @@ public void testCreateRequest_AllOptionsDefined() throws IOException {
8077
);
8178

8279
var requestMap = entityAsMap(httpPost.getEntity().getContent());
83-
MatcherAssert.assertThat(requestMap, is(Map.of(
84-
"input", List.of("abc"),
85-
"model", "model",
86-
"input_type", "document",
87-
"output_dtype", "float"
88-
)));
80+
MatcherAssert.assertThat(
81+
requestMap,
82+
is(Map.of("input", List.of("abc"), "model", "model", "input_type", "document", "output_dtype", "float"))
83+
);
8984
}
9085

9186
public void testCreateRequest_DimensionDefined() throws IOException {
9287
var request = createRequest(
9388
List.of("abc"),
9489
VoyageAIEmbeddingsModelTests.createModel(
9590
"url",
96-
"secret", new VoyageAIEmbeddingsTaskSettings(InputType.INGEST, null),
91+
"secret",
92+
new VoyageAIEmbeddingsTaskSettings(InputType.INGEST, null),
9793
null,
9894
2048,
9995
"model"
@@ -114,21 +110,32 @@ public void testCreateRequest_DimensionDefined() throws IOException {
114110
);
115111

116112
var requestMap = entityAsMap(httpPost.getEntity().getContent());
117-
MatcherAssert.assertThat(requestMap, is(Map.of(
118-
"input", List.of("abc"),
119-
"model", "model",
120-
"input_type", "document",
121-
"output_dtype", "float",
122-
"output_dimension", 2048
123-
)));
113+
MatcherAssert.assertThat(
114+
requestMap,
115+
is(
116+
Map.of(
117+
"input",
118+
List.of("abc"),
119+
"model",
120+
"model",
121+
"input_type",
122+
"document",
123+
"output_dtype",
124+
"float",
125+
"output_dimension",
126+
2048
127+
)
128+
)
129+
);
124130
}
125131

126132
public void testCreateRequest_EmbeddingTypeDefined() throws IOException {
127133
var request = createRequest(
128134
List.of("abc"),
129135
VoyageAIEmbeddingsModelTests.createModel(
130136
"url",
131-
"secret", new VoyageAIEmbeddingsTaskSettings(InputType.INGEST, null),
137+
"secret",
138+
new VoyageAIEmbeddingsTaskSettings(InputType.INGEST, null),
132139
null,
133140
2048,
134141
"model",
@@ -150,13 +157,23 @@ public void testCreateRequest_EmbeddingTypeDefined() throws IOException {
150157
);
151158

152159
var requestMap = entityAsMap(httpPost.getEntity().getContent());
153-
MatcherAssert.assertThat(requestMap, is(Map.of(
154-
"input", List.of("abc"),
155-
"model", "model",
156-
"input_type", "document",
157-
"output_dtype", "int8",
158-
"output_dimension", 2048
159-
)));
160+
MatcherAssert.assertThat(
161+
requestMap,
162+
is(
163+
Map.of(
164+
"input",
165+
List.of("abc"),
166+
"model",
167+
"model",
168+
"input_type",
169+
"document",
170+
"output_dtype",
171+
"int8",
172+
"output_dimension",
173+
2048
174+
)
175+
)
176+
);
160177
}
161178

162179
public void testCreateRequest_InputTypeSearch() throws IOException {
@@ -186,12 +203,10 @@ public void testCreateRequest_InputTypeSearch() throws IOException {
186203
);
187204

188205
var requestMap = entityAsMap(httpPost.getEntity().getContent());
189-
MatcherAssert.assertThat(requestMap, is(Map.of(
190-
"input", List.of("abc"),
191-
"model", "model",
192-
"input_type", "query",
193-
"output_dtype", "float"
194-
)));
206+
MatcherAssert.assertThat(
207+
requestMap,
208+
is(Map.of("input", List.of("abc"), "model", "model", "input_type", "query", "output_dtype", "float"))
209+
);
195210
}
196211

197212
public static VoyageAIEmbeddingsRequest createRequest(List<String> input, VoyageAIEmbeddingsModel model) {

x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/external/request/voyageai/VoyageAIRerankRequestTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
import java.util.List;
1919

2020
import static org.elasticsearch.xpack.inference.external.http.Utils.entityAsMap;
21-
import static org.hamcrest.Matchers.is;
22-
import static org.hamcrest.Matchers.instanceOf;
2321
import static org.hamcrest.Matchers.aMapWithSize;
22+
import static org.hamcrest.Matchers.instanceOf;
23+
import static org.hamcrest.Matchers.is;
2424
import static org.hamcrest.Matchers.sameInstance;
2525

2626
public class VoyageAIRerankRequestTests extends ESTestCase {

0 commit comments

Comments
 (0)