use of org.hl7.fhir.r5.model.IdType in project openmrs-module-fhir2 by openmrs.
the class EncounterFhirResourceProviderTest method updateEncounter_shouldThrowMethodNotAllowedIfDoesNotExist.
@Test(expected = MethodNotAllowedException.class)
public void updateEncounter_shouldThrowMethodNotAllowedIfDoesNotExist() {
Encounter wrongEncounter = new Encounter();
wrongEncounter.setId(WRONG_ENCOUNTER_UUID);
when(encounterService.update(WRONG_ENCOUNTER_UUID, wrongEncounter)).thenThrow(MethodNotAllowedException.class);
resourceProvider.updateEncounter(new IdType().setValue(WRONG_ENCOUNTER_UUID), wrongEncounter);
}
use of org.hl7.fhir.r5.model.IdType in project openmrs-module-fhir2 by openmrs.
the class EncounterFhirResourceProviderTest method getEncounterWithWrongUuid_shouldThrowResourceNotFoundException.
@Test(expected = ResourceNotFoundException.class)
public void getEncounterWithWrongUuid_shouldThrowResourceNotFoundException() {
IdType id = new IdType();
id.setValue(WRONG_ENCOUNTER_UUID);
Encounter result = resourceProvider.getEncounterByUuid(id);
assertThat(result, nullValue());
}
use of org.hl7.fhir.r5.model.IdType in project openmrs-module-fhir2 by openmrs.
the class EncounterFhirResourceProviderTest method updateEncounter_shouldThrowInvalidRequestForMissingId.
@Test(expected = InvalidRequestException.class)
public void updateEncounter_shouldThrowInvalidRequestForMissingId() {
Encounter noIdEncounter = new Encounter();
when(encounterService.update(ENCOUNTER_UUID, noIdEncounter)).thenThrow(InvalidRequestException.class);
resourceProvider.updateEncounter(new IdType().setValue(ENCOUNTER_UUID), noIdEncounter);
}
use of org.hl7.fhir.r5.model.IdType in project openmrs-module-fhir2 by openmrs.
the class EncounterFhirResourceProviderTest method getEncounterHistory_shouldReturnProvenanceResources.
@Test
public void getEncounterHistory_shouldReturnProvenanceResources() {
IdType id = new IdType();
id.setValue(ENCOUNTER_UUID);
when(encounterService.get(ENCOUNTER_UUID)).thenReturn(encounter);
List<Resource> resources = resourceProvider.getEncounterHistoryById(id);
assertThat(resources, not(empty()));
assertThat(resources.stream().findAny().isPresent(), is(true));
assertThat(resources.stream().findAny().get().getResourceType().name(), Matchers.equalTo(Provenance.class.getSimpleName()));
}
use of org.hl7.fhir.r5.model.IdType in project openmrs-module-fhir2 by openmrs.
the class EncounterFhirResourceProviderTest method getEncounterByUuid_shouldReturnMatchingEncounter.
@Test
public void getEncounterByUuid_shouldReturnMatchingEncounter() {
IdType id = new IdType();
id.setValue(ENCOUNTER_UUID);
when(encounterService.get(ENCOUNTER_UUID)).thenReturn(encounter);
Encounter result = resourceProvider.getEncounterByUuid(id);
assertThat(result, notNullValue());
assertThat(result.getId(), notNullValue());
assertThat(result.getId(), equalTo(ENCOUNTER_UUID));
assertThat(result.getStatus(), equalTo(Encounter.EncounterStatus.UNKNOWN));
}
Aggregations