@Test(expected = IllegalStateException.class) public void updateGlobalProperty_shouldFailIfGlobalPropertyBeingUpdatedDoesNotAlreadyExist() { executeDataSet("org/openmrs/api/include/AdministrationServiceTest-globalproperties.xml"); adminService.updateGlobalProperty("a_invalid_gp_key", "asdfsadfsafd"); }
@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 updateGlobalProperty_shouldUpdateGlobalPropertyInDatabase() { executeDataSet("org/openmrs/api/include/AdministrationServiceTest-globalproperties.xml"); String propertyValue = adminService.getGlobalProperty("a_valid_gp_key"); assertEquals("correct-value", propertyValue); adminService.updateGlobalProperty("a_valid_gp_key", "new-value"); String newValue = adminService.getGlobalProperty("a_valid_gp_key"); assertEquals("new-value", newValue); }