/** * @see org.openmrs.api.GlobalPropertyListener#globalPropertyDeleted(java.lang.String) */ @Override public void globalPropertyDeleted(String propertyName) { // reset the value setDefaultLocation(null); }
/** * @see LocationUtility#getDefaultLocation() */ @Test public void getDefaultLocation_shouldReturnTheUpdatedDefaultLocationWhenTheValueOfTheGlobalPropertyIsChanged() { //sanity check Assert.assertEquals("Unknown Location", LocationUtility.getDefaultLocation().getName()); GlobalProperty gp = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_DEFAULT_LOCATION_NAME, "Xanadu", "Testing"); Context.getAdministrationService().saveGlobalProperty(gp); Assert.assertEquals("Xanadu", LocationUtility.getDefaultLocation().getName()); }
/** * @see LocationUtility#getUserDefaultLocation() */ @Test public void getUserDefaultLocation_shouldReturnTheUserSpecifiedLocationIfAnyIsSet() { //sanity check Assert.assertNull(LocationUtility.getUserDefaultLocation()); User user = Context.getAuthenticatedUser(); Map<String, String> properties = user.getUserProperties(); properties.put(OpenmrsConstants.USER_PROPERTY_DEFAULT_LOCATION, "2"); user.setUserProperties(properties); Context.getUserService().saveUser(user); Context.refreshAuthenticatedUser(); Assert.assertEquals("Xanadu", LocationUtility.getUserDefaultLocation().getName()); } }
/** * @see org.openmrs.api.GlobalPropertyListener#globalPropertyChanged(org.openmrs.GlobalProperty) */ @Override public void globalPropertyChanged(GlobalProperty newValue) { // reset the value setDefaultLocation(null); }