Search in sources :

Example 66 with IdType

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));
}
Also used : Group(org.hl7.fhir.r4.model.Group) IdType(org.hl7.fhir.r4.model.IdType) Test(org.junit.Test)

Example 67 with IdType

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);
}
Also used : Group(org.hl7.fhir.r4.model.Group) Group(org.hl7.fhir.r4.model.Group) IdType(org.hl7.fhir.r4.model.IdType) Test(org.junit.Test)

Example 68 with IdType

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"));
}
Also used : OperationOutcome(org.hl7.fhir.r4.model.OperationOutcome) IdType(org.hl7.fhir.r4.model.IdType) Test(org.junit.Test)

Example 69 with IdType

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));
}
Also used : Group(org.hl7.fhir.r4.model.Group) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) IdType(org.hl7.fhir.r4.model.IdType) Test(org.junit.Test)

Example 70 with IdType

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);
}
Also used : Immunization(org.hl7.fhir.r4.model.Immunization) IdType(org.hl7.fhir.r4.model.IdType) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Aggregations

IdType (org.hl7.fhir.r4.model.IdType)240 Test (org.junit.Test)240 IdType (org.hl7.fhir.dstu3.model.IdType)217 BaseFhirProvenanceResourceTest (org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest)87 Test (org.junit.jupiter.api.Test)72 HashMap (java.util.HashMap)70 JsonObject (javax.json.JsonObject)55 Path (javax.ws.rs.Path)55 Produces (javax.ws.rs.Produces)55 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)50 MethodOutcome (ca.uhn.fhir.rest.api.MethodOutcome)49 Bundle (org.hl7.fhir.r4.model.Bundle)45 Date (java.util.Date)44 GET (javax.ws.rs.GET)40 ArrayList (java.util.ArrayList)38 ResourceNotFoundException (ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException)36 Coding (org.hl7.fhir.r4.model.Coding)34 IBaseBundle (org.hl7.fhir.instance.model.api.IBaseBundle)33 Resource (org.hl7.fhir.r4.model.Resource)33 Provenance (org.hl7.fhir.r4.model.Provenance)32