use of org.hl7.fhir.r4.model.Group in project openmrs-module-fhir2 by openmrs.
the class FhirGroupServiceImplTest method shouldDeleteGroup.
@Test
public void shouldDeleteGroup() {
Group group = new Group();
group.setId(COHORT_UUID);
when(dao.delete(COHORT_UUID)).thenReturn(cohort);
when(translator.toFhirResource(cohort)).thenReturn(group);
Group result = groupService.delete(COHORT_UUID);
assertThat(result, notNullValue());
assertThat(result.getId(), equalTo(COHORT_UUID));
assertThat(result.getActive(), is(false));
}
use of org.hl7.fhir.r4.model.Group in project openmrs-module-fhir2 by openmrs.
the class GroupTranslatorImplTest method shouldUpdateIsVoidedOpenMRSType.
@Test
public void shouldUpdateIsVoidedOpenMRSType() {
Cohort cohort = new Cohort();
cohort.setVoided(false);
Group group = mock(Group.class);
when(group.hasActive()).thenReturn(true);
when(group.getActive()).thenReturn(false);
Cohort updateCohort = groupTranslator.toOpenmrsType(cohort, group);
assertThat(updateCohort, notNullValue());
assertThat(updateCohort.getVoided(), is(true));
}
use of org.hl7.fhir.r4.model.Group in project openmrs-module-fhir2 by openmrs.
the class GroupTranslatorImplTest method shouldTranslateUuidToIdFHIRType.
@Test
public void shouldTranslateUuidToIdFHIRType() {
Cohort cohort = mock(Cohort.class);
when(cohort.getUuid()).thenReturn(COHORT_UUID);
Group group = groupTranslator.toFhirResource(cohort);
assertThat(group, notNullValue());
assertThat(group.getId(), is(COHORT_UUID));
}
use of org.hl7.fhir.r4.model.Group in project openmrs-module-fhir2 by openmrs.
the class GroupTranslatorImplTest method shouldTranslateCreatorToManagingEntityFHIRType.
@Test
public void shouldTranslateCreatorToManagingEntityFHIRType() {
User user = mock(User.class);
Cohort cohort = new Cohort();
cohort.setUuid(COHORT_UUID);
cohort.setName(COHORT_NAME);
cohort.setCreator(user);
Reference practitionerRef = mock(Reference.class);
when(practitionerReferenceTranslator.toFhirResource(user)).thenReturn(practitionerRef);
Group result = groupTranslator.toFhirResource(cohort);
assertThat(result, notNullValue());
assertThat(result.hasManagingEntity(), is(true));
assertThat(result.getManagingEntity(), is(practitionerRef));
}
use of org.hl7.fhir.r4.model.Group in project openmrs-module-fhir2 by openmrs.
the class GroupTranslatorImplTest method shouldTranslateCohortMembersToFHIRGroupMembers.
@Test
@Ignore
public void shouldTranslateCohortMembersToFHIRGroupMembers() {
Cohort cohort = mock(Cohort.class);
Reference patientReference = mock(Reference.class);
Group.GroupMemberComponent groupMemberComponent = mock(Group.GroupMemberComponent.class);
when(cohort.getMemberIds()).thenReturn(new HashSet<>(Arrays.asList(1, 2, 3)));
// when(groupMemberTranslator.toFhirResource(anyInt())).thenReturn(new GroupMember(groupMemberComponent.getEntity()));
when(groupMemberComponent.hasEntity()).thenReturn(true);
when(groupMemberComponent.getEntity()).thenReturn(patientReference);
Group group = groupTranslator.toFhirResource(cohort);
assertThat(group, notNullValue());
assertThat(group.hasMember(), is(true));
assertThat(group.getMemberFirstRep().hasEntity(), is(true));
assertThat(group.getMemberFirstRep().getEntity(), is(patientReference));
}
Aggregations