/** * @see org.openmrs.Attributable#findPossibleValues(java.lang.String) */ @Override public List<Location> findPossibleValues(String searchText) { try { return Context.getLocationService().getLocations(searchText); } catch (Exception e) { return Collections.emptyList(); } }
@Override protected LocationAttributeType getObjectByUuid(String uuid) { return Context.getLocationService().getLocationAttributeTypeByUuid(uuid); } }
@Override protected LocationTag getObjectByUuid(String uuid) { return Context.getLocationService().getLocationTagByUuid(uuid); } }
/** * @see org.openmrs.Attributable#hydrate(java.lang.String) */ @Override public Location hydrate(String locationId) { try { return Context.getLocationService().getLocation(Integer.valueOf(locationId)); } catch (Exception e) { return new Location(); } }
/** * @see org.openmrs.api.LocationService#retireLocation(Location, String) */ @Override public Location retireLocation(Location location, String reason) throws APIException { location.setRetired(true); location.setRetireReason(reason); return Context.getLocationService().saveLocation(location); }
/** * @see LocationService#getAllLocations(null) */ @Test public void getAllLocations_shouldReturnOnlyUnretiredLocationsWhenIncludeRetiresIsFalse() { List<Location> locations = Context.getLocationService().getAllLocations(false); Assert.assertEquals(5, locations.size()); }
/** * @see LocationService#getAllLocationTags() */ @Test public void getAllLocationTags_shouldReturnAllLocationTagsIncludingRetired() { List<LocationTag> tags = Context.getLocationService().getAllLocationTags(); Assert.assertEquals(6, tags.size()); }
@Test public void getPatientIdentifiers_shouldLimitByResultsByLocation() { Location location = Context.getLocationService().getLocation(3); // there is only one identifier in the test database for location 3 List<PatientIdentifier> patientIdentifiers = dao.getPatientIdentifiers(null, new ArrayList<>(), Collections.singletonList(location), new ArrayList<>(), null); Assert.assertEquals(1, patientIdentifiers.size()); Assert.assertEquals("12345K", patientIdentifiers.get(0).getIdentifier()); }
/** * @see LocationService#getLocationsHavingAnyTag(List<QLocationTag;>) */ @Test public void getLocationsHavingAnyTag_shouldReturnEmptyListWhenNoLocationHasTheGivenTags() { LocationService ls = Context.getLocationService(); Assert.assertEquals(0, ls.getLocationsHavingAnyTag(Collections.singletonList(ls.getLocationTagByName("Retired"))) .size()); }
/** * @see LocationService#getLocationTagByName(String) */ @Test public void getLocationTagByName_shouldReturnNullWhenNoLocationTagMatchGivenName() { Assert.assertNull(Context.getLocationService().getLocationTagByName("Hospital of the year 2222")); }
/** * @see LocationService#getLocationTagByUuid(String) */ @Test public void getLocationTagByUuid_shouldReturnNullIfNoObjectFoundWithGivenUuid() { Assert.assertNull(Context.getLocationService().getLocationTagByUuid("ffffffff-47ed-11df-bc8b-001e378eb67e")); }
/** * @see LocationService#getLocation(String) */ @Test public void getLocation_shouldReturnNullWhenNoLocationMatchGivenLocationName() { Assert.assertNull(Context.getLocationService().getLocation("Princeton Plainsboro")); }
/** * @see LocationService#getLocationByUuid(String) */ @Test public void getLocationByUuid_shouldReturnNullIfNoObjectFoundWithGivenUuid() { Assert.assertNull(Context.getLocationService().getLocationByUuid("some invalid uuid")); }
/** * @see LocationService#getLocationAttributeType(Integer) */ @Test public void getLocationAttributeType_shouldReturnNullIfNoLocationAttributeTypeExistsWithTheGivenId() { executeDataSet(LOC_ATTRIBUTE_DATA_XML); Assert.assertNull(Context.getLocationService().getLocationAttributeType(999)); }
/** * @see LocationService#getLocationByUuid(String) */ @Test public void getLocationByUuid_shouldFindObjectGivenValidUuid() { String uuid = "f08ba64b-ea57-4a41-b33c-9dfc59b0c60a"; Location location = Context.getLocationService().getLocationByUuid(uuid); Assert.assertEquals(1, (int) location.getLocationId()); }
/** * @see LocationService#getLocationAttributeTypeByUuid(String) */ @Test public void getLocationAttributeTypeByUuid_shouldReturnNullIfNoLocationAttributeTypeExistsWithTheGivenUuid() { executeDataSet(LOC_ATTRIBUTE_DATA_XML); Assert.assertNull(Context.getLocationService().getLocationAttributeTypeByUuid("not-a-uuid")); }
/** * @see LocationService#getLocationAttributeByUuid(String) */ @Test public void getLocationAttributeByUuid_shouldReturnNullIfNoLocationAttributeHasTheGivenUuid() { executeDataSet(LOC_ATTRIBUTE_DATA_XML); LocationService service = Context.getLocationService(); Assert.assertNull(service.getLocationAttributeByUuid("not-a-uuid")); }
/** * Get locations that have a specified tag among its child tags. * * @see LocationService#getLocationsByTag(LocationTag) */ @Test public void getLocationsByTag_shouldGetLocationsByTag() { LocationService ls = Context.getLocationService(); assertEquals(1, ls.getLocationsByTag(ls.getLocationTag(1)).size()); assertEquals(2, ls.getLocationsByTag(ls.getLocationTag(3)).size()); assertEquals(4, ls.getLocationsByTag(ls.getLocationTag(4)).size()); }
/** * @see LocationService#saveLocation(Location) */ @Test public void saveLocation_shouldReturnSavedObject() { Location location = new Location(); location.setName("Some name"); location.setDescription("Some description"); Location savedLocation = Context.getLocationService().saveLocation(location); Assert.assertEquals(location, savedLocation); }
/** * @see LocationService#saveLocationTag(LocationTag) */ @Test(expected = APIException.class) public void saveLocationTag_shouldThrowAPIExceptionIfTagHasNoName() { LocationTag tagWithoutName = new LocationTag(); Location location = new Location(); location.setName("Some name"); location.setDescription("Some description"); location.addTag(tagWithoutName); Context.getLocationService().saveLocation(location); }