/** * @see OrderService#getDrugDispensingUnits() */ @Test public void getDrugDispensingUnits_shouldReturnAnEmptyListIfNothingIsConfigured() { adminService.saveGlobalProperty(new GlobalProperty(OpenmrsConstants.GP_DRUG_DISPENSING_UNITS_CONCEPT_UUID, "")); adminService.saveGlobalProperty(new GlobalProperty(OpenmrsConstants.GP_DRUG_DOSING_UNITS_CONCEPT_UUID, "")); assertThat(orderService.getDrugDispensingUnits(), is(empty())); }
/** * Utility method that creates the global property concept.unknown' */ private static void createUnknownConceptGlobalProperty() { GlobalProperty unknownConceptGlobalProperty = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_UNKNOWN_CONCEPT, "9", "Concept id of the concept defining the UNKNOWN concept"); Context.getAdministrationService().saveGlobalProperty(unknownConceptGlobalProperty); }
/** * Utility method that creates the global properties 'concept.true' and 'concept.false' */ private static void createTrueFalseGlobalProperties() { GlobalProperty trueConceptGlobalProperty = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_TRUE_CONCEPT, "7", "Concept id of the concept defining the TRUE boolean concept"); GlobalProperty falseConceptGlobalProperty = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_FALSE_CONCEPT, "8", "Concept id of the concept defining the TRUE boolean concept"); Context.getAdministrationService().saveGlobalProperty(trueConceptGlobalProperty); Context.getAdministrationService().saveGlobalProperty(falseConceptGlobalProperty); }
/** * @see OrderService#getTestSpecimenSources() */ @Test public void getTestSpecimenSources_shouldReturnAnEmptyListIfNothingIsConfigured() { adminService.saveGlobalProperty(new GlobalProperty(OpenmrsConstants.GP_TEST_SPECIMEN_SOURCES_CONCEPT_UUID, "")); assertThat(orderService.getTestSpecimenSources(), is(empty())); }
/** * @see OrderService#getDrugDosingUnits() */ @Test public void getDrugDosingUnits_shouldReturnAnEmptyListIfNothingIsConfigured() { adminService.saveGlobalProperty(new GlobalProperty(OpenmrsConstants.GP_DRUG_DOSING_UNITS_CONCEPT_UUID, "")); assertThat(orderService.getDrugDosingUnits(), is(empty())); }
/** * @see OrderService#getDurationUnits() */ @Test public void getDurationUnits_shouldReturnAnEmptyListIfNothingIsConfigured() { adminService.saveGlobalProperty(new GlobalProperty(OpenmrsConstants.GP_DURATION_UNITS_CONCEPT_UUID, "")); assertThat(orderService.getDurationUnits(), is(empty())); }
@Test public void saveGlobalProperty_shouldFailIfGivenAllowedLocaleListDoesNotContainDefaultLocale() { String localeList = "fr,es"; assertThat("localeList contains default locale but should not for this test case", localeList, not(containsString(LocaleUtility.getDefaultLocale().toString()))); expectedException.expect(APIException.class); expectedException.expectMessage("can not be removed from allowed locales list because it is the default locale"); adminService.saveGlobalProperty( new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_LOCALE_ALLOWED_LIST, localeList)); }
/** * Creates a new Global Property to lock patient identifier types by setting its value * * @param propertyValue value for patient identifier types locked GP */ public void createPatientIdentifierTypeLockedGPAndSetValue(String propertyValue) { GlobalProperty gp = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_IDENTIFIER_TYPES_LOCKED); gp.setPropertyValue(propertyValue); Context.getAdministrationService().saveGlobalProperty(gp); }
/** * Creates a new Global Property to lock person attribute types by setting its value * @param propertyValue value for person attribute types locked GP */ public void createPersonAttributeTypeLockedGPAndSetValue(String propertyValue) { GlobalProperty gp = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PERSON_ATRIBUTE_TYPES_LOCKED); gp.setPropertyValue(propertyValue); Context.getAdministrationService().saveGlobalProperty(gp); }
@Test public void getAllowedLocales_shouldNotReturnDuplicatesEvenIfTheGlobalPropertyHasThem() { adminService.saveGlobalProperty( new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_LOCALE_ALLOWED_LIST, "en_GB,fr,es,en_GB")); assertEquals(3, adminService.getAllowedLocales().size()); }
/** * @see PatientNameValidator#validatePersonName(java.lang.Object, org.springframework.validation.Errors, boolean, boolean) */ @Test public void validate_shouldSkipRegexValidationIfValidationStringIsNull() { Context.getAdministrationService().saveGlobalProperty( new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_NAME_REGEX, null)); personName.setFamilyName("asd123"); validator.validatePersonName(personName, errors, false, true); assertThat(errors, not(hasFieldErrors("familyName"))); }
/** * @see OrderService#getNonCodedDrugConcept() */ @Test public void getNonCodedDrugConcept_shouldReturnNullIfNothingIsConfigured() { adminService.saveGlobalProperty(new GlobalProperty(OpenmrsConstants.GP_DRUG_ORDER_DRUG_OTHER, "")); assertNull(orderService.getNonCodedDrugConcept()); }
@Test(expected = APIException.class) public void getActiveEncounterVisitHandler_shouldThrowIfBeanWithGivenTypeAndNameNotFound() { String incorrectBeanName = OpenmrsConstants.REGISTERED_COMPONENT_NAME_PREFIX + "invalidName"; GlobalProperty visitHandlerProperty = new GlobalProperty(OpenmrsConstants.GP_VISIT_ASSIGNMENT_HANDLER, incorrectBeanName); Context.getAdministrationService().saveGlobalProperty(visitHandlerProperty); Context.getEncounterService().getActiveEncounterVisitHandler(); }
@Test public void saveGlobalProperty_shouldCreateGlobalPropertyInDatabase() { executeDataSet(ADMIN_INITIAL_DATA_XML); adminService.saveGlobalProperty(new GlobalProperty("detectHiddenSkill", "100")); assertNotNull(adminService.getGlobalProperty("detectHiddenSkill")); }
/** * @see LocaleUtility#getDefaultLocale() */ @Test public void getDefaultLocale_shouldNotFailWithEmptyGlobalPropertyValue() { Context.getAdministrationService().saveGlobalProperty( new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_DEFAULT_LOCALE, "")); // check for nonnullness Assert.assertNotNull(LocaleUtility.getDefaultLocale()); }
/** * @see PatientService#getPatients(String) */ @Test public void getPatients_shouldForceSearchStringToBeGreaterThanMinsearchcharactersGlobalProperty() throws Exception { // make sure we can get patients with the default of 3 assertEquals(1, Context.getPatientService().getPatients("Colle").size()); Context.clearSession(); Context.getAdministrationService().saveGlobalProperty( new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_MIN_SEARCH_CHARACTERS, "4")); assertEquals(0, Context.getPatientService().getPatients("Col").size()); }
@Test public void updateGlobalProperty_shouldUpdateAGlobalPropertyWhoseTypedvalueIsHandledByACustomDatatype() { GlobalProperty gp = new GlobalProperty(); gp.setProperty("Flag"); gp.setDatatypeClassname(BooleanDatatype.class.getName()); gp.setValue(Boolean.FALSE); adminService.saveGlobalProperty(gp); assertEquals(adminService.getGlobalProperty("Flag"), "false"); adminService.updateGlobalProperty("Flag", Boolean.TRUE.toString()); assertEquals(adminService.getGlobalProperty("Flag"), "true"); }
@Test public void getActiveEncounterVisitHandler_shouldReturnBeanHaveBeenRegisteredWithGivenName() { String correctBeanName = OpenmrsConstants.REGISTERED_COMPONENT_NAME_PREFIX + "existingOrNewVisitAssignmentHandler"; GlobalProperty visitHandlerProperty = new GlobalProperty(OpenmrsConstants.GP_VISIT_ASSIGNMENT_HANDLER, correctBeanName); Context.getAdministrationService().saveGlobalProperty(visitHandlerProperty); EncounterVisitHandler activeEncounterVisitHandler = Context.getEncounterService().getActiveEncounterVisitHandler(); Assert.assertNotNull(activeEncounterVisitHandler); }
/** * @see ConceptService#getDefaultConceptMapType() */ @Test public void getDefaultConceptMapType_shouldReturnTypeAsSetInGp() { final String testName = "is a"; Context.getAdministrationService().saveGlobalProperty(new GlobalProperty("concept.defaultConceptMapType", testName)); ConceptMapType conceptMapType = conceptService.getDefaultConceptMapType(); Assert.assertNotNull(conceptMapType); Assert.assertEquals(testName, conceptMapType.getName()); }
@Test public void saveGlobalProperty_shouldOverwriteGlobalPropertyIfExists() { executeDataSet(ADMIN_INITIAL_DATA_XML); GlobalProperty gp = adminService.getGlobalPropertyObject("a_valid_gp_key"); assertEquals("correct-value", gp.getPropertyValue()); gp.setPropertyValue("new-even-more-correct-value"); adminService.saveGlobalProperty(gp); assertEquals("new-even-more-correct-value", adminService.getGlobalProperty("a_valid_gp_key")); }