Search in sources :

Example 41 with Group

use of org.hl7.fhir.r4.model.Group in project openmrs-module-fhir2 by openmrs.

the class FhirGroupServiceImplTest method getGroupByUuid_shouldGetGroupByUuid.

@Test
public void getGroupByUuid_shouldGetGroupByUuid() {
    when(dao.get(COHORT_UUID)).thenReturn(cohort);
    when(translator.toFhirResource(cohort)).thenReturn(group);
    Group group = groupService.get(COHORT_UUID);
    assertThat(group, notNullValue());
    assertThat(group.getId(), notNullValue());
    assertThat(group.getId(), equalTo(COHORT_UUID));
}
Also used : Group(org.hl7.fhir.r4.model.Group) Test(org.junit.Test)

Example 42 with Group

use of org.hl7.fhir.r4.model.Group in project openmrs-module-fhir2 by openmrs.

the class FhirGroupServiceImplTest method updateGroupShouldThrowInvalidRequestExceptionIfIdIsNull.

@Test(expected = InvalidRequestException.class)
public void updateGroupShouldThrowInvalidRequestExceptionIfIdIsNull() {
    Group group = new Group();
    group.setId(COHORT_UUID);
    groupService.update(null, group);
}
Also used : Group(org.hl7.fhir.r4.model.Group) Test(org.junit.Test)

Example 43 with Group

use of org.hl7.fhir.r4.model.Group in project openmrs-module-fhir2 by openmrs.

the class FhirGroupServiceImplTest method updateGroupShouldThrowResourceNotFoundException.

@Test(expected = ResourceNotFoundException.class)
public void updateGroupShouldThrowResourceNotFoundException() {
    Group group = new Group();
    group.setId(COHORT_UUID);
    groupService.update(COHORT_UUID, group);
}
Also used : Group(org.hl7.fhir.r4.model.Group) Test(org.junit.Test)

Example 44 with Group

use of org.hl7.fhir.r4.model.Group in project openmrs-module-fhir2 by openmrs.

the class FhirGroupServiceImplTest method setup.

@Before
public void setup() {
    groupService = new FhirGroupServiceImpl() {

        @Override
        protected void validateObject(Cohort object) {
        }
    };
    groupService.setDao(dao);
    groupService.setTranslator(translator);
    groupService.setSearchQuery(searchQuery);
    groupService.setSearchQueryInclude(searchQueryInclude);
    group = new Group();
    group.setId(COHORT_UUID);
    cohort = new Cohort();
    cohort.setUuid(COHORT_UUID);
}
Also used : Group(org.hl7.fhir.r4.model.Group) Cohort(org.openmrs.Cohort) Before(org.junit.Before)

Example 45 with Group

use of org.hl7.fhir.r4.model.Group in project openmrs-module-fhir2 by openmrs.

the class FhirGroupServiceImplTest method shouldSaveNewGroup.

@Test
public void shouldSaveNewGroup() {
    Cohort cohort = new Cohort();
    cohort.setUuid(COHORT_UUID);
    Group group = new Group();
    group.setId(COHORT_UUID);
    when(translator.toFhirResource(cohort)).thenReturn(group);
    when(translator.toOpenmrsType(group)).thenReturn(cohort);
    when(dao.createOrUpdate(cohort)).thenReturn(cohort);
    Group result = groupService.create(group);
    assertThat(result, notNullValue());
    assertThat(result.getId(), equalTo(COHORT_UUID));
}
Also used : Group(org.hl7.fhir.r4.model.Group) Cohort(org.openmrs.Cohort) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)106 Group (org.hl7.fhir.r4.model.Group)74 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)59 ArrayList (java.util.ArrayList)57 BaseFhirIntegrationTest (org.openmrs.module.fhir2.BaseFhirIntegrationTest)50 Group (org.hl7.fhir.dstu3.model.Group)44 FHIRException (org.hl7.fhir.exceptions.FHIRException)37 Cohort (org.openmrs.Cohort)32 Test (org.junit.jupiter.api.Test)29 InputStream (java.io.InputStream)21 Reference (org.hl7.fhir.r4.model.Reference)21 List (java.util.List)16 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)16 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)16 Coding (org.hl7.fhir.r4.model.Coding)16 Diagnosis (gov.cms.bfd.server.war.commons.Diagnosis)15 IOException (java.io.IOException)13 IdType (org.hl7.fhir.dstu3.model.IdType)13 OperationOutcome (org.hl7.fhir.r4.model.OperationOutcome)13 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)13