use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationFhirResourceProviderWebTest method deleteLocation_shouldDeleteLocation.
@Test
public void deleteLocation_shouldDeleteLocation() throws Exception {
org.hl7.fhir.r4.model.Location location = new org.hl7.fhir.r4.model.Location();
location.setId(LOCATION_UUID);
when(locationService.delete(LOCATION_UUID)).thenReturn(location);
MockHttpServletResponse response = delete("/Location/" + LOCATION_UUID).accept(FhirMediaTypes.JSON).go();
assertThat(response, isOk());
assertThat(response.getContentType(), equalTo(FhirMediaTypes.JSON.toString()));
}
use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationFhirResourceProviderWebTest method verifyURI.
private void verifyURI(String uri) throws Exception {
Location location = new Location();
location.setId(LOCATION_UUID);
when(locationService.searchForLocations(any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(location), 10, 1));
MockHttpServletResponse response = get(uri).accept(FhirMediaTypes.JSON).go();
assertThat(response, isOk());
assertThat(response.getContentType(), equalTo(FhirMediaTypes.JSON.toString()));
assertThat(readBundleResponse(response).getEntry().size(), greaterThanOrEqualTo(1));
}
use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationFhirResourceProviderWebTest method getLocationById_shouldReturnLocationWithMatchingUuid.
@Test
public void getLocationById_shouldReturnLocationWithMatchingUuid() throws Exception {
Location location = new Location();
location.setId(LOCATION_UUID);
when(locationService.get(LOCATION_UUID)).thenReturn(location);
MockHttpServletResponse response = get("/Location/" + LOCATION_UUID).accept(FhirMediaTypes.JSON).go();
assertThat(response, isOk());
assertThat(response.getContentType(), equalTo(FhirMediaTypes.JSON.toString()));
Location resource = readResponse(response);
assertThat(resource.getIdElement().getIdPart(), equalTo(LOCATION_UUID));
}
use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationFhirResourceProviderWebTest method createLocation_shouldCreateLocation.
@Test
public void createLocation_shouldCreateLocation() throws Exception {
String jsonLocation;
try (InputStream is = this.getClass().getClassLoader().getResourceAsStream(JSON_CREATE_LOCATION_PATH)) {
Objects.requireNonNull(is);
jsonLocation = IOUtils.toString(is, StandardCharsets.UTF_8);
}
Location location = new Location();
location.setId(LOCATION_UUID);
when(locationService.create(any(Location.class))).thenReturn(location);
MockHttpServletResponse response = post("/Location").jsonContent(jsonLocation).accept(FhirMediaTypes.JSON).go();
assertThat(response, isCreated());
}
use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationFhirResourceProviderWebTest method shouldGetLocationHistoryById.
@Test
public void shouldGetLocationHistoryById() throws IOException, ServletException {
Provenance provenance = new Provenance();
provenance.setId(new IdType(FhirUtils.newUuid()));
provenance.setRecorded(new Date());
provenance.setActivity(new CodeableConcept().addCoding(new Coding().setCode("CREATE").setSystem(FhirConstants.FHIR_TERMINOLOGY_DATA_OPERATION).setDisplay("create")));
provenance.addAgent(new Provenance.ProvenanceAgentComponent().setType(new CodeableConcept().addCoding(new Coding().setCode(FhirConstants.AUT).setDisplay(FhirConstants.AUTHOR).setSystem(FhirConstants.FHIR_TERMINOLOGY_PROVENANCE_PARTICIPANT_TYPE))).addRole(new CodeableConcept().addCoding(new Coding().setCode("").setDisplay("").setSystem(FhirConstants.FHIR_TERMINOLOGY_PARTICIPATION_TYPE))));
Location location = new Location();
location.setId(LOCATION_UUID);
location.addContained(provenance);
when(locationService.get(LOCATION_UUID)).thenReturn(location);
MockHttpServletResponse response = getLocationHistoryByIdRequest();
Bundle results = readBundleResponse(response);
assertThat(results, Matchers.notNullValue());
assertThat(results.hasEntry(), is(true));
assertThat(results.getEntry().get(0).getResource(), Matchers.notNullValue());
assertThat(results.getEntry().get(0).getResource().getResourceType().name(), equalTo(Provenance.class.getSimpleName()));
}
Aggregations