use of org.hl7.fhir.r4.model.Group in project openmrs-module-fhir2 by openmrs.
the class GroupTranslatorImplTest method shouldTranslateGroupTypeToAlwaysPerson.
@Test
public void shouldTranslateGroupTypeToAlwaysPerson() {
Cohort cohort = mock(Cohort.class);
Group group = groupTranslator.toFhirResource(cohort);
assertThat(group, notNullValue());
assertThat(group.getType(), is(Group.GroupType.PERSON));
}
use of org.hl7.fhir.r4.model.Group in project openmrs-module-fhir2 by openmrs.
the class GroupTranslatorImplTest method shouldTranslateFHIRGroupMembersToOpenMRSCohortMembers.
@Test
@Ignore
public void shouldTranslateFHIRGroupMembersToOpenMRSCohortMembers() {
Group group = mock(Group.class);
GroupMember groupMember = mock(GroupMember.class);
Reference memberRef = mock(Reference.class);
Group.GroupMemberComponent groupMemberComponent = mock(Group.GroupMemberComponent.class);
when(group.hasMember()).thenReturn(true);
when(group.getMember()).thenReturn(Arrays.asList(groupMemberComponent, groupMemberComponent));
when(groupMember.hasEntity()).thenReturn(true);
when(groupMember.getEntity()).thenReturn(memberRef);
// when(memberRef.getReference()).thenReturn("ref-xxx");
when(groupMemberTranslator.toOpenmrsType(groupMember)).thenReturn(1);
Cohort cohort = groupTranslator.toOpenmrsType(group);
assertThat(cohort, notNullValue());
assertThat(cohort.getMemberIds().isEmpty(), is(false));
assertThat(cohort.getMemberIds(), hasSize(1));
assertThat(cohort.getMemberIds().iterator().next(), is(1));
}
use of org.hl7.fhir.r4.model.Group in project openmrs-module-fhir2 by openmrs.
the class GroupTranslatorImplTest method shouldTranslateNameToNameFHIRType.
@Test
public void shouldTranslateNameToNameFHIRType() {
Cohort cohort = mock(Cohort.class);
when(cohort.getName()).thenReturn(COHORT_NAME);
Group group = groupTranslator.toFhirResource(cohort);
assertThat(group, notNullValue());
assertThat(group.getName(), is(COHORT_NAME));
}
use of org.hl7.fhir.r4.model.Group in project openmrs-module-fhir2 by openmrs.
the class GroupTranslatorImplTest method shouldTranslateActiveFHIRTypeToIsVoidedOpenMRSType.
@Test
public void shouldTranslateActiveFHIRTypeToIsVoidedOpenMRSType() {
Group group = mock(Group.class);
when(group.hasActive()).thenReturn(true);
when(group.getActive()).thenReturn(true);
Cohort cohort = groupTranslator.toOpenmrsType(group);
assertThat(cohort, notNullValue());
assertThat(cohort.getVoided(), is(false));
}
use of org.hl7.fhir.r4.model.Group in project openmrs-module-fhir2 by openmrs.
the class BaseGroupTranslatorTest method shouldTranslateManagingEntityToCreatorOpenMRSType.
@Test
public void shouldTranslateManagingEntityToCreatorOpenMRSType() {
User user = mock(User.class);
Reference practitionerRef = mock(Reference.class);
when(practitionerReferenceTranslator.toOpenmrsType(practitionerRef)).thenReturn(user);
group.setManagingEntity(practitionerRef);
Cohort result = baseGroupTranslator.toOpenmrsType(cohort, group);
assertThat(result, notNullValue());
assertThat(result.getCreator(), notNullValue());
assertThat(result.getCreator(), is(user));
}
Aggregations