Search in sources :

Example 16 with Location

use of com.google.api.services.actions_fulfillment.v2.model.Location in project openmrs-module-fhir2 by openmrs.

the class LocationFhirResourceProviderTest method searchLocations_shouldReturnMatchingBundleOfChainedLocationsByParentName.

@Test
public void searchLocations_shouldReturnMatchingBundleOfChainedLocationsByParentName() {
    ReferenceAndListParam locationParentName = new ReferenceAndListParam();
    locationParentName.addValue(new ReferenceOrListParam().add(new ReferenceParam().setValue("chulaimbo").setChain(Location.SP_NAME)));
    when(locationService.searchForLocations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), argThat(Matchers.is(locationParentName)), 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, locationParentName, null, null, null, null, null);
    assertThat(results, notNullValue());
    List<Location> resultList = get(results);
    assertThat(resultList.get(0).fhirType(), is(FhirConstants.LOCATION));
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
Also used : ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) ReferenceOrListParam(ca.uhn.fhir.rest.param.ReferenceOrListParam) Location(org.hl7.fhir.r4.model.Location) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Example 17 with Location

use of com.google.api.services.actions_fulfillment.v2.model.Location in project openmrs-module-fhir2 by openmrs.

the class LocationFhirResourceProviderTest method searchLocations_shouldReturnMatchingBundleOfChainedLocationsByParentCountry.

@Test
public void searchLocations_shouldReturnMatchingBundleOfChainedLocationsByParentCountry() {
    ReferenceAndListParam locationParentCountry = new ReferenceAndListParam();
    locationParentCountry.addValue(new ReferenceOrListParam().add(new ReferenceParam().setValue("uganda").setChain(Location.SP_ADDRESS_COUNTRY)));
    when(locationService.searchForLocations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), argThat(Matchers.is(locationParentCountry)), 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, locationParentCountry, null, null, null, null, null);
    assertThat(results, notNullValue());
    List<Location> resultList = get(results);
    assertThat(resultList.get(0).fhirType(), is(FhirConstants.LOCATION));
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
Also used : ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) ReferenceOrListParam(ca.uhn.fhir.rest.param.ReferenceOrListParam) Location(org.hl7.fhir.r4.model.Location) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Example 18 with Location

use of com.google.api.services.actions_fulfillment.v2.model.Location in project openmrs-module-fhir2 by openmrs.

the class LocationFhirResourceProviderTest method searchLocations_shouldReturnMatchingBundleOfChainedLocationsByParentState.

@Test
public void searchLocations_shouldReturnMatchingBundleOfChainedLocationsByParentState() {
    ReferenceAndListParam locationParentState = new ReferenceAndListParam();
    locationParentState.addValue(new ReferenceOrListParam().add(new ReferenceParam().setValue("najjanankumbi").setChain(Location.SP_ADDRESS_STATE)));
    when(locationService.searchForLocations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), argThat(Matchers.is(locationParentState)), 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, locationParentState, null, null, null, null, null);
    assertThat(results, notNullValue());
    List<Location> resultList = get(results);
    assertThat(resultList.get(0).fhirType(), is(FhirConstants.LOCATION));
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
Also used : ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) ReferenceOrListParam(ca.uhn.fhir.rest.param.ReferenceOrListParam) Location(org.hl7.fhir.r4.model.Location) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Example 19 with Location

use of com.google.api.services.actions_fulfillment.v2.model.Location in project openmrs-module-fhir2 by openmrs.

the class LocationFhirResourceProviderTest method searchLocations_shouldReturnMatchingBundleOfLocationsByUUID.

@Test
public void searchLocations_shouldReturnMatchingBundleOfLocationsByUUID() {
    TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(LOCATION_UUID));
    when(locationService.searchForLocations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), argThat(is(uuid)), 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, uuid, null, null, null, null);
    assertThat(results, notNullValue());
    List<Location> resultList = get(results);
    assertThat(resultList.get(0).fhirType(), is(FhirConstants.LOCATION));
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
    assertThat(resultList.get(0).getId(), equalTo(LOCATION_UUID));
}
Also used : TokenParam(ca.uhn.fhir.rest.param.TokenParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) Location(org.hl7.fhir.r4.model.Location) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Example 20 with Location

use of com.google.api.services.actions_fulfillment.v2.model.Location in project openmrs-module-fhir2 by openmrs.

the class LocationFhirResourceProviderTest method searchLocations_shouldAddRelatedResourcesWhenIncluded.

@Test
public void searchLocations_shouldAddRelatedResourcesWhenIncluded() {
    HashSet<Include> includeSet = new HashSet<>();
    includeSet.add(new Include("Location:partof"));
    when(locationService.searchForLocations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), argThat(is(includeSet)), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Arrays.asList(location, new Location()), PREFERRED_PAGE_SIZE, COUNT));
    IBundleProvider results = resourceProvider.searchLocations(null, null, null, null, null, null, null, null, null, includeSet, null, null);
    List<Location> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList.get(0).fhirType(), is(FhirConstants.LOCATION));
    assertThat(resultList.get(1).fhirType(), is(FhirConstants.LOCATION));
    assertThat(resultList.size(), equalTo(2));
    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) HashSet(java.util.HashSet) Location(org.hl7.fhir.r4.model.Location) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)120 Location (org.hl7.fhir.r4.model.Location)93 Location (org.hl7.fhir.dstu3.model.Location)66 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)59 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)42 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)30 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)27 BaseFhirProvenanceResourceTest (org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest)21 StringAndListParam (ca.uhn.fhir.rest.param.StringAndListParam)20 StringOrListParam (ca.uhn.fhir.rest.param.StringOrListParam)20 StringParam (ca.uhn.fhir.rest.param.StringParam)20 ReferenceAndListParam (ca.uhn.fhir.rest.param.ReferenceAndListParam)16 ReferenceOrListParam (ca.uhn.fhir.rest.param.ReferenceOrListParam)16 ReferenceParam (ca.uhn.fhir.rest.param.ReferenceParam)16 MockIBundleProvider (org.openmrs.module.fhir2.providers.r4.MockIBundleProvider)16 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)13 Test (org.junit.jupiter.api.Test)13 ArrayList (java.util.ArrayList)11 HashSet (java.util.HashSet)11 TokenParam (ca.uhn.fhir.rest.param.TokenParam)10