use of org.hl7.fhir.r5.utils.validation in project openmrs-module-fhir2 by openmrs.
the class DiagnosticReportFhirResourceProviderTest method updateDiagnosticReport_shouldThrowMethodNotAllowedIfDoesNotExist.
@Test(expected = MethodNotAllowedException.class)
public void updateDiagnosticReport_shouldThrowMethodNotAllowedIfDoesNotExist() {
DiagnosticReport wrongDiagnosticReport = new DiagnosticReport();
wrongDiagnosticReport.setId(WRONG_UUID);
when(service.update(eq(WRONG_UUID), any(org.hl7.fhir.r4.model.DiagnosticReport.class))).thenThrow(MethodNotAllowedException.class);
resourceProvider.updateDiagnosticReport(new IdType().setValue(WRONG_UUID), wrongDiagnosticReport);
}
use of org.hl7.fhir.r5.utils.validation in project openmrs-module-fhir2 by openmrs.
the class DiagnosticReportFhirResourceProviderTest method updateDiagnosticReport_shouldThrowInvalidRequestForMissingId.
@Test(expected = InvalidRequestException.class)
public void updateDiagnosticReport_shouldThrowInvalidRequestForMissingId() {
DiagnosticReport noIdDiagnosticReport = new DiagnosticReport();
when(service.update(eq(UUID), any(org.hl7.fhir.r4.model.DiagnosticReport.class))).thenThrow(InvalidRequestException.class);
resourceProvider.updateDiagnosticReport(new IdType().setValue(UUID), noIdDiagnosticReport);
}
use of org.hl7.fhir.r5.utils.validation in project openmrs-module-fhir2 by openmrs.
the class EncounterFhirResourceProviderTest method updateEncounter_shouldUpdateEncounter.
@Test
public void updateEncounter_shouldUpdateEncounter() {
when(encounterService.update(eq(ENCOUNTER_UUID), any(org.hl7.fhir.r4.model.Encounter.class))).thenReturn(encounter);
MethodOutcome result = resourceProvider.updateEncounter(new IdType().setValue(ENCOUNTER_UUID), Encounter30_40.convertEncounter(encounter));
assertThat(result, notNullValue());
assertThat(result.getResource(), notNullValue());
assertThat(result.getResource().getIdElement().getIdPart(), equalTo(ENCOUNTER_UUID));
}
use of org.hl7.fhir.r5.utils.validation in project openmrs-module-fhir2 by openmrs.
the class EncounterFhirResourceProviderTest method createEncounter_shouldCreateNewEncounter.
@Test
public void createEncounter_shouldCreateNewEncounter() {
when(encounterService.create(any(org.hl7.fhir.r4.model.Encounter.class))).thenReturn(encounter);
MethodOutcome result = resourceProvider.createEncounter(Encounter30_40.convertEncounter(encounter));
assertThat(result, notNullValue());
assertThat(result.getCreated(), is(true));
assertThat(result.getResource(), notNullValue());
assertThat(result.getResource().getIdElement().getIdPart(), equalTo(ENCOUNTER_UUID));
}
use of org.hl7.fhir.r5.utils.validation in project openmrs-module-fhir2 by openmrs.
the class EncounterFhirResourceProviderTest method searchEncounters_shouldReturnMatchingEncounters.
@Test
public void searchEncounters_shouldReturnMatchingEncounters() {
List<org.hl7.fhir.r4.model.Encounter> encounters = new ArrayList<>();
encounters.add(encounter);
when(encounterService.searchForEncounters(any(), any(), any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(new MockIBundleProvider<>(encounters, PREFERRED_SIZE, COUNT));
ReferenceAndListParam subjectReference = new ReferenceAndListParam();
subjectReference.addValue(new ReferenceOrListParam().add(new ReferenceParam().setChain(Patient.SP_NAME)));
IBundleProvider results = resourceProvider.searchEncounter(null, null, null, subjectReference, null, null, null, null, null, null, null);
List<Encounter> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(resultList.get(0).fhirType(), equalTo(FhirConstants.ENCOUNTER));
assertThat(resultList.get(0).getId(), equalTo(ENCOUNTER_UUID));
}
Aggregations