Search in sources :

Example 61 with Location

use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.

the class LocationFhirResourceProviderTest method initLocation.

@Before
public void initLocation() {
    Address address = new Address();
    address.setCity(CITY);
    address.setCountry(COUNTRY);
    address.setState(STATE);
    address.setPostalCode(POSTAL_CODE);
    location = new org.hl7.fhir.r4.model.Location();
    location.setId(LOCATION_UUID);
    location.setName(LOCATION_NAME);
    location.setAddress(address);
    location.getMeta().addTag(new Coding(FhirConstants.OPENMRS_FHIR_EXT_LOCATION_TAG, LOGIN_LOCATION_TAG_NAME, LOGIN_LOCATION_TAG_DESCRIPTION));
    setProvenanceResources(location);
}
Also used : Address(org.hl7.fhir.r4.model.Address) Coding(org.hl7.fhir.r4.model.Coding) Before(org.junit.Before)

Example 62 with Location

use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.

the class LocationFhirResourceProviderTest method getLocationByUuid_shouldReturnMatchingLocation.

@Test
public void getLocationByUuid_shouldReturnMatchingLocation() {
    when(locationService.get(LOCATION_UUID)).thenReturn(location);
    IdType id = new IdType();
    id.setValue(LOCATION_UUID);
    org.hl7.fhir.dstu3.model.Location result = resourceProvider.getLocationById(id);
    assertThat(result, notNullValue());
    assertThat(result.getId(), notNullValue());
    assertThat(result.getId(), equalTo(LOCATION_UUID));
}
Also used : Location(org.hl7.fhir.dstu3.model.Location) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.Test)

Example 63 with Location

use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.

the class LocationFhirResourceProviderTest method searchLocations_shouldReturnMatchingBundleOfLocations.

@Test
public void searchLocations_shouldReturnMatchingBundleOfLocations() {
    List<org.hl7.fhir.r4.model.Location> locations = new ArrayList<>();
    locations.add(location);
    when(locationService.searchForLocations(any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(new MockIBundleProvider<>(locations, PREFERRED_PAGE_SIZE, COUNT));
    StringAndListParam location = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(LOCATION_NAME)));
    IBundleProvider results = resourceProvider.searchLocations(location, null, null, null, null, null, null, null, null, null, null, null);
    List<Location> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList.get(0).fhirType(), is(FhirConstants.LOCATION));
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
    assertThat(resultList.get(0).getId(), equalTo(LOCATION_UUID));
}
Also used : StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) ArrayList(java.util.ArrayList) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) MockIBundleProvider(org.openmrs.module.fhir2.providers.r4.MockIBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) StringOrListParam(ca.uhn.fhir.rest.param.StringOrListParam) Location(org.hl7.fhir.dstu3.model.Location) Test(org.junit.Test)

Example 64 with Location

use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.

the class LocationFhirResourceProviderTest method searchLocations_shouldReturnMatchingBundleOfLocationsByLastUpdated.

@Test
public void searchLocations_shouldReturnMatchingBundleOfLocationsByLastUpdated() {
    DateRangeParam lastUpdated = new DateRangeParam().setUpperBound(LAST_UPDATED_DATE).setLowerBound(LAST_UPDATED_DATE);
    when(locationService.searchForLocations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), argThat(is(lastUpdated)), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(location), PREFERRED_PAGE_SIZE, COUNT));
    IBundleProvider results = resourceProvider.searchLocations(null, null, null, null, null, null, null, null, lastUpdated, null, null, null);
    List<Location> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList.get(0).fhirType(), is(FhirConstants.LOCATION));
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
    assertThat(resultList.get(0).getId(), equalTo(LOCATION_UUID));
}
Also used : DateRangeParam(ca.uhn.fhir.rest.param.DateRangeParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) MockIBundleProvider(org.openmrs.module.fhir2.providers.r4.MockIBundleProvider) Location(org.hl7.fhir.dstu3.model.Location) Test(org.junit.Test)

Example 65 with Location

use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.

the class LocationFhirResourceProviderTest method searchLocations_shouldNotAddRelatedResourcesForEmptyReverseInclude.

@Test
public void searchLocations_shouldNotAddRelatedResourcesForEmptyReverseInclude() {
    HashSet<Include> revIncludeSet = new HashSet<>();
    when(locationService.searchForLocations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(location), PREFERRED_PAGE_SIZE, COUNT));
    IBundleProvider results = resourceProvider.searchLocations(null, null, null, null, null, null, null, null, null, null, revIncludeSet, null);
    List<Location> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList.get(0).fhirType(), is(FhirConstants.LOCATION));
    assertThat(resultList.size(), equalTo(1));
    assertThat(resultList.get(0).getId(), equalTo(LOCATION_UUID));
}
Also used : Include(ca.uhn.fhir.model.api.Include) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) MockIBundleProvider(org.openmrs.module.fhir2.providers.r4.MockIBundleProvider) HashSet(java.util.HashSet) Location(org.hl7.fhir.dstu3.model.Location) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)215 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)94 Location (org.hl7.fhir.r4.model.Location)93 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)71 Location (org.hl7.fhir.dstu3.model.Location)66 InputStream (java.io.InputStream)46 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)39 Matchers.containsString (org.hamcrest.Matchers.containsString)38 Test (org.junit.jupiter.api.Test)38 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)37 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)35 ArrayList (java.util.ArrayList)29 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)29 BaseFhirProvenanceResourceTest (org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest)26 Reference (org.hl7.fhir.r4.model.Reference)25 Date (java.util.Date)24 Bundle (org.hl7.fhir.r4.model.Bundle)24 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)24 ReferenceAndListParam (ca.uhn.fhir.rest.param.ReferenceAndListParam)23 ReferenceOrListParam (ca.uhn.fhir.rest.param.ReferenceOrListParam)23