/** * @see org.openmrs.api.AdministrationService#setGlobalProperty(java.lang.String, * java.lang.String) */ @Override public void setGlobalProperty(String propertyName, String propertyValue) throws APIException { GlobalProperty gp = Context.getAdministrationService().getGlobalPropertyObject(propertyName); if (gp == null) { gp = new GlobalProperty(); gp.setProperty(propertyName); } gp.setPropertyValue(propertyValue); Context.getAdministrationService().saveGlobalProperty(gp); }
@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); assertNotNull(gp.getValueReference()); }
/** * @throws HL7Exception * @throws IOException * @see HL7Service#processHL7InQueue(HL7InQueue) */ @Test public void processHL7InQueue_shouldCreateHL7InArchiveAfterSuccessfulParsing() throws HL7Exception, IOException { executeDataSet("org/openmrs/hl7/include/ORUTest-initialData.xml"); File tempDir = new File(System.getProperty("java.io.tmpdir"), HL7Constants.HL7_ARCHIVE_DIRECTORY_NAME); if (tempDir.exists() && tempDir.isDirectory()) Assert.assertEquals(true, OpenmrsUtil.deleteDirectory(tempDir)); //set a global property for the archives directory as a temporary folder GlobalProperty gp = new GlobalProperty(); gp.setProperty(OpenmrsConstants.GLOBAL_PROPERTY_HL7_ARCHIVE_DIRECTORY); gp.setPropertyValue(tempDir.getAbsolutePath()); gp.setDescription("temp test dir"); Context.getAdministrationService().saveGlobalProperty(gp); HL7Service hl7service = Context.getHL7Service(); Assert.assertEquals(0, hl7service.getAllHL7InArchives().size()); HL7InQueue queueItem = hl7service.getHL7InQueue(1); hl7service.processHL7InQueue(queueItem); Assert.assertEquals(1, hl7service.getAllHL7InArchives().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"); }