use of org.hl7.fhir.r4.model.Group in project openmrs-module-fhir2 by openmrs.
the class GroupResourceProviderIntegrationTest method shouldReturnNotFoundWhenUpdatingNonExistentGroupAsJSON.
@Test
public void shouldReturnNotFoundWhenUpdatingNonExistentGroupAsJSON() throws Exception {
// get the existing record
MockHttpServletResponse response = get("/Group/" + GROUP_UUID).accept(FhirMediaTypes.JSON).go();
Group group = readResponse(response);
// update the existing record
group.setId(BAD_GROUP_UUID);
// send the update to the server
response = put("/Group/" + BAD_GROUP_UUID).jsonContent(toJson(group)).accept(FhirMediaTypes.JSON).go();
assertThat(response, isNotFound());
assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
assertThat(response.getContentAsString(), notNullValue());
OperationOutcome operationOutcome = readOperationOutcome(response);
assertThat(operationOutcome, notNullValue());
assertThat(operationOutcome.hasIssue(), is(true));
}
use of org.hl7.fhir.r4.model.Group in project openmrs-module-fhir2 by openmrs.
the class GroupResourceProviderIntegrationTest method shouldReturnPaginatedListOfGroupMembersWithLargeGroupAsJson.
@Test
public void shouldReturnPaginatedListOfGroupMembersWithLargeGroupAsJson() throws Exception {
MockHttpServletResponse response = get("/Group/" + GROUP_WITH_MORE_MEMBERS + "/$members").accept(FhirMediaTypes.JSON).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(BaseFhirIntegrationTest.FhirMediaTypes.JSON.toString()));
assertThat(response.getContentAsString(), notNullValue());
Bundle groupMembers = readBundleResponse(response);
assertThat(groupMembers, notNullValue());
assertThat(groupMembers.getEntry(), not(empty()));
assertThat(groupMembers.getTotal(), is(6));
List<Bundle.BundleEntryComponent> entries = groupMembers.getEntry();
assertThat(entries, everyItem(hasProperty("fullUrl", startsWith("http://localhost/ws/fhir2/R4/GroupMember/"))));
assertThat(entries, everyItem(hasResource(instanceOf(GroupMember.class))));
assertThat(entries, everyItem(hasResource(hasProperty("entity", hasProperty("reference", startsWith("Patient/"))))));
}
use of org.hl7.fhir.r4.model.Group in project openmrs-module-fhir2 by openmrs.
the class GroupResourceProviderIntegrationTest method shouldReturnPaginatedListOfGroupMembersWithLargeGroupAsXml.
@Test
public void shouldReturnPaginatedListOfGroupMembersWithLargeGroupAsXml() throws Exception {
MockHttpServletResponse response = get("/Group/" + GROUP_WITH_MORE_MEMBERS + "/$members").accept(FhirMediaTypes.XML).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
assertThat(response.getContentAsString(), notNullValue());
Bundle groupMembers = readBundleResponse(response);
assertThat(groupMembers, notNullValue());
assertThat(groupMembers.getEntry(), not(empty()));
assertThat(groupMembers.getTotal(), is(6));
List<Bundle.BundleEntryComponent> entries = groupMembers.getEntry();
assertThat(entries, everyItem(hasProperty("fullUrl", startsWith("http://localhost/ws/fhir2/R4/GroupMember/"))));
assertThat(entries, everyItem(hasResource(instanceOf(GroupMember.class))));
assertThat(entries, everyItem(hasResource(hasProperty("entity", hasProperty("reference", startsWith("Patient/"))))));
}
use of org.hl7.fhir.r4.model.Group in project openmrs-module-fhir2 by openmrs.
the class GroupResourceProviderIntegrationTest method shouldCreateNewGroupAsJson.
@Test
public void shouldCreateNewGroupAsJson() throws Exception {
// read JSON record
String jsonGroup;
try (InputStream is = this.getClass().getClassLoader().getResourceAsStream(JSON_CREATE_GROUP_DOCUMENT)) {
Objects.requireNonNull(is);
jsonGroup = IOUtils.toString(is, StandardCharsets.UTF_8);
}
// create group
MockHttpServletResponse response = post("/Group").accept(FhirMediaTypes.JSON).jsonContent(jsonGroup).go();
// verify created correctly
assertThat(response, isCreated());
assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
assertThat(response.getContentAsString(), notNullValue());
Group group = readResponse(response);
assertThat(group, notNullValue());
assertThat(group.getActive(), is(true));
assertThat(group.hasMember(), is(true));
assertThat(group.getMember(), notNullValue());
assertThat(group.getQuantity(), equalTo(1));
// try to get new group
response = get(group.getId()).accept(FhirMediaTypes.JSON).go();
assertThat(response, isOk());
Group newGroup = readResponse(response);
assertThat(newGroup.getId(), equalTo(group.getId()));
assertThat(newGroup.getActive(), equalTo(true));
}
use of org.hl7.fhir.r4.model.Group in project openmrs-module-fhir2 by openmrs.
the class GroupResourceProviderIntegrationTest method shouldReturnNotFoundWhenUpdatingNonExistentGroupAsXML.
@Test
public void shouldReturnNotFoundWhenUpdatingNonExistentGroupAsXML() throws Exception {
// get the existing record
MockHttpServletResponse response = get("/Group/" + GROUP_UUID).accept(FhirMediaTypes.XML).go();
Group group = readResponse(response);
// update the existing record
group.setId(BAD_GROUP_UUID);
// send the update to the server
response = put("/Group/" + BAD_GROUP_UUID).xmlContent(toXML(group)).accept(FhirMediaTypes.XML).go();
assertThat(response, isNotFound());
assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
assertThat(response.getContentAsString(), notNullValue());
OperationOutcome operationOutcome = readOperationOutcome(response);
assertThat(operationOutcome, notNullValue());
assertThat(operationOutcome.hasIssue(), is(true));
}
Aggregations