/** * @see org.openmrs.api.LocationService#saveAddressTemplate(String) */ @Override public void saveAddressTemplate(String xml) throws APIException { Context.getAdministrationService().setGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_ADDRESS_TEMPLATE, xml); }
@Test public void getPersonAttributeTypes_shouldReturnPatientAttributesWhenViewTypeViewingAndPatient() { adminService.setGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_VIEWING_ATTRIBUTES, "1"); adminService.setGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_USER_VIEWING_ATTRIBUTES, "2"); PersonAttributeType race = personService.getPersonAttributeType(1); List<PersonAttributeType> result = personService.getPersonAttributeTypes(OpenmrsConstants.PERSON_TYPE.PATIENT, PersonService.ATTR_VIEW_TYPE.VIEWING); assertThat(result, contains(race)); assertEquals(result.size(), 1); }
@Test public void getPersonAttributeTypes_shouldReturnUserAttributesWhenViewTypeHeaderAndUser() { adminService.setGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_HEADER_ATTRIBUTES, "1"); adminService.setGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_USER_HEADER_ATTRIBUTES, "2"); PersonAttributeType birthplace = personService.getPersonAttributeType(2); List<PersonAttributeType> result = personService.getPersonAttributeTypes(OpenmrsConstants.PERSON_TYPE.USER, PersonService.ATTR_VIEW_TYPE.HEADER); assertThat(result, contains(birthplace)); assertEquals(result.size(), 1); } }
@Test public void getPersonAttributeTypes_shouldReturnUserAndPatientAttributesWhenViewTypeListiningAndPerson() { adminService.setGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_LISTING_ATTRIBUTES, "1"); adminService.setGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_USER_LISTING_ATTRIBUTES, "2"); PersonAttributeType race = personService.getPersonAttributeType(1); PersonAttributeType birthplace = personService.getPersonAttributeType(2); List<PersonAttributeType> result = personService.getPersonAttributeTypes(OpenmrsConstants.PERSON_TYPE.PERSON, PersonService.ATTR_VIEW_TYPE.LISTING); assertThat(result, contains(race, birthplace)); assertEquals(result.size(), 2); }
@Test public void getPersonAttributeTypes_shouldReturnPatientAttributesWhenGivenViewTypeListing() { adminService.setGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_LISTING_ATTRIBUTES, "1"); PersonAttributeType race = personService.getPersonAttributeType(1); List<PersonAttributeType> result = personService.getPersonAttributeTypes(null, PersonService.ATTR_VIEW_TYPE.LISTING); assertThat(result, contains(race)); assertEquals(result.size(), 1); }
public String setGlobalProperty(String propertyName, String propertyValue) { String oldPropertyValue = administrationService.getGlobalProperty(propertyName); administrationService.setGlobalProperty(propertyName, propertyValue); Assert.assertEquals(propertyValue, administrationService.getGlobalProperty(propertyName)); return oldPropertyValue; }
@Test public void setGlobalProperty_shouldSaveAGlobalPropertyWhoseTypedValueIsHandledByACustomDatatype() { String newKey = "Flag"; String initialValue = adminService.getGlobalProperty(newKey); assertNull(initialValue); adminService.setGlobalProperty(newKey, Boolean.FALSE.toString()); assertEquals(adminService.getGlobalProperty("Flag"), "false"); }
@Test public void getPersonAttributeTypes_shouldReturnListWithNullWhenGlobalPropertyNotExists() { adminService.setGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_LISTING_ATTRIBUTES, "9"); assertNull(personService.getPersonAttributeType(9)); List<PersonAttributeType> result = personService.getPersonAttributeTypes(null, PersonService.ATTR_VIEW_TYPE.LISTING); // This is a bug Trunk-5149 assertEquals(result.size(), 1); assertNull(result.get(0)); }
@Test public void getPersonAttributeTypes_shouldReturnNothingWhenGlobalPropertyLargerNineExists() { adminService.setGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_LISTING_ATTRIBUTES, "99"); executeDataSet(CREATE_PERSON_PROPERTY_XML); assertNotNull(personService.getPersonAttributeType(99)); List<PersonAttributeType> result = personService.getPersonAttributeTypes(null, PersonService.ATTR_VIEW_TYPE.LISTING); // This is probably a bug TRUNK-5148 assertEquals(result.size(), 1); assertNull(result.get(0)); }
System.out.println("Starts with search for 'Jack Sehgal' name limited to 15 results returned in " + time + " ms"); Context.getAdministrationService().setGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_SEARCH_MATCH_MODE, OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_SEARCH_MATCH_ANYWHERE); System.out.println("Exact search for 'London' attribute limited to 15 results returned in " + time + " ms"); Context.getAdministrationService().setGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PERSON_ATTRIBUTE_SEARCH_MATCH_MODE, OpenmrsConstants.GLOBAL_PROPERTY_PERSON_ATTRIBUTE_SEARCH_MATCH_ANYWHERE);
@Test public void setGlobalProperty_shouldCreateGlobalPropertyInDatabase() { String newKey = "new_gp_key"; String initialValue = adminService.getGlobalProperty(newKey); assertNull(initialValue); // ensure gp doesn't exist before test adminService.setGlobalProperty(newKey, "new_key"); String newValue = adminService.getGlobalProperty(newKey); assertNotNull(newValue); }
@Test public void setGlobalProperty_shouldOverwriteGlobalPropertyIfExists() { executeDataSet("org/openmrs/api/include/AdministrationServiceTest-globalproperties.xml"); String propertyValue = adminService.getGlobalProperty("a_valid_gp_key"); assertEquals("correct-value", propertyValue); adminService.setGlobalProperty("a_valid_gp_key", "new-value"); String newValue = adminService.getGlobalProperty("a_valid_gp_key"); assertEquals("new-value", newValue); }
@Ignore("TRUNK-5425") @Test public void setUserActivationKey_shouldCreateUserActivationKey() throws MessageException { User u = new User(); u.setPerson(new Person()); u.addName(new PersonName("Benjamin", "A", "Wolfe")); u.setUsername("bwolfe"); u.getPerson().setGender("M"); Context.getAdministrationService().setGlobalProperty(OpenmrsConstants.GP_HOST_URL, "http://localhost:8080/openmrs/admin/users/changePassword.form/{activationKey}"); User createdUser = userService.createUser(u, "Openmr5xy"); assertNull(dao.getLoginCredential(createdUser).getActivationKey()); assertEquals(createdUser, userService.setUserActivationKey(createdUser)); assertNotNull(dao.getLoginCredential(createdUser).getActivationKey()); }