Skip to content

Commit

Permalink
fix: testSearchTokenWithNullLocale fail randomly (#16110)
Browse files Browse the repository at this point in the history
  • Loading branch information
vietnguyen authored Jan 9, 2024
1 parent 202bb64 commit 91df59a
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import java.util.Locale;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.i18n.locale.LocaleManager;
import org.hisp.dhis.jsontree.JsonArray;
import org.hisp.dhis.setting.SettingKey;
import org.hisp.dhis.setting.SystemSettingManager;
Expand Down Expand Up @@ -134,10 +135,17 @@ void testSearchTokenDefaultLocale() {
@DisplayName("Search by token should use default properties instead of translations column")
void testSearchTokenWithNullLocale() {
setUpTranslation();
doInTransaction(
() -> systemSettingManager.saveSystemSetting(SettingKey.DB_LOCALE, Locale.ENGLISH));
systemSettingManager.invalidateCache();
assertEquals(
Locale.ENGLISH,
systemSettingManager.getSystemSetting(SettingKey.DB_LOCALE, LocaleManager.DEFAULT_LOCALE));

User userA = createAndAddUser("userA", null, "ALL");
injectSecurityContext(userA);
userSettingService.saveUserSetting(UserSettingKey.DB_LOCALE, null);

systemSettingManager.saveSystemSetting(SettingKey.DB_LOCALE, Locale.ENGLISH);
assertTrue(
GET("/dataSets?filter=identifiable:token:bb").content().getArray("dataSets").isEmpty());
assertTrue(
Expand Down Expand Up @@ -165,11 +173,10 @@ private void setUpTranslation() {
"{'translations': [{'locale':'fr', 'property':'NAME', 'value':'fr dataSet'}]}")
.content(HttpStatus.NO_CONTENT);

assertEquals(1, GET("/dataSets", id).content().getArray("dataSets").size());

JsonArray translations =
GET("/dataSets/{id}/translations", id).content().getArray("translations");
assertEquals(1, translations.size());

assertTrue(
GET("/dataSets?filter=identifiable:token:fr", id).content().getArray("dataSets").isEmpty());
}
}

0 comments on commit 91df59a

Please sign in to comment.