use of org.openmrs.GlobalProperty in project openmrs-core by openmrs.
the class AdministrationServiceTest method saveGlobalProperty_shouldOverwriteGlobalPropertyIfExists.
/**
* @see AdministrationService#saveGlobalProperty(GlobalProperty)
*/
@Test
public void saveGlobalProperty_shouldOverwriteGlobalPropertyIfExists() {
executeDataSet(ADMIN_INITIAL_DATA_XML);
AdministrationService as = Context.getAdministrationService();
GlobalProperty gp = as.getGlobalPropertyObject("a_valid_gp_key");
Assert.assertEquals("correct-value", gp.getPropertyValue());
gp.setPropertyValue("new-even-more-correct-value");
as.saveGlobalProperty(gp);
Assert.assertEquals("new-even-more-correct-value", as.getGlobalProperty("a_valid_gp_key"));
}
use of org.openmrs.GlobalProperty in project openmrs-core by openmrs.
the class AdministrationServiceTest method saveGlobalProperty_shouldSaveAGlobalPropertyWhoseTypedValueIsHandledByACustomDatatype.
/**
* @see AdministrationService#saveGlobalProperty(GlobalProperty)
*/
@Test
public void saveGlobalProperty_shouldSaveAGlobalPropertyWhoseTypedValueIsHandledByACustomDatatype() {
GlobalProperty gp = new GlobalProperty();
gp.setProperty("What time is it?");
gp.setDatatypeClassname(DateDatatype.class.getName());
gp.setValue(new Date());
adminService.saveGlobalProperty(gp);
Assert.assertNotNull(gp.getValueReference());
}
use of org.openmrs.GlobalProperty in project openmrs-core by openmrs.
the class PersonNameValidatorTest method validate_shouldSkipRegexValidationIfValidationStringIsNull.
/**
* @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")));
}
use of org.openmrs.GlobalProperty in project openmrs-core by openmrs.
the class DrugOrderValidatorTest method saveOrder_shouldFailDrugOrderWithNeitherDrugNonCodedNorDrugAreSetForDrugOrderWhenDrugRequiredSet.
@Test
public void saveOrder_shouldFailDrugOrderWithNeitherDrugNonCodedNorDrugAreSetForDrugOrderWhenDrugRequiredSet() {
Patient patient = Context.getPatientService().getPatient(7);
CareSetting careSetting = Context.getOrderService().getCareSetting(2);
OrderType orderType = Context.getOrderService().getOrderTypeByName("Drug order");
GlobalProperty gp = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_DRUG_ORDER_REQUIRE_DRUG, "true");
Context.getAdministrationService().saveGlobalProperty(gp);
// place drug order
DrugOrder order = new DrugOrder();
Encounter encounter = Context.getEncounterService().getEncounter(3);
order.setEncounter(encounter);
order.setPatient(patient);
order.setCareSetting(careSetting);
order.setOrderer(Context.getProviderService().getProvider(1));
order.setDateActivated(encounter.getEncounterDatetime());
order.setOrderType(orderType);
order.setDosingType(FreeTextDosingInstructions.class);
order.setInstructions("None");
order.setDosingInstructions("Test Instruction");
Errors errors = new BindException(order, "order");
new DrugOrderValidator().validate(order, errors);
Assert.assertTrue(errors.hasFieldErrors());
assertEquals("DrugOrder.error.drugIsRequired", errors.getFieldError("drug").getCode());
}
use of org.openmrs.GlobalProperty in project openmrs-core by openmrs.
the class DrugOrderValidatorTest method saveOrder_shouldPassDrugOrderWithoutADrugWhenDrugOrderRequireDrugGBIsFalse.
/**
* @see org.openmrs.api.OrderService#saveOrder(org.openmrs.Order, org.openmrs.api.OrderContext)
*/
@Test
public void saveOrder_shouldPassDrugOrderWithoutADrugWhenDrugOrderRequireDrugGBIsFalse() {
GlobalProperty gp = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_DRUG_ORDER_REQUIRE_DRUG, "false");
Context.getAdministrationService().saveGlobalProperty(gp);
Patient patient = Context.getPatientService().getPatient(7);
CareSetting careSetting = Context.getOrderService().getCareSetting(2);
OrderType orderType = Context.getOrderService().getOrderTypeByName("Drug order");
// place drug order
DrugOrder order = new DrugOrder();
Encounter encounter = Context.getEncounterService().getEncounter(3);
order.setEncounter(encounter);
order.setConcept(Context.getConceptService().getConcept(5497));
order.setPatient(patient);
order.setCareSetting(careSetting);
order.setOrderer(Context.getProviderService().getProvider(1));
order.setDateActivated(encounter.getEncounterDatetime());
order.setOrderType(orderType);
order.setDosingType(FreeTextDosingInstructions.class);
order.setInstructions("None");
order.setDosingInstructions("Test Instruction");
Errors errors = new BindException(order, "order");
new DrugOrderValidator().validate(order, errors);
Assert.assertFalse(errors.hasFieldErrors());
}
Aggregations