Search in sources :

Example 96 with org.hl7.fhir.r5.utils.validation.constants

use of org.hl7.fhir.r5.utils.validation.constants in project openmrs-module-fhir2 by openmrs.

the class GroupFhirResourceProviderTest method shouldCreateNewGroup.

@Test
public void shouldCreateNewGroup() {
    when(fhirGroupService.create(any(org.hl7.fhir.r4.model.Group.class))).thenReturn(group);
    MethodOutcome result = resourceProvider.createGroup(Group30_40.convertGroup(group));
    assertThat(result, notNullValue());
    assertThat(result.getCreated(), is(true));
    assertThat(result.getResource(), notNullValue());
    assertThat(result.getResource().getIdElement().getIdPart(), equalTo(group.getId()));
    assertThat(result.getResource().getStructureFhirVersionEnum(), equalTo(FhirVersionEnum.DSTU3));
}
Also used : Group(org.hl7.fhir.dstu3.model.Group) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) Test(org.junit.Test)

Example 97 with org.hl7.fhir.r5.utils.validation.constants

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() {
    org.hl7.fhir.r4.model.Group.GroupMemberComponent groupMemberComponent = mock(org.hl7.fhir.r4.model.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), Group30_40.convertGroup(group));
    assertThat(result, notNullValue());
    assertThat(result.getResource(), notNullValue());
    assertThat(result.getResource().getIdElement().getIdPart(), equalTo(group.getId()));
    assertThat(result.getResource().getStructureFhirVersionEnum(), equalTo(FhirVersionEnum.DSTU3));
}
Also used : Group(org.hl7.fhir.dstu3.model.Group) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.Test)

Example 98 with org.hl7.fhir.r5.utils.validation.constants

use of org.hl7.fhir.r5.utils.validation.constants in project openmrs-module-fhir2 by openmrs.

the class LocationFhirResourceProviderTest method updateLocation_shouldThrowInvalidRequestForMissingId.

@Test(expected = InvalidRequestException.class)
public void updateLocation_shouldThrowInvalidRequestForMissingId() {
    Location noIdLocation = new Location();
    when(locationService.update(eq(LOCATION_UUID), any(org.hl7.fhir.r4.model.Location.class))).thenThrow(InvalidRequestException.class);
    resourceProvider.updateLocation(new IdType().setValue(LOCATION_UUID), noIdLocation);
}
Also used : Location(org.hl7.fhir.dstu3.model.Location) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.Test)

Example 99 with org.hl7.fhir.r5.utils.validation.constants

use of org.hl7.fhir.r5.utils.validation.constants in project openmrs-module-fhir2 by openmrs.

the class LocationFhirResourceProviderTest method initLocation.

@Before
public void initLocation() {
    Address address = new Address();
    address.setCity(CITY);
    address.setCountry(COUNTRY);
    address.setState(STATE);
    address.setPostalCode(POSTAL_CODE);
    location = new org.hl7.fhir.r4.model.Location();
    location.setId(LOCATION_UUID);
    location.setName(LOCATION_NAME);
    location.setAddress(address);
    location.getMeta().addTag(new Coding(FhirConstants.OPENMRS_FHIR_EXT_LOCATION_TAG, LOGIN_LOCATION_TAG_NAME, LOGIN_LOCATION_TAG_DESCRIPTION));
    setProvenanceResources(location);
}
Also used : Address(org.hl7.fhir.r4.model.Address) Coding(org.hl7.fhir.r4.model.Coding) Before(org.junit.Before)

Example 100 with org.hl7.fhir.r5.utils.validation.constants

use of org.hl7.fhir.r5.utils.validation.constants in project openmrs-module-fhir2 by openmrs.

the class LocationFhirResourceProviderTest method getLocationByUuid_shouldReturnMatchingLocation.

@Test
public void getLocationByUuid_shouldReturnMatchingLocation() {
    when(locationService.get(LOCATION_UUID)).thenReturn(location);
    IdType id = new IdType();
    id.setValue(LOCATION_UUID);
    org.hl7.fhir.dstu3.model.Location result = resourceProvider.getLocationById(id);
    assertThat(result, notNullValue());
    assertThat(result.getId(), notNullValue());
    assertThat(result.getId(), equalTo(LOCATION_UUID));
}
Also used : Location(org.hl7.fhir.dstu3.model.Location) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.Test)

Aggregations

Test (org.junit.jupiter.api.Test)427 Turtle (org.hl7.fhir.dstu3.utils.formats.Turtle)334 Test (org.junit.Test)241 FHIRException (org.hl7.fhir.exceptions.FHIRException)104 ArrayList (java.util.ArrayList)101 IOException (java.io.IOException)78 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)70 Date (java.util.Date)65 List (java.util.List)64 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)61 FileOutputStream (java.io.FileOutputStream)59 CodeableReference (org.hl7.fhir.r5.model.CodeableReference)58 File (java.io.File)57 InputStream (java.io.InputStream)51 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)50 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)48 Bundle (org.hl7.fhir.dstu3.model.Bundle)48 MethodSource (org.junit.jupiter.params.provider.MethodSource)46 Arrays (java.util.Arrays)45 Collectors (java.util.stream.Collectors)45