use of org.hl7.fhir.dstu3.model.Library in project quality-measure-and-cohort-service by Alvearie.
the class RestFhirLibraryResolverIntegrationTest method resolveLibraryByCanonicalUrl_twice___returns_cached_data.
@Test
public void resolveLibraryByCanonicalUrl_twice___returns_cached_data() throws Exception {
resolver = new CachingFhirResourceResolver<>(resolver);
Library library = getLibrary("Test", DEFAULT_VERSION, "cql/basic/Test-1.0.0.cql");
library.setUrl(TEST_URL);
Library actual = runTest(TEST_URL, makeBundle(library));
assertNotNull(actual);
assertEquals(library.getUrl(), actual.getUrl());
resolver.resolveByCanonicalUrl(TEST_URL);
verify(1, getRequestedFor(urlMatching("/Library\\?url=.*")));
}
use of org.hl7.fhir.dstu3.model.Library in project quality-measure-and-cohort-service by Alvearie.
the class RestFhirLibraryResolverIntegrationTest method resolveLibraryByCanonicalUrl___exception_when_multiple_library_found.
@Test(expected = IllegalArgumentException.class)
public void resolveLibraryByCanonicalUrl___exception_when_multiple_library_found() throws Exception {
Library library1 = getLibrary("Test", DEFAULT_VERSION, "cql/basic/Test-1.0.0.cql");
library1.setUrl(TEST_URL);
Library library2 = getLibrary("Test", DEFAULT_VERSION, "cql/basic/Test-1.0.0.cql");
library2.setUrl(TEST_URL);
runTest(TEST_URL, makeBundle(library1, library2));
}
use of org.hl7.fhir.dstu3.model.Library in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluationSeederTest method create_noLibraryOnMeasure.
@Test(expected = IllegalArgumentException.class)
public void create_noLibraryOnMeasure() {
Measure measure = createMeasure();
FhirResourceResolver<Library> libraryResolver = Mockito.mock(FhirResourceResolver.class);
R4LibraryDependencyGatherer dependencyGatherer = Mockito.mock(R4LibraryDependencyGatherer.class);
Mockito.when(dependencyGatherer.gatherForMeasure(measure)).thenReturn(Collections.emptyList());
MeasureEvaluationSeeder seeder = new MeasureEvaluationSeeder(null, null, dependencyGatherer, libraryResolver);
seeder.create(measure, periodStart, periodEnd, null, null);
}
use of org.hl7.fhir.dstu3.model.Library in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluationSeederTest method create_fullContext.
@Test
public void create_fullContext() throws IOException {
TerminologyProvider terminologyProvider = Mockito.mock(TerminologyProvider.class);
CqlDataProvider dataProvider = Mockito.mock(CqlDataProvider.class);
Map<String, CqlDataProvider> dataProviders = new HashMap<>();
dataProviders.put(fhirUri, dataProvider);
Measure measure = createMeasure();
Library library = createLibrary("/cql/seeder/Test-1.0.0.xml");
FhirResourceResolver<Library> libraryResolver = Mockito.mock(FhirResourceResolver.class);
Mockito.when(libraryResolver.resolveByName(libraryName, libraryVersion)).thenReturn(library);
R4LibraryDependencyGatherer dependencyGatherer = Mockito.mock(R4LibraryDependencyGatherer.class);
Mockito.when(dependencyGatherer.gatherForMeasure(measure)).thenReturn(Collections.singletonList(library));
MeasureEvaluationSeeder seeder = new MeasureEvaluationSeeder(terminologyProvider, dataProviders, dependencyGatherer, libraryResolver);
seeder.enableExpressionCaching();
IMeasureEvaluationSeed actual = seeder.create(measure, periodStart, periodEnd, productLine, null);
Interval expectedInterval = createInterval();
Assert.assertEquals(0, expectedInterval.compareTo(actual.getMeasurementPeriod()));
Assert.assertSame(measure, actual.getMeasure());
Assert.assertSame(dataProvider, actual.getDataProvider());
// Attempt to validate the `Context` by looking for key fields under our control.
Assert.assertSame(terminologyProvider, actual.getContext().resolveTerminologyProvider());
Assert.assertEquals(productLine, actual.getContext().resolveParameterRef(null, "Product Line"));
Assert.assertTrue(actual.getContext().isExpressionCachingEnabled());
Assert.assertNotNull(actual.getContext().getDebugMap());
}
use of org.hl7.fhir.dstu3.model.Library in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluationSeederTest method create_minimalContext.
@Test
public void create_minimalContext() throws IOException {
TerminologyProvider terminologyProvider = Mockito.mock(TerminologyProvider.class);
CqlDataProvider dataProvider = Mockito.mock(CqlDataProvider.class);
Map<String, CqlDataProvider> dataProviders = new HashMap<>();
dataProviders.put(fhirUri, dataProvider);
Library library = createLibrary("/cql/seeder/Test-1.0.0.xml");
FhirResourceResolver<Library> libraryResolver = Mockito.mock(FhirResourceResolver.class);
Mockito.when(libraryResolver.resolveByName(libraryName, libraryVersion)).thenReturn(library);
Measure measure = createMeasure();
R4LibraryDependencyGatherer dependencyGatherer = Mockito.mock(R4LibraryDependencyGatherer.class);
Mockito.when(dependencyGatherer.gatherForMeasure(measure)).thenReturn(Collections.singletonList(library));
MeasureEvaluationSeeder seeder = new MeasureEvaluationSeeder(terminologyProvider, dataProviders, dependencyGatherer, libraryResolver);
seeder.disableDebugLogging();
IMeasureEvaluationSeed actual = seeder.create(measure, periodStart, periodEnd, null, null);
Interval expectedInterval = createInterval();
Assert.assertEquals(0, expectedInterval.compareTo(actual.getMeasurementPeriod()));
Assert.assertSame(measure, actual.getMeasure());
Assert.assertSame(dataProvider, actual.getDataProvider());
// Attempt to validate the `Context` by looking for key fields under our control.
Assert.assertSame(terminologyProvider, actual.getContext().resolveTerminologyProvider());
Assert.assertThrows(NullPointerException.class, () -> actual.getContext().resolveParameterRef(null, "Product Line"));
Assert.assertFalse(actual.getContext().isExpressionCachingEnabled());
Assert.assertNull(actual.getContext().getDebugMap());
}
Aggregations