Search in sources :

Example 81 with GlobalProperty

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());
}
Also used : GlobalProperty(org.openmrs.GlobalProperty) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 82 with GlobalProperty

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());
}
Also used : Locale(java.util.Locale) User(org.openmrs.User) GlobalProperty(org.openmrs.GlobalProperty) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 83 with GlobalProperty

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")));
}
Also used : ArrayList(java.util.ArrayList) GlobalProperty(org.openmrs.GlobalProperty) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 84 with GlobalProperty

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);
}
Also used : ArrayList(java.util.ArrayList) GlobalProperty(org.openmrs.GlobalProperty) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 85 with GlobalProperty

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());
}
Also used : GlobalProperty(org.openmrs.GlobalProperty) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

GlobalProperty (org.openmrs.GlobalProperty)110 Test (org.junit.Test)80 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)77 Locale (java.util.Locale)14 OrderUtilTest (org.openmrs.order.OrderUtilTest)14 Encounter (org.openmrs.Encounter)12 ArrayList (java.util.ArrayList)11 User (org.openmrs.User)11 Patient (org.openmrs.Patient)10 AdministrationService (org.openmrs.api.AdministrationService)10 BindException (org.springframework.validation.BindException)10 DrugOrder (org.openmrs.DrugOrder)9 Errors (org.springframework.validation.Errors)9 CareSetting (org.openmrs.CareSetting)7 OrderType (org.openmrs.OrderType)7 Date (java.util.Date)6 EncounterType (org.openmrs.EncounterType)5 APIException (org.openmrs.api.APIException)5 MutableMessageSource (org.openmrs.messagesource.MutableMessageSource)4 MutableResourceBundleMessageSource (org.openmrs.messagesource.impl.MutableResourceBundleMessageSource)4