/** * @see org.openmrs.Attributable#getDisplayString() */ @Override public String getDisplayString() { return getName(); }
/** * @see java.lang.Object#toString() * @should not fail with empty object */ @Override public String toString() { String ret = ""; ret += encounterId == null ? "(no ID) " : encounterId.toString() + " "; ret += this.getEncounterDatetime() == null ? "(no Date) " : this.getEncounterDatetime().toString() + " "; ret += this.getEncounterType() == null ? "(no Type) " : this.getEncounterType().getName() + " "; ret += this.getLocation() == null ? "(no Location) " : this.getLocation().getName() + " "; ret += this.getPatient() == null ? "(no Patient) " : this.getPatient().getPatientId().toString() + " "; ret += this.getForm() == null ? "(no Form) " : this.getForm().getName() + " "; ret += "num Obs: " + this.getObsAtTopLevel(false) + " "; ret += "num Orders: " + this.getOrders().size() + " "; return "Encounter: [" + ret + "]"; }
/** * @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()); }
String origName = location.getName(); String origDesc = location.getDescription(); assertTrue("The name should be the same", newestLoc.getName().equals(newName)); assertFalse("The name should be different", origDesc.equals(newDesc)); assertTrue("The name should be the same", newestLoc.getDescription().equals(newDesc));
/** * @see OpenmrsMetadataSaveHandler#handle(OpenmrsMetadata,User,Date,String) */ @Test public void handle_shouldTrimWhitespaceFromName() { String NAME = "the location name"; OpenmrsMetadataSaveHandler handler = new OpenmrsMetadataSaveHandler(); Location loc = new Location(); loc.setName(" " + NAME + " "); handler.handle(loc, null, null, null); Assert.assertEquals(NAME, loc.getName()); }
if (location.getName() == null) { throw new APIException("Location.name.required", (Object[]) null);
/** * @see LocationService#getDefaultLocation() */ @Test public void getDefaultLocation_shouldReturnDefaultLocationForTheImplementation() { //set the global property for default location to something other than Unknown Location GlobalProperty gp = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_DEFAULT_LOCATION_NAME, "Test Parent Location", "Testing default Location"); Context.getAdministrationService().saveGlobalProperty(gp); Assert.assertEquals("Test Parent Location", Context.getLocationService().getDefaultLocation().getName()); }
/** * @see LocationService#getDefaultLocation() */ @Test public void getDefaultLocation_shouldReturnUnknownLocationIfTheGlobalPropertyIsSomethingElseThatDoesnotExist() { //set the global property to something that has no match in the location table GlobalProperty gp = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_DEFAULT_LOCATION_NAME, "None existent Location", "Testing"); Context.getAdministrationService().saveGlobalProperty(gp); Assert.assertEquals("Unknown Location", Context.getLocationService().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()); } }
Location exist = Context.getLocationService().getLocation(location.getName()); if (exist != null && !exist.getRetired() && !OpenmrsUtil.nullSafeEquals(location.getUuid(), exist.getUuid())) { errors.rejectValue("name", "location.duplicate.name");
@Override public boolean matches(Object o) { Location location = (Location) o; return new EqualsBuilder().append(location.getName(), facility.getName()) .append(location.getCountry(), facility.getCountry()) .append(location.getAddress6(), facility.getRegion()) .append(location.getStateProvince(), facility.getStateProvince()) .append(location.getCountyDistrict(), facility.getCountyDistrict()) .isEquals(); } };
MRSFacility convertLocationToFacility(Location savedLocation) { return new OpenMRSFacility(String.valueOf(savedLocation.getId()), savedLocation.getName(), savedLocation.getCountry(), savedLocation.getAddress6(), savedLocation.getCountyDistrict(), savedLocation.getStateProvince()); }
/** * @see {@link HtmlFormEntryUtil#getLocation(String)} id test */ @Test @Verifies(value = "should find a location by its id", method = "getLocation(String)") public void getLocation_shouldFindALocationByItsId() throws Exception { Assert.assertEquals("Xanadu", HtmlFormEntryUtil.getLocation("2").getName()); }
/** * @see {@link HtmlFormEntryUtil#getLocation(String)} this is the uuid test */ @Test @Verifies(value = "should find a location by its uuid", method = "getLocation(String)") public void getLocation_shouldFindALocationByItsUuid() throws Exception { Assert.assertEquals("Xanadu", HtmlFormEntryUtil.getLocation("9356400c-a5a2-4532-8f2b-2361b3446eb8").getName()); }
public PersonAddress build() { PersonAddress address = new PersonAddress(); address.setAddress1(addressLine1); if (community != null) { address.setAddress2(community.getName()); } address.setRegion(location.getRegion()); address.setCountyDistrict(location.getCountyDistrict()); address.setStateProvince(location.getStateProvince()); address.setNeighborhoodCell(location.getName()); return address; }
@Test public void shouldGetALocationByName() throws Exception { MockHttpServletRequest req = request(RequestMethod.GET, getURI() + "/Xanadu"); SimpleObject result = deserialize(handle(req)); Location location = service.getLocation("Xanadu"); Assert.assertNotNull(result); Assert.assertEquals(location.getUuid(), PropertyUtils.getProperty(result, "uuid")); Assert.assertEquals(location.getName(), PropertyUtils.getProperty(result, "name")); }
@Test public void shouldGetALocationByUuid() throws Exception { MockHttpServletRequest req = request(RequestMethod.GET, getURI() + "/" + getUuid()); SimpleObject result = deserialize(handle(req)); Location location = service.getLocationByUuid(getUuid()); Assert.assertNotNull(result); Assert.assertEquals(location.getUuid(), PropertyUtils.getProperty(result, "uuid")); Assert.assertEquals(location.getName(), PropertyUtils.getProperty(result, "name")); }
@Test public void shouldEditALocation() throws Exception { final String editedName = "Xanadu edited"; String json = "{ \"name\":\"" + editedName + "\" }"; MockHttpServletRequest req = request(RequestMethod.POST, getURI() + "/" + getUuid()); req.setContent(json.getBytes()); handle(req); Location editedLocation = service.getLocationByUuid(getUuid()); Assert.assertNotNull(editedLocation); Assert.assertEquals(editedName, editedLocation.getName()); }