Search in sources :

Example 1 with FhirGlobalPropertyService

use of org.openmrs.module.fhir2.api.FhirGlobalPropertyService in project openmrs-module-fhir2 by openmrs.

the class MockedGlobalPropertyServiceConfiguration method getFhirGlobalPropertyService.

@Bean
@Primary
public FhirGlobalPropertyService getFhirGlobalPropertyService() {
    FhirGlobalPropertyService globalPropertyService = Mockito.mock(FhirGlobalPropertyService.class);
    when(globalPropertyService.getGlobalProperty("default_locale", "en_GB")).thenReturn("en_GB");
    return globalPropertyService;
}
Also used : FhirGlobalPropertyService(org.openmrs.module.fhir2.api.FhirGlobalPropertyService) Primary(org.springframework.context.annotation.Primary) Bean(org.springframework.context.annotation.Bean)

Example 2 with FhirGlobalPropertyService

use of org.openmrs.module.fhir2.api.FhirGlobalPropertyService in project openmrs-module-fhir2 by openmrs.

the class FhirTaskServiceImplTest method searchForTasks_shouldReturnTasksByParameters.

@Test
public void searchForTasks_shouldReturnTasksByParameters() {
    List<FhirTask> openmrsTasks = new ArrayList<>();
    FhirTask openmrsTask = new FhirTask();
    openmrsTask.setUuid(TASK_UUID);
    openmrsTasks.add(openmrsTask);
    Task task = new Task();
    task.setId(TASK_UUID);
    SearchParameterMap theParams = new SearchParameterMap();
    when(dao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(TASK_UUID));
    when(dao.getSearchResults(any(), any())).thenReturn(openmrsTasks);
    when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, translator, fhirGlobalPropertyService, searchQueryInclude));
    when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
    when(translator.toFhirResource(openmrsTask)).thenReturn(task);
    IBundleProvider results = fhirTaskService.searchForTasks(null, null, null, null, null, null, null);
    List<IBaseResource> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList, not(empty()));
    assertThat(resultList, hasItem(hasProperty("id", equalTo(TASK_UUID))));
}
Also used : Task(org.hl7.fhir.r4.model.Task) FhirTask(org.openmrs.module.fhir2.model.FhirTask) FhirTask(org.openmrs.module.fhir2.model.FhirTask) ArrayList(java.util.ArrayList) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Example 3 with FhirGlobalPropertyService

use of org.openmrs.module.fhir2.api.FhirGlobalPropertyService in project openmrs-module-fhir2 by openmrs.

the class FhirGlobalPropertyServiceImplTest method shouldReturnStringGlobalPropertyValueWhenPropertyMatched.

@Test
public void shouldReturnStringGlobalPropertyValueWhenPropertyMatched() {
    FhirGlobalPropertyService globalPropertyService = mock(FhirGlobalPropertyService.class);
    when(globalPropertyService.getGlobalProperty(DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZE_STRING_VALUE)).thenReturn("100");
    String result = globalPropertyService.getGlobalProperty(DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZE_STRING_VALUE);
    assertThat(result, notNullValue());
    assertThat(result, is("100"));
}
Also used : FhirGlobalPropertyService(org.openmrs.module.fhir2.api.FhirGlobalPropertyService) Test(org.junit.Test)

Example 4 with FhirGlobalPropertyService

use of org.openmrs.module.fhir2.api.FhirGlobalPropertyService in project openmrs-module-fhir2 by openmrs.

the class FhirGlobalPropertyServiceImplTest method shouldReturnIntegerGlobalPropertyValueWhenPropertyMatched.

@Test
public void shouldReturnIntegerGlobalPropertyValueWhenPropertyMatched() {
    FhirGlobalPropertyService globalPropertyService = mock(FhirGlobalPropertyService.class);
    when(globalPropertyService.getGlobalProperty(DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZE_INTEGER_VALUE)).thenReturn(100);
    int result = globalPropertyService.getGlobalProperty(DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZE_INTEGER_VALUE);
    assertThat(result, notNullValue());
    assertThat(result, is(100));
}
Also used : FhirGlobalPropertyService(org.openmrs.module.fhir2.api.FhirGlobalPropertyService) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 FhirGlobalPropertyService (org.openmrs.module.fhir2.api.FhirGlobalPropertyService)3 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)1 ArrayList (java.util.ArrayList)1 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)1 Task (org.hl7.fhir.r4.model.Task)1 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)1 FhirTask (org.openmrs.module.fhir2.model.FhirTask)1 Bean (org.springframework.context.annotation.Bean)1 Primary (org.springframework.context.annotation.Primary)1