diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml
index e6fd5dae..a83bea09 100644
--- a/.code-samples.meilisearch.yaml
+++ b/.code-samples.meilisearch.yaml
@@ -837,3 +837,18 @@ distinct_attribute_guide_filterable_1: |-
distinct_attribute_guide_distinct_parameter_1: |-
SearchRequest searchRequest = SearchRequest.builder().q("white shirt").distinct("sku").build();
client.index("products").search(searchRequest);
+search_parameter_reference_locales_1: |-
+ SearchRequest searchRequest = SearchRequest.builder().q("QUERY TEXT IN JAPANESE").locales(new String[]{"jpn"}).build();
+ client.index("INDEX_NAME").search(searchRequest);
+get_localized_attribute_settings_1: |-
+ client.index("INDEX_NAME").getLocalizedAttributesSettings();
+update_localized_attribute_settings_1: |-
+ LocalizedAttribute attribute = new LocalizedAttribute();
+ attribute.setAttributePatterns(new String[] {"jpn"});
+ attribute.setLocales(new String[] {"*_ja"});
+
+ client.index("INDEX_NAME").updateLocalizedAttributesSettings(
+ new LocalizedAttributes[] {attribute}
+ );
+reset_localized_attribute_settings_1: |-
+ client.index("INDEX_NAME").resetLocalizedAttributesSettings();
diff --git a/src/main/java/com/meilisearch/sdk/Index.java b/src/main/java/com/meilisearch/sdk/Index.java
index 90c58c5e..ee0431a4 100644
--- a/src/main/java/com/meilisearch/sdk/Index.java
+++ b/src/main/java/com/meilisearch/sdk/Index.java
@@ -697,6 +697,46 @@ public TaskInfo resetDisplayedAttributesSettings() throws MeilisearchException {
return this.settingsHandler.resetDisplayedAttributesSettings(this.uid);
}
+ /**
+ * Gets the localized attributes of the index
+ *
+ * @return localized attributes of a given uid as LocalizedAttribute
+ * @throws MeilisearchException if an error occurs
+ * @see API
+ * specification
+ */
+ public LocalizedAttribute[] getLocalizedAttributesSettings() throws MeilisearchException {
+ return this.settingsHandler.getLocalizedAttributes(this.uid);
+ }
+
+ /**
+ * Updates the localized attributes of the index
+ *
+ * @param localizedAttributes An array of localized attributes that contains attributes of an
+ * index to display
+ * @return TaskInfo instance
+ * @throws MeilisearchException if an error occurs
+ * @see API
+ * specification
+ */
+ public TaskInfo updateLocalizedAttributesSettings(LocalizedAttribute[] localizedAttributes)
+ throws MeilisearchException {
+ return this.settingsHandler.updateLocalizedAttributesSettings(
+ this.uid, localizedAttributes);
+ }
+
+ /**
+ * Resets the localized attributes of the index
+ *
+ * @return TaskInfo instance
+ * @throws MeilisearchException if an error occurs
+ */
+ public TaskInfo resetLocalizedAttributesSettings() throws MeilisearchException {
+ return this.settingsHandler.resetLocalizedAttributesSettings(this.uid);
+ }
+
/**
* Gets the filterable attributes of the index
*
diff --git a/src/main/java/com/meilisearch/sdk/IndexSearchRequest.java b/src/main/java/com/meilisearch/sdk/IndexSearchRequest.java
index f13d81d8..3ba8eef4 100644
--- a/src/main/java/com/meilisearch/sdk/IndexSearchRequest.java
+++ b/src/main/java/com/meilisearch/sdk/IndexSearchRequest.java
@@ -36,6 +36,7 @@ public class IndexSearchRequest {
protected Double rankingScoreThreshold;
private String[] attributesToSearchOn;
private FederationOptions federationOptions;
+ protected String[] locales;
protected String distinct;
/**
@@ -104,6 +105,7 @@ public String toString() {
.putOpt("showRankingScoreDetails", this.showRankingScoreDetails)
.putOpt("rankingScoreThreshold", this.rankingScoreThreshold)
.putOpt("attributesToSearchOn", this.attributesToSearchOn)
+ .putOpt("locales", this.locales)
.putOpt("distinct", this.distinct);
return jsonObject.toString();
diff --git a/src/main/java/com/meilisearch/sdk/SearchRequest.java b/src/main/java/com/meilisearch/sdk/SearchRequest.java
index 556e38cc..77650ad5 100644
--- a/src/main/java/com/meilisearch/sdk/SearchRequest.java
+++ b/src/main/java/com/meilisearch/sdk/SearchRequest.java
@@ -40,6 +40,7 @@ public class SearchRequest {
protected Boolean showRankingScore;
protected Boolean showRankingScoreDetails;
protected Double rankingScoreThreshold;
+ protected String[] locales;
protected String distinct;
/**
@@ -102,6 +103,7 @@ public String toString() {
.putOpt("showRankingScore", this.showRankingScore)
.putOpt("showRankingScoreDetails", this.showRankingScoreDetails)
.putOpt("rankingScoreThreshold", this.rankingScoreThreshold)
+ .putOpt("locales", this.locales)
.putOpt("distinct", this.distinct);
return jsonObject.toString();
diff --git a/src/main/java/com/meilisearch/sdk/SettingsHandler.java b/src/main/java/com/meilisearch/sdk/SettingsHandler.java
index cc7f9190..c70f9f80 100644
--- a/src/main/java/com/meilisearch/sdk/SettingsHandler.java
+++ b/src/main/java/com/meilisearch/sdk/SettingsHandler.java
@@ -3,6 +3,7 @@
import com.meilisearch.sdk.exceptions.MeilisearchException;
import com.meilisearch.sdk.http.URLBuilder;
import com.meilisearch.sdk.model.Faceting;
+import com.meilisearch.sdk.model.LocalizedAttribute;
import com.meilisearch.sdk.model.Pagination;
import com.meilisearch.sdk.model.Settings;
import com.meilisearch.sdk.model.TaskInfo;
@@ -266,6 +267,50 @@ TaskInfo resetDisplayedAttributesSettings(String uid) throws MeilisearchExceptio
settingsPath(uid).addSubroute("displayed-attributes").getURL(), TaskInfo.class);
}
+ /**
+ * Gets the localized attributes of the index
+ *
+ * @param uid Index identifier
+ * @return an array of localizedattributes that contains attributes of the index to display
+ * @throws MeilisearchException if an error occurs
+ */
+ LocalizedAttribute[] getLocalizedAttributes(String uid) throws MeilisearchException {
+ return httpClient.get(
+ settingsPath(uid).addSubroute("localized-attributes").getURL(),
+ LocalizedAttribute[].class);
+ }
+
+ /**
+ * Updates the localized attributes of the index.
+ *
+ * @param uid Index identifier
+ * @param localizedAttributes an array of LocalizedAttributes that contain patterns and locales
+ * settings
+ * @return TaskInfo instance
+ * @throws MeilisearchException if an error occurs
+ */
+ TaskInfo updateLocalizedAttributesSettings(String uid, LocalizedAttribute[] localizedAttributes)
+ throws MeilisearchException {
+ return httpClient.put(
+ settingsPath(uid).addSubroute("localized-attributes").getURL(),
+ localizedAttributes == null
+ ? httpClient.jsonHandler.encode(localizedAttributes)
+ : localizedAttributes,
+ TaskInfo.class);
+ }
+
+ /**
+ * Resets the localized attributes of the index
+ *
+ * @param uid Index identifier
+ * @return TaskInfo instance
+ * @throws MeilisearchException if an error occurs
+ */
+ TaskInfo resetLocalizedAttributesSettings(String uid) throws MeilisearchException {
+ return httpClient.delete(
+ settingsPath(uid).addSubroute("localized-attributes").getURL(), TaskInfo.class);
+ }
+
/**
* Gets the filterableAttributes of the index
*
diff --git a/src/main/java/com/meilisearch/sdk/model/LocalizedAttribute.java b/src/main/java/com/meilisearch/sdk/model/LocalizedAttribute.java
new file mode 100644
index 00000000..ba87a194
--- /dev/null
+++ b/src/main/java/com/meilisearch/sdk/model/LocalizedAttribute.java
@@ -0,0 +1,21 @@
+package com.meilisearch.sdk.model;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+/**
+ * LocalizedAttribute setting data structure
+ *
+ * @see API
+ * specification
+ */
+@Getter
+@Setter
+@AllArgsConstructor
+@NoArgsConstructor
+public class LocalizedAttribute {
+ protected String[] attributePatterns;
+ protected String[] locales;
+}
diff --git a/src/main/java/com/meilisearch/sdk/model/Settings.java b/src/main/java/com/meilisearch/sdk/model/Settings.java
index c450185f..2a4233b6 100644
--- a/src/main/java/com/meilisearch/sdk/model/Settings.java
+++ b/src/main/java/com/meilisearch/sdk/model/Settings.java
@@ -32,6 +32,7 @@ public class Settings {
protected String[] separatorTokens;
protected String[] nonSeparatorTokens;
protected HashMap embedders;
+ protected LocalizedAttribute[] localizedAttributes;
public Settings() {}
}
diff --git a/src/test/java/com/meilisearch/integration/SearchTest.java b/src/test/java/com/meilisearch/integration/SearchTest.java
index 9c96f7a2..5e06531b 100644
--- a/src/test/java/com/meilisearch/integration/SearchTest.java
+++ b/src/test/java/com/meilisearch/integration/SearchTest.java
@@ -1119,4 +1119,80 @@ public void testSimilarDocuments() throws Exception {
assertThat(hits.get(2).get("title"), is("How to Train Your Dragon: The Hidden World"));
assertThat(hits.get(3).get("title"), is("Shazam!"));
}
+
+ /** Test Search with locales */
+ @Test
+ public void testSearchWithLocales() throws Exception {
+ String indexUid = "SearchLocales";
+ Index index = client.index(indexUid);
+ GsonJsonHandler jsonGson = new GsonJsonHandler();
+
+ TestData testData = this.getTestData(NESTED_MOVIES, Movie.class);
+ TaskInfo task = index.addDocuments(testData.getRaw());
+
+ index.waitForTask(task.getTaskUid());
+
+ Settings settings = index.getSettings();
+
+ LocalizedAttribute localizedAttribute = new LocalizedAttribute();
+ localizedAttribute.setAttributePatterns(new String[] {"title", "comment"});
+ localizedAttribute.setLocales(new String[] {"fra", "eng"});
+ settings.setLocalizedAttributes(new LocalizedAttribute[] {localizedAttribute});
+
+ index.waitForTask(index.updateSettings(settings).getTaskUid());
+
+ SearchRequest searchRequest =
+ SearchRequest.builder().q("french").locales(new String[] {"fra", "eng"}).build();
+
+ Results resGson = jsonGson.decode(index.rawSearch(searchRequest), Results.class);
+
+ assertThat(resGson.hits, is(arrayWithSize(2)));
+ }
+
+ /** Test multisearch with locales */
+ @Test
+ public void testMultiSearchWithLocales() throws Exception {
+ HashSet indexUids = new HashSet();
+ indexUids.add("LocaleSearch1");
+ indexUids.add("LocaleSearch2");
+
+ for (String indexUid : indexUids) {
+ Index index = client.index(indexUid);
+
+ TestData testData = this.getTestData(NESTED_MOVIES, Movie.class);
+ TaskInfo task = index.addDocuments(testData.getRaw());
+
+ index.waitForTask(task.getTaskUid());
+
+ Settings settings = index.getSettings();
+
+ LocalizedAttribute localizedAttribute = new LocalizedAttribute();
+ localizedAttribute.setAttributePatterns(new String[] {"title", "comment"});
+ localizedAttribute.setLocales(new String[] {"fra", "eng"});
+ settings.setLocalizedAttributes(new LocalizedAttribute[] {localizedAttribute});
+
+ index.waitForTask(index.updateSettings(settings).getTaskUid());
+ }
+
+ MultiSearchRequest search = new MultiSearchRequest();
+
+ search.addQuery(
+ new IndexSearchRequest("LocaleSearch1")
+ .setQuery("")
+ .setLocales(new String[] {"eng"}));
+ search.addQuery(
+ new IndexSearchRequest("LocaleSearch2")
+ .setQuery("french")
+ .setLocales(new String[] {"fra"}));
+
+ MultiSearchResult[] results = client.multiSearch(search).getResults();
+
+ assertThat(results.length, is(2));
+
+ for (MultiSearchResult searchResult : results) {
+ assertThat(indexUids.contains(searchResult.getIndexUid()), is(true));
+ }
+ assertThat(results[0].getHits().size(), is(7));
+ assertThat(results[1].getHits().size(), is(2));
+ }
}
diff --git a/src/test/java/com/meilisearch/integration/SettingsTest.java b/src/test/java/com/meilisearch/integration/SettingsTest.java
index 82dd6a9e..b345bdac 100644
--- a/src/test/java/com/meilisearch/integration/SettingsTest.java
+++ b/src/test/java/com/meilisearch/integration/SettingsTest.java
@@ -18,6 +18,7 @@
import com.meilisearch.sdk.Index;
import com.meilisearch.sdk.model.FacetSortValue;
import com.meilisearch.sdk.model.Faceting;
+import com.meilisearch.sdk.model.LocalizedAttribute;
import com.meilisearch.sdk.model.Pagination;
import com.meilisearch.sdk.model.Settings;
import com.meilisearch.sdk.model.TaskInfo;
@@ -445,7 +446,7 @@ public void testGetDisplayedAttributesSettings() throws Exception {
assertThat(
initialDisplayedAttributes,
- is(arrayWithSize(initialSettings.getSearchableAttributes().length)));
+ is(arrayWithSize(initialSettings.getDisplayedAttributes().length)));
assertThat(
initialDisplayedAttributes, is(equalTo(initialSettings.getDisplayedAttributes())));
}
@@ -492,6 +493,99 @@ public void testResetDisplayedAttributesSettings() throws Exception {
is(not(arrayWithSize(updatedDisplayedAttributes.length))));
}
+ /** Tests of the localization attributes setting methods */
+ @Test
+ @DisplayName("Test get localized attributes settings by uid")
+ public void testGetLocalizedAttributesSettings() throws Exception {
+ Index index = createIndex("testGetLocalizedAttributesSettings");
+ Settings initialSettings = index.getSettings();
+ LocalizedAttribute[] initialLocalizedAttributes = index.getLocalizedAttributesSettings();
+
+ assertThat(
+ initialLocalizedAttributes, is(equalTo(initialSettings.getLocalizedAttributes())));
+ assertThat(
+ initialLocalizedAttributes, is(equalTo(initialSettings.getLocalizedAttributes())));
+ }
+
+ @Test
+ @DisplayName("Test update localized attributes settings")
+ public void testUpdateLocalizedAttributesSettings() throws Exception {
+ Index index = createIndex("testUpdateLocalizedAttributesSettings");
+ LocalizedAttribute[] initialLocalizedAttributes = index.getLocalizedAttributesSettings();
+
+ LocalizedAttribute firstAttribute = new LocalizedAttribute();
+ LocalizedAttribute secondAttribute = new LocalizedAttribute();
+
+ firstAttribute.setAttributePatterns(new String[] {"title", "description"});
+ firstAttribute.setLocales(new String[] {"eng", "fra"});
+
+ secondAttribute.setAttributePatterns(new String[] {"genre", "release_date"});
+ secondAttribute.setLocales(new String[] {"rus"});
+
+ LocalizedAttribute[] newLocalizedAttributes =
+ new LocalizedAttribute[] {firstAttribute, secondAttribute};
+
+ index.waitForTask(
+ index.updateLocalizedAttributesSettings(newLocalizedAttributes).getTaskUid());
+ LocalizedAttribute[] updatedLocalizedAttributes = index.getLocalizedAttributesSettings();
+
+ assertThat(updatedLocalizedAttributes, is(arrayWithSize(newLocalizedAttributes.length)));
+ assertThat(
+ updatedLocalizedAttributes[0].getAttributePatterns(),
+ is(equalTo(newLocalizedAttributes[0].getAttributePatterns())));
+ assertThat(
+ updatedLocalizedAttributes[0].getLocales(),
+ is(equalTo(newLocalizedAttributes[0].getLocales())));
+ assertThat(
+ updatedLocalizedAttributes[1].getAttributePatterns(),
+ is(equalTo(newLocalizedAttributes[1].getAttributePatterns())));
+ assertThat(
+ updatedLocalizedAttributes[1].getLocales(),
+ is(equalTo(newLocalizedAttributes[1].getLocales())));
+ assertThat(updatedLocalizedAttributes, is(not(equalTo(initialLocalizedAttributes))));
+ }
+
+ @Test
+ @DisplayName("Test reset localized attributes settings")
+ public void testResetLocalizedAttributesSettings() throws Exception {
+ Index index = createIndex("testResetLocalizedAttributesSettings");
+ LocalizedAttribute[] initialLocalizedAttributes = index.getLocalizedAttributesSettings();
+ LocalizedAttribute firstAttribute = new LocalizedAttribute();
+ LocalizedAttribute secondAttribute = new LocalizedAttribute();
+
+ firstAttribute.setAttributePatterns(new String[] {"title", "description"});
+ firstAttribute.setLocales(new String[] {"eng", "fra"});
+
+ secondAttribute.setAttributePatterns(new String[] {"genre", "release_date"});
+ secondAttribute.setLocales(new String[] {"rus"});
+
+ LocalizedAttribute[] newLocalizedAttributes =
+ new LocalizedAttribute[] {firstAttribute, secondAttribute};
+
+ index.waitForTask(
+ index.updateLocalizedAttributesSettings(newLocalizedAttributes).getTaskUid());
+ LocalizedAttribute[] updatedLocalizedAttributes = index.getLocalizedAttributesSettings();
+
+ index.waitForTask(index.resetLocalizedAttributesSettings().getTaskUid());
+ LocalizedAttribute[] localizedAttributesAfterReset = index.getLocalizedAttributesSettings();
+
+ assertThat(updatedLocalizedAttributes, is(arrayWithSize(newLocalizedAttributes.length)));
+ assertThat(
+ updatedLocalizedAttributes[0].getAttributePatterns(),
+ is(equalTo(newLocalizedAttributes[0].getAttributePatterns())));
+ assertThat(
+ updatedLocalizedAttributes[0].getLocales(),
+ is(equalTo(newLocalizedAttributes[0].getLocales())));
+ assertThat(
+ updatedLocalizedAttributes[1].getAttributePatterns(),
+ is(equalTo(newLocalizedAttributes[1].getAttributePatterns())));
+ assertThat(
+ updatedLocalizedAttributes[1].getLocales(),
+ is(equalTo(newLocalizedAttributes[1].getLocales())));
+ assertThat(updatedLocalizedAttributes, is(not(equalTo(initialLocalizedAttributes))));
+ assertThat(localizedAttributesAfterReset, is(not(equalTo(updatedLocalizedAttributes))));
+ }
+
/** Tests of the filterable attributes setting methods */
@Test
@DisplayName("Test get filterable attributes settings by uid")
@@ -963,6 +1057,37 @@ public void testUpdateDistinctAttributeSettingsUsingNull() throws Exception {
assertThat(resetDistinctAttribute, is(equalTo(initialDistinctAttribute)));
}
+ @Test
+ @DisplayName("Test update localized attribute settings when null is passed")
+ public void testUpdateLocalizedAttributeSettingsUsingNull() throws Exception {
+ Index index = createIndex("testUpdateLocalizedAttributesSettingsUsingNull");
+ LocalizedAttribute[] initialLocalizedAttributes = index.getLocalizedAttributesSettings();
+ LocalizedAttribute firstAttribute = new LocalizedAttribute();
+ LocalizedAttribute secondAttribute = new LocalizedAttribute();
+
+ firstAttribute.setAttributePatterns(new String[] {"title", "description"});
+ firstAttribute.setLocales(new String[] {"eng", "fra"});
+
+ secondAttribute.setAttributePatterns(new String[] {"genre", "release_date"});
+ secondAttribute.setLocales(new String[] {"rus"});
+
+ LocalizedAttribute[] newLocalizedAttributes =
+ new LocalizedAttribute[] {firstAttribute, secondAttribute};
+
+ index.waitForTask(
+ index.updateLocalizedAttributesSettings(newLocalizedAttributes).getTaskUid());
+ LocalizedAttribute[] updatedLocalizedAttributes = index.getLocalizedAttributesSettings();
+
+ index.waitForTask(index.updateLocalizedAttributesSettings(null).getTaskUid());
+ LocalizedAttribute[] resetLocalizedAttributes = index.getLocalizedAttributesSettings();
+
+ assertThat(updatedLocalizedAttributes, is(not(equalTo(initialLocalizedAttributes))));
+ assertThat(
+ resetLocalizedAttributes,
+ is(not(arrayWithSize(updatedLocalizedAttributes.length))));
+ assertThat(resetLocalizedAttributes, is(equalTo(initialLocalizedAttributes)));
+ }
+
/** Tests of the pagination setting methods */
@Test
@DisplayName("Test get pagination settings by uid")
diff --git a/src/test/java/com/meilisearch/sdk/SearchRequestTest.java b/src/test/java/com/meilisearch/sdk/SearchRequestTest.java
index 7578596b..6eb9f850 100644
--- a/src/test/java/com/meilisearch/sdk/SearchRequestTest.java
+++ b/src/test/java/com/meilisearch/sdk/SearchRequestTest.java
@@ -134,6 +134,7 @@ void toStringEveryParameters() {
.setSort(new String[] {"sort"})
.setPage(10)
.setHitsPerPage(2)
+ .setLocales(new String[] {"eng"})
.setDistinct("distinct");
assertThat(classToTest.getQ(), is(equalTo("This is a Test")));
@@ -154,6 +155,7 @@ void toStringEveryParameters() {
assertThat(classToTest.getCropLength(), is(equalTo(900)));
assertThat(classToTest.getPage(), is(equalTo(10)));
assertThat(classToTest.getHitsPerPage(), is(equalTo(2)));
+ assertThat(classToTest.getLocales()[0], is(equalTo("eng")));
assertThat(classToTest.getDistinct(), is(equalTo("distinct")));
}
@@ -174,6 +176,7 @@ void toStringEveryParametersWithBuilder() {
.sort(new String[] {"sort"})
.page(10)
.hitsPerPage(2)
+ .locales(new String[] {"eng"})
.distinct("distinct")
.build();
@@ -195,6 +198,7 @@ void toStringEveryParametersWithBuilder() {
assertThat(classToTest.getCropLength(), is(equalTo(900)));
assertThat(classToTest.getPage(), is(equalTo(10)));
assertThat(classToTest.getHitsPerPage(), is(equalTo(2)));
+ assertThat(classToTest.getLocales()[0], is(equalTo("eng")));
assertThat(classToTest.getDistinct(), is(equalTo("distinct")));
}
@@ -222,9 +226,10 @@ void toStringEveryParametersWithArray() {
.setSort(new String[] {"sort"})
.setPage(0)
.setHitsPerPage(0)
- .setDistinct("distinct");
+ .setDistinct("distinct")
+ .setLocales(new String[] {"eng"});
String expectedToString =
- "{\"attributesToRetrieve\":[\"bubble\"],\"offset\":200,\"cropMarker\":\"123\",\"hitsPerPage\":0,\"attributesToSearchOn\":[\"searchOn\"],\"distinct\":\"distinct\",\"sort\":[\"sort\"],\"highlightPreTag\":\"abc\",\"facets\":[\"facets\"],\"filter\":[[\"test='test'\"],[\"test1='test1'\"]],\"q\":\"This is a Test\",\"matchingStrategy\":\"all\",\"showMatchesPosition\":true,\"limit\":900,\"cropLength\":900,\"highlightPostTag\":\"zyx\",\"attributesToHighlight\":[\"highlight\"],\"page\":0,\"attributesToCrop\":[\"crop\"]}";
+ "{\"attributesToRetrieve\":[\"bubble\"],\"offset\":200,\"cropMarker\":\"123\",\"hitsPerPage\":0,\"attributesToSearchOn\":[\"searchOn\"],\"distinct\":\"distinct\",\"sort\":[\"sort\"],\"highlightPreTag\":\"abc\",\"facets\":[\"facets\"],\"filter\":[[\"test='test'\"],[\"test1='test1'\"]],\"q\":\"This is a Test\",\"locales\":[\"eng\"],\"matchingStrategy\":\"all\",\"showMatchesPosition\":true,\"limit\":900,\"cropLength\":900,\"highlightPostTag\":\"zyx\",\"attributesToHighlight\":[\"highlight\"],\"page\":0,\"attributesToCrop\":[\"crop\"]}";
assertThat(classToTest.getQ(), is(equalTo("This is a Test")));
assertThat(classToTest.getOffset(), is(equalTo(200)));
@@ -246,6 +251,7 @@ void toStringEveryParametersWithArray() {
assertThat(classToTest.getCropLength(), is(equalTo(900)));
assertThat(classToTest.getPage(), is(equalTo(0)));
assertThat(classToTest.getHitsPerPage(), is(equalTo(0)));
+ assertThat(classToTest.getLocales()[0], is(equalTo("eng")));
assertThat(classToTest.getDistinct(), is(equalTo("distinct")));
assertThat(classToTest.toString(), is(equalTo(expectedToString)));
}
@@ -275,10 +281,11 @@ void toStringEveryParametersWithArrayWithBuilder() {
.sort(new String[] {"sort"})
.page(0)
.hitsPerPage(0)
+ .locales(new String[] {"eng"})
.distinct("distinct")
.build();
String expectedToString =
- "{\"attributesToRetrieve\":[\"bubble\"],\"offset\":200,\"cropMarker\":\"123\",\"hitsPerPage\":0,\"attributesToSearchOn\":[\"searchOn\"],\"distinct\":\"distinct\",\"sort\":[\"sort\"],\"highlightPreTag\":\"abc\",\"facets\":[\"facets\"],\"filter\":[[\"test='test'\"],[\"test1='test1'\"]],\"q\":\"This is a Test\",\"matchingStrategy\":\"all\",\"showMatchesPosition\":true,\"limit\":900,\"cropLength\":900,\"highlightPostTag\":\"zyx\",\"attributesToHighlight\":[\"highlight\"],\"page\":0,\"attributesToCrop\":[\"crop\"]}";
+ "{\"attributesToRetrieve\":[\"bubble\"],\"offset\":200,\"cropMarker\":\"123\",\"hitsPerPage\":0,\"attributesToSearchOn\":[\"searchOn\"],\"distinct\":\"distinct\",\"sort\":[\"sort\"],\"highlightPreTag\":\"abc\",\"facets\":[\"facets\"],\"filter\":[[\"test='test'\"],[\"test1='test1'\"]],\"q\":\"This is a Test\",\"locales\":[\"eng\"],\"matchingStrategy\":\"all\",\"showMatchesPosition\":true,\"limit\":900,\"cropLength\":900,\"highlightPostTag\":\"zyx\",\"attributesToHighlight\":[\"highlight\"],\"page\":0,\"attributesToCrop\":[\"crop\"]}";
assertThat(classToTest.getQ(), is(equalTo("This is a Test")));
assertThat(classToTest.getOffset(), is(equalTo(200)));
@@ -300,6 +307,7 @@ void toStringEveryParametersWithArrayWithBuilder() {
assertThat(classToTest.getCropLength(), is(equalTo(900)));
assertThat(classToTest.getPage(), is(equalTo(0)));
assertThat(classToTest.getHitsPerPage(), is(equalTo(0)));
+ assertThat(classToTest.getLocales()[0], is(equalTo("eng")));
assertThat(classToTest.getDistinct(), is(equalTo("distinct")));
assertThat(classToTest.toString(), is(equalTo(expectedToString)));
}