forked from meilisearch/meilisearch-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSearchResultQueryVectorTest.java
More file actions
32 lines (26 loc) · 1.12 KB
/
SearchResultQueryVectorTest.java
File metadata and controls
32 lines (26 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package com.meilisearch.sdk;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import com.meilisearch.sdk.json.GsonJsonHandler;
import com.meilisearch.sdk.model.SearchResult;
import org.junit.jupiter.api.Test;
class SearchResultQueryVectorTest {
@Test
void testQueryVectorIsMapped() throws Exception {
String json =
"{"
+ "\"hits\": [],"
+ "\"processingTimeMs\": 1,"
+ "\"query\": \"hello\","
+ "\"queryVector\": [0.1, 0.2, 0.3]"
+ "}";
GsonJsonHandler handler = new GsonJsonHandler();
SearchResult result = handler.decode(json, SearchResult.class);
assertThat(result, is(notNullValue()));
assertThat(result.getQueryVector(), is(notNullValue()));
assertThat(result.getQueryVector().size(), is(3));
assertThat(result.getQueryVector().get(0), equalTo(0.1F));
assertThat(result.getQueryVector().get(1), equalTo(0.2F));
assertThat(result.getQueryVector().get(2), equalTo(0.3F));
}
}