use of org.openmrs.GlobalProperty in project openmrs-core by openmrs.
the class AdministrationServiceTest method getGlobalPropertyByUuid_shouldFindObjectGivenValidUuid.
/**
* @see AdministrationService#getGlobalPropertyByUuid(String)
*/
@Test
public void getGlobalPropertyByUuid_shouldFindObjectGivenValidUuid() {
String uuid = "4f55827e-26fe-102b-80cb-0017a47871b3";
GlobalProperty prop = Context.getAdministrationService().getGlobalPropertyByUuid(uuid);
Assert.assertEquals("locale.allowed.list", prop.getProperty());
}
use of org.openmrs.GlobalProperty in project openmrs-core by openmrs.
the class AdministrationServiceTest method saveGlobalProperty_shouldEvictCachedResults.
/**
* @see AdministrationService#saveGlobalProperty(GlobalProperty)
*/
@Test
public void saveGlobalProperty_shouldEvictCachedResults() {
// given
Context.getAdministrationService().saveGlobalProperty(new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_LOCALE_ALLOWED_LIST, "en_GB, en_US, pl"));
User user = Context.getAuthenticatedUser();
user.setUserProperty(OpenmrsConstants.USER_PROPERTY_PROFICIENT_LOCALES, "en_GB, en_US");
Context.getUserService().saveUser(user);
// sanity check that cache has been populated
Context.getAdministrationService().getSearchLocales();
List<Locale> cachedSearchLocales = getCachedSearchLocalesForCurrentUser();
assertThat(cachedSearchLocales, hasItem(new Locale("en", "US")));
// evict cache
Context.getAdministrationService().saveGlobalProperty(new GlobalProperty("test", "TEST"));
assertThat(getCacheForCurrentUser(), nullValue());
}
use of org.openmrs.GlobalProperty in project openmrs-core by openmrs.
the class AdministrationServiceTest method saveGlobalProperties_shouldSavePropertiesWithCaseDifferenceOnly.
/**
* @see AdministrationService#saveGlobalProperties(List<QGlobalProperty;>)
*/
@Test
public void saveGlobalProperties_shouldSavePropertiesWithCaseDifferenceOnly() {
int originalSize = adminService.getAllGlobalProperties().size();
List<GlobalProperty> props = new ArrayList<>();
props.add(new GlobalProperty("a.property.key", "something"));
props.add(new GlobalProperty("a.property.KEY", "somethingelse"));
adminService.saveGlobalProperties(props);
// make sure that we now have two properties
props = adminService.getAllGlobalProperties();
Assert.assertEquals(originalSize + 1, props.size());
Assert.assertTrue(props.contains(adminService.getGlobalPropertyObject("a.property.KEY")));
}
use of org.openmrs.GlobalProperty in project openmrs-core by openmrs.
the class AdministrationServiceTest method purgeGlobalProperties_shouldDeleteGlobalPropertiesFromDatabase.
/**
* @see AdministrationService#purgeGlobalProperties(List)
*/
@Test
public void purgeGlobalProperties_shouldDeleteGlobalPropertiesFromDatabase() {
int originalSize = adminService.getAllGlobalProperties().size();
List<GlobalProperty> props = new ArrayList<>();
props.add(new GlobalProperty("a.property.key", "something"));
props.add(new GlobalProperty("a.property.KEY", "somethingelse"));
adminService.saveGlobalProperties(props);
int afterSaveSize = adminService.getAllGlobalProperties().size();
Assert.assertEquals(originalSize + 1, afterSaveSize);
adminService.purgeGlobalProperties(props);
int afterPurgeSize = adminService.getAllGlobalProperties().size();
Assert.assertEquals(originalSize, afterPurgeSize);
}
use of org.openmrs.GlobalProperty in project openmrs-core by openmrs.
the class AdministrationServiceTest method getAllowedLocales_shouldNotReturnDuplicatesEvenIfTheGlobalPropertyHasThem.
/**
* @see AdministrationService#getAllowedLocales()
*/
@Test
public void getAllowedLocales_shouldNotReturnDuplicatesEvenIfTheGlobalPropertyHasThem() {
Context.getAdministrationService().saveGlobalProperty(new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_LOCALE_ALLOWED_LIST, "en_GB,fr,es,en_GB"));
Assert.assertEquals(3, Context.getAdministrationService().getAllowedLocales().size());
}
Aggregations