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()));
}
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));
}
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());
}
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 \\-]+$"));
}
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")));
}
Aggregations