Skip to content

Commit

Permalink
null based test added
Browse files Browse the repository at this point in the history
  • Loading branch information
Barabasbalazs committed Oct 31, 2024
1 parent 382e47b commit f7476f5
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion src/test/java/com/meilisearch/integration/SettingsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ public void testResetLocalizedAttributesSettings() throws Exception {
index.updateLocalizedAttributesSettings(newLocalizedAttributes).getTaskUid());
LocalizedAttribute[] updatedLocalizedAttributes = index.getLocalizedAttributesSettings();

index.waitForTask(index.resetDisplayedAttributesSettings().getTaskUid());
index.waitForTask(index.resetLocalizedAttributesSettings().getTaskUid());
LocalizedAttribute[] localizedAttributesAfterReset = index.getLocalizedAttributesSettings();

assertThat(updatedLocalizedAttributes, is(arrayWithSize(newLocalizedAttributes.length)));
Expand Down Expand Up @@ -1057,6 +1057,39 @@ 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")
Expand Down

0 comments on commit f7476f5

Please sign in to comment.