Skip to content

Commit

Permalink
Add tests update partial typo tolerance
Browse files Browse the repository at this point in the history
  • Loading branch information
alallema committed May 23, 2022
1 parent 705e3cf commit d7bbdb5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/meilisearch/sdk/TypoTolerance.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.json.JSONObject;

public class TypoTolerance {
@Getter @Setter private boolean enabled = false;
@Getter @Setter private boolean enabled = true;
@Getter @Setter private HashMap<String, Integer> minWordSizeForTypos;
@Getter @Setter private String[] disableOnWords;
@Getter @Setter private String[] disableOnAttributes;
Expand Down
28 changes: 27 additions & 1 deletion src/test/java/com/meilisearch/integration/SettingsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ public void testUpdateSettingsTypoTolerance() throws Exception {
Settings settings = index.getSettings();

TypoTolerance typoTolerance = new TypoTolerance();
typoTolerance.setEnabled(true);
typoTolerance.setDisableOnWords(new String[] {"and"});
typoTolerance.setDisableOnAttributes(new String[] {"title"});
settings.setTypoTolerance(typoTolerance);
Expand Down Expand Up @@ -581,6 +580,33 @@ public void testUpdateTypoTolerance() throws Exception {
&& updatedTypoTolerance.getMinWordSizeForTypos().get("twoTypos") == 10);
}

@Test
@DisplayName("Test update typo tolerance settings")
public void testPartialUpdateTypoTolerance() throws Exception {
Index index = createIndex("testUpdateTypoTolerance");
TypoTolerance initialTypoTolerance = index.getTypoToleranceSettings();
TypoTolerance newTypoTolerance = new TypoTolerance();
newTypoTolerance.setDisableOnWords(new String[] {"the"});
newTypoTolerance.setDisableOnAttributes(new String[] {"title"});

index.waitForTask(index.updateTypoToleranceSettings(newTypoTolerance).getUid());
TypoTolerance updatedTypoTolerance = index.getTypoToleranceSettings();

assertEquals(
newTypoTolerance.getDisableOnWords()[0],
updatedTypoTolerance.getDisableOnWords()[0]);
assertEquals(
newTypoTolerance.getDisableOnAttributes()[0],
updatedTypoTolerance.getDisableOnAttributes()[0]);
assertTrue(updatedTypoTolerance.isEnabled());
assertTrue(
updatedTypoTolerance.getMinWordSizeForTypos().containsKey("oneTypo")
&& updatedTypoTolerance.getMinWordSizeForTypos().get("oneTypo") == 5);
assertTrue(
updatedTypoTolerance.getMinWordSizeForTypos().containsKey("twoTypos")
&& updatedTypoTolerance.getMinWordSizeForTypos().get("twoTypos") == 9);
}

@Test
@DisplayName("Test reset typo tolerance settings")
public void testResetTypoTolerance() throws Exception {
Expand Down

0 comments on commit d7bbdb5

Please sign in to comment.