Search in sources :

Example 71 with GlobalProperty

use of org.openmrs.GlobalProperty in project openmrs-core by openmrs.

the class ModuleFileParserTest method parse_shouldParseGlobalPropertyContainingElementsNotIncludedInGlobalProperty.

@Test
public void parse_shouldParseGlobalPropertyContainingElementsNotIncludedInGlobalProperty() throws IOException {
    GlobalProperty gp1 = new GlobalProperty("report.deleteReportsAgeInHours", "72", "delete reports after");
    Document config = buildOnValidConfigXml().withGlobalProperty(gp1.getProperty(), gp1.getPropertyValue(), gp1.getDescription(), null, null).build();
    config.getElementsByTagName("globalProperty").item(0).appendChild(config.createElement("ignoreMe"));
    ModuleFileParser parser = new ModuleFileParser(writeConfigXmlToFile(config));
    Module module = parser.parse();
    assertThat(module.getGlobalProperties().size(), is(1));
    assertThat(module.getGlobalProperties().get(0).getProperty(), is(gp1.getProperty()));
    assertThat(module.getGlobalProperties().get(0).getPropertyValue(), is(gp1.getPropertyValue()));
    assertThat(module.getGlobalProperties().get(0).getDescription(), is(gp1.getDescription()));
}
Also used : Document(org.w3c.dom.Document) GlobalProperty(org.openmrs.GlobalProperty) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 72 with GlobalProperty

use of org.openmrs.GlobalProperty in project openmrs-core by openmrs.

the class GlobalLocaleListTest method globalPropertyChanged_shouldSetAllowedLocalesIfGlobalPropertyContainsTwoLocales.

@Test
public void globalPropertyChanged_shouldSetAllowedLocalesIfGlobalPropertyContainsTwoLocales() {
    GlobalProperty gp = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_LOCALE_ALLOWED_LIST, "en_CA,fr");
    globalLocaleList.globalPropertyChanged(gp);
    assertThat(globalLocaleList.getAllowedLocales(), contains(Locale.CANADA, Locale.FRENCH));
}
Also used : GlobalProperty(org.openmrs.GlobalProperty) Test(org.junit.Test)

Example 73 with GlobalProperty

use of org.openmrs.GlobalProperty in project openmrs-core by openmrs.

the class ExistingOrNewVisitAssignmentHandlerTest method beforeCreateEncounter_shouldAssignMappingGlobalPropertyVisitType.

/**
 * @see ExistingVisitAssignmentHandler#beforeCreateEncounter(Encounter)
 */
@Test
public void beforeCreateEncounter_shouldAssignMappingGlobalPropertyVisitType() {
    Encounter encounter = Context.getEncounterService().getEncounter(1);
    Assert.assertNull(encounter.getVisit());
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(encounter.getEncounterDatetime());
    calendar.set(Calendar.YEAR, 1900);
    encounter.setEncounterDatetime(calendar.getTime());
    GlobalProperty gp = new GlobalProperty(OpenmrsConstants.GP_ENCOUNTER_TYPE_TO_VISIT_TYPE_MAPPING, "3:4, 5:2, 1:2, 2:2");
    Context.getAdministrationService().saveGlobalProperty(gp);
    new ExistingOrNewVisitAssignmentHandler().beforeCreateEncounter(encounter);
    Assert.assertNotNull(encounter.getVisit());
    // should be set according to: 1:2 encounterTypeId:visitTypeId
    Assert.assertEquals(1, encounter.getEncounterType().getEncounterTypeId().intValue());
    Assert.assertEquals(Context.getVisitService().getVisitType(2), encounter.getVisit().getVisitType());
}
Also used : Calendar(java.util.Calendar) Encounter(org.openmrs.Encounter) GlobalProperty(org.openmrs.GlobalProperty) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 74 with GlobalProperty

use of org.openmrs.GlobalProperty in project openmrs-core by openmrs.

the class PersonNameValidatorTest method setUp.

@Before
public void setUp() {
    validator = new PersonNameValidator();
    personName = new PersonName();
    errors = new BindException(personName, "personName");
    Context.getAdministrationService().saveGlobalProperty(new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_NAME_REGEX, "^[a-zA-Z \\-]+$"));
}
Also used : PersonName(org.openmrs.PersonName) BindException(org.springframework.validation.BindException) GlobalProperty(org.openmrs.GlobalProperty) Before(org.junit.Before)

Example 75 with GlobalProperty

use of org.openmrs.GlobalProperty in project openmrs-core by openmrs.

the class PersonNameValidatorTest method validate_shouldSkipRegexValidationIfValidationStringIsEmpty.

/**
 * @see PatientNameValidator#validatePersonName(java.lang.Object, org.springframework.validation.Errors, boolean, boolean)
 */
@Test
public void validate_shouldSkipRegexValidationIfValidationStringIsEmpty() {
    Context.getAdministrationService().saveGlobalProperty(new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_NAME_REGEX, ""));
    personName.setGivenName("123asd");
    validator.validatePersonName(personName, errors, false, true);
    assertThat(errors, not(hasFieldErrors("givenName")));
}
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