use of org.openmrs.module.fhir2.model.GroupMember in project openmrs-module-fhir2 by openmrs.
the class GroupTranslatorImpl_2_1Test method shouldTranslateFHIRGroupMembersToOpenMRSCohortMembers.
@Test
public void shouldTranslateFHIRGroupMembersToOpenMRSCohortMembers() {
Group group = mock(Group.class);
CohortMembership cohortMembership = mock(CohortMembership.class);
GroupMember groupMember = mock(GroupMember.class);
Group.GroupMemberComponent groupMemberComponent = mock(Group.GroupMemberComponent.class);
when(group.hasMember()).thenReturn(true);
when(group.getMember()).thenReturn(Arrays.asList(groupMemberComponent, groupMemberComponent));
when(groupMemberTranslator21.toOpenmrsType(groupMember)).thenReturn(cohortMembership);
when(componentTranslator.toOpenmrsType(groupMemberComponent)).thenReturn(groupMember);
Cohort cohort = groupTranslator.toOpenmrsType(group);
assertThat(cohort, notNullValue());
assertThat(cohort.getMemberships().isEmpty(), is(false));
assertThat(cohort.getMemberships(), hasSize(1));
assertThat(cohort.getMemberships().iterator().next(), is(cohortMembership));
}
use of org.openmrs.module.fhir2.model.GroupMember in project openmrs-module-fhir2 by openmrs.
the class GroupResourceProviderIntegrationTest method shouldReturnPaginatedListOfGroupMembersAsJson.
@Test
public void shouldReturnPaginatedListOfGroupMembersAsJson() throws Exception {
MockHttpServletResponse response = get("/Group/" + GROUP_UUID + "/$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(1));
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.openmrs.module.fhir2.model.GroupMember 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.openmrs.module.fhir2.model.GroupMember 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.openmrs.module.fhir2.model.GroupMember in project openmrs-module-fhir2 by openmrs.
the class GroupResourceProviderIntegrationTest method shouldReturnPaginatedListOfGroupMembersAsXml.
@Test
public void shouldReturnPaginatedListOfGroupMembersAsXml() throws Exception {
MockHttpServletResponse response = get("/Group/" + GROUP_UUID + "/$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(1));
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/"))))));
}
Aggregations