use of org.hl7.fhir.r5.model.IdType in project openmrs-module-fhir2 by openmrs.
the class GroupFhirResourceProviderTest method getGroupByUuid_shouldReturnMatchingGroup.
@Test
public void getGroupByUuid_shouldReturnMatchingGroup() {
when(fhirGroupService.get(COHORT_UUID)).thenReturn(group);
IdType id = new IdType();
id.setValue(COHORT_UUID);
Group group = resourceProvider.getGroupByUuid(id);
assertThat(group, notNullValue());
assertThat(group.getId(), notNullValue());
assertThat(group.getId(), equalTo(COHORT_UUID));
}
use of org.hl7.fhir.r5.model.IdType 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.model.IdType in project openmrs-module-fhir2 by openmrs.
the class GroupFhirResourceProviderTest method shouldDeleteRequestedGroup.
@Test
public void shouldDeleteRequestedGroup() {
when(fhirGroupService.delete(COHORT_UUID)).thenReturn(group);
OperationOutcome result = resourceProvider.deleteGroup(new IdType().setValue(COHORT_UUID));
assertThat(result, notNullValue());
assertThat(result.getIssue(), notNullValue());
assertThat(result.getIssueFirstRep().getSeverity(), equalTo(OperationOutcome.IssueSeverity.INFORMATION));
assertThat(result.getIssueFirstRep().getDetails().getCodingFirstRep().getCode(), equalTo("MSG_DELETED"));
}
use of org.hl7.fhir.r5.model.IdType 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.model.IdType in project openmrs-module-fhir2 by openmrs.
the class ImmunizationFhirResourceProviderTest method updateImmunization_shouldThrowInvalidRequestExceptionForMissingId.
@Test(expected = InvalidRequestException.class)
public void updateImmunization_shouldThrowInvalidRequestExceptionForMissingId() {
Immunization noIdImmunization = new Immunization();
when(immunizationService.update(IMMUNIZATION_UUID, noIdImmunization)).thenThrow(InvalidRequestException.class);
resourceProvider.updateImmunization(new IdType().setValue(IMMUNIZATION_UUID), noIdImmunization);
}
Aggregations