use of org.hl7.fhir.r5.utils.validation.constants in project openmrs-module-fhir2 by openmrs.
the class GroupFhirResourceProviderTest method shouldThrowMethodNotAllowedIfGroupToUpdateDoesNotExist.
@Test(expected = MethodNotAllowedException.class)
public void shouldThrowMethodNotAllowedIfGroupToUpdateDoesNotExist() {
org.hl7.fhir.r4.model.Group wrongGroup = new org.hl7.fhir.r4.model.Group();
wrongGroup.setId(BAD_COHORT_UUID);
when(fhirGroupService.update(eq(BAD_COHORT_UUID), any(org.hl7.fhir.r4.model.Group.class))).thenThrow(MethodNotAllowedException.class);
resourceProvider.updateGroup(new IdType().setValue(BAD_COHORT_UUID), wrongGroup);
}
use of org.hl7.fhir.r5.utils.validation.constants in project openmrs-module-fhir2 by openmrs.
the class GroupFhirResourceProviderTest method shouldUpdateExistingGroup.
@Test
public void shouldUpdateExistingGroup() {
Group.GroupMemberComponent groupMemberComponent = mock(Group.GroupMemberComponent.class);
group.setActual(false);
group.addMember(groupMemberComponent);
when(fhirGroupService.update(eq(COHORT_UUID), any(org.hl7.fhir.r4.model.Group.class))).thenReturn(group);
MethodOutcome result = resourceProvider.updateGroup(new IdType().setValue(COHORT_UUID), group);
assertThat(result, notNullValue());
assertThat(result.getResource(), notNullValue());
assertThat(result.getResource().getIdElement().getIdPart(), equalTo(group.getId()));
assertThat(result.getResource().getStructureFhirVersionEnum(), equalTo(FhirVersionEnum.R4));
}
use of org.hl7.fhir.r5.utils.validation.constants in project openmrs-module-fhir2 by openmrs.
the class ObservationTranslatorImplTest method shouldAddProvenanceResources.
@Test
public void shouldAddProvenanceResources() {
Obs obs = new Obs();
obs.setUuid(OBS_UUID);
Provenance provenance = new Provenance();
provenance.setId(new IdType(FhirUtils.newUuid()));
when(provenanceTranslator.getCreateProvenance(obs)).thenReturn(provenance);
when(provenanceTranslator.getUpdateProvenance(obs)).thenReturn(provenance);
org.hl7.fhir.r4.model.Observation result = observationTranslator.toFhirResource(obs);
assertThat(result, notNullValue());
assertThat(result.getContained(), not(empty()));
assertThat(result.getContained().size(), greaterThanOrEqualTo(2));
assertThat(result.getContained().stream().anyMatch(resource -> resource.getResourceType().name().equals(Provenance.class.getSimpleName())), is(true));
}
use of org.hl7.fhir.r5.utils.validation.constants in project openmrs-module-fhir2 by openmrs.
the class PatientTranslatorImplTest method shouldNotAddUpdateProvenanceIfDateChangedAndChangedByAreBothNull.
@Test
public void shouldNotAddUpdateProvenanceIfDateChangedAndChangedByAreBothNull() {
Provenance provenance = new Provenance();
provenance.setId(new IdType(FhirUtils.newUuid()));
org.openmrs.Patient patient = new org.openmrs.Patient();
patient.setUuid(PATIENT_UUID);
patient.setDateChanged(null);
patient.setChangedBy(null);
when(provenanceTranslator.getCreateProvenance(patient)).thenReturn(provenance);
when(provenanceTranslator.getUpdateProvenance(patient)).thenReturn(null);
org.hl7.fhir.r4.model.Patient result = patientTranslator.toFhirResource(patient);
assertThat(result, notNullValue());
assertThat(result.getContained(), not(empty()));
assertThat(result.getContained().size(), equalTo(1));
assertThat(result.getContained().stream().anyMatch(resource -> resource.getResourceType().name().equals(Provenance.class.getSimpleName())), is(true));
}
use of org.hl7.fhir.r5.utils.validation.constants in project openmrs-module-fhir2 by openmrs.
the class PatientTranslatorImplTest method shouldAddProvenanceResources.
@Test
public void shouldAddProvenanceResources() {
org.openmrs.Patient patient = new org.openmrs.Patient();
patient.setUuid(PATIENT_UUID);
Provenance provenance = new Provenance();
provenance.setId(new IdType(FhirUtils.newUuid()));
when(provenanceTranslator.getCreateProvenance(patient)).thenReturn(provenance);
when(provenanceTranslator.getUpdateProvenance(patient)).thenReturn(provenance);
org.hl7.fhir.r4.model.Patient result = patientTranslator.toFhirResource(patient);
assertThat(result, notNullValue());
assertThat(result.getContained(), not(empty()));
assertThat(result.getContained().size(), greaterThanOrEqualTo(2));
assertThat(result.getContained().stream().anyMatch(resource -> resource.getResourceType().name().equals(Provenance.class.getSimpleName())), is(true));
}
Aggregations