use of com.ibm.cohort.cql.library.CqlLibraryProvider in project quality-measure-and-cohort-service by Alvearie.
the class CqlTranslationIntegrationTest method multipleFilesInFolder__translatedSuccessfully.
@Test
public void multipleFilesInFolder__translatedSuccessfully() throws Exception {
Path rootDirectory = Paths.get("src/test/resources/cql/multiple-files");
MapCqlLibraryProviderFactory providerFactory = new MapCqlLibraryProviderFactory();
CqlLibraryProvider backingLibraryProvider = providerFactory.fromDirectory(rootDirectory);
runMultipleFilesTest(backingLibraryProvider);
}
use of com.ibm.cohort.cql.library.CqlLibraryProvider in project quality-measure-and-cohort-service by Alvearie.
the class CqlTranslationIntegrationTest method runMultipleFilesTest.
private void runMultipleFilesTest(CqlLibraryProvider backingLibraryProvider) {
Path modelInfo = Paths.get("src/test/resources/modelinfo/ig-with-target-modelinfo-0.0.1.xml");
CqlToElmTranslator translator = new CqlToElmTranslator();
translator.registerModelInfo(modelInfo.toFile());
CqlLibraryProvider libraryProvider = new TranslatingCqlLibraryProvider(backingLibraryProvider, translator, true);
List<String> libraryNames = Arrays.asList("BreastCancerScreening", "Test", "TestDateQuery");
for (String libraryName : libraryNames) {
CqlLibraryDescriptor descriptor = new CqlLibraryDescriptor().setLibraryId(libraryName).setVersion("1.0.0").setFormat(Format.ELM);
CqlLibrary library = libraryProvider.getLibrary(descriptor);
Assert.assertFalse(library.getContent().isEmpty());
}
}
use of com.ibm.cohort.cql.library.CqlLibraryProvider in project quality-measure-and-cohort-service by Alvearie.
the class CqlTranslationIntegrationTest method exceptionCausedByNotIncludingFHIRHelpers.
@Test
public void exceptionCausedByNotIncludingFHIRHelpers() {
CqlLibraryProvider backingLibraryProvider = new ClasspathCqlLibraryProvider("cql.failure");
CqlToElmTranslator translator = new CqlToElmTranslator();
CqlLibraryProvider translatingLibraryProvider = new TranslatingCqlLibraryProvider(backingLibraryProvider, translator, true);
boolean failed = false;
CqlLibraryDescriptor descriptor = new CqlLibraryDescriptor().setLibraryId("MissingFhirHelpers").setVersion("1.0.0").setFormat(Format.ELM);
try {
translatingLibraryProvider.getLibrary(descriptor);
} catch (Exception e) {
failed = true;
Assert.assertTrue("Unexpected exception message: " + e.getMessage(), e.getMessage().startsWith("There were exceptions during cql translation:"));
}
if (!failed) {
Assert.fail("Did not fail translation");
}
}
use of com.ibm.cohort.cql.library.CqlLibraryProvider in project quality-measure-and-cohort-service by Alvearie.
the class CqlTranslationIntegrationTest method singleFile_withOptions__translatedSuccessfully.
@Test
public void singleFile_withOptions__translatedSuccessfully() {
CqlLibraryProvider backingLibraryProvider = new ClasspathCqlLibraryProvider("cql.basic");
CqlToElmTranslator translator = new CqlToElmTranslator();
Path modelInfo = Paths.get("src/test/resources/modelinfo/ig-with-target-modelinfo-0.0.1.xml");
translator.registerModelInfo(modelInfo.toFile());
CqlLibraryProvider translatingLibraryProvider = new TranslatingCqlLibraryProvider(backingLibraryProvider, translator, true);
LibraryLoader libraryLoader = new ProviderBasedLibraryLoader(translatingLibraryProvider);
VersionedIdentifier identifier = new VersionedIdentifier().withId("Test").withVersion("1.0.0");
Library library = libraryLoader.load(identifier);
Assert.assertEquals(identifier, library.getIdentifier());
Assert.assertEquals(2, library.getAnnotation().size());
Assert.assertEquals(4, library.getStatements().getDef().size());
}
use of com.ibm.cohort.cql.library.CqlLibraryProvider in project quality-measure-and-cohort-service by Alvearie.
the class TranslatingCqlLibraryProviderTest method testLoadWithTranslation.
@Test
public void testLoadWithTranslation() throws Exception {
CqlToElmTranslator translator = new CqlToElmTranslator();
try (Reader modelInfoXML = new FileReader("src/test/resources/modelinfo/mock-modelinfo-1.0.0.xml")) {
translator.registerModelInfo(modelInfoXML);
}
CqlLibraryProvider backingProvider = new ClasspathCqlLibraryProvider("cql");
CqlLibraryProvider provider = new TranslatingCqlLibraryProvider(backingProvider, translator);
CqlLibraryDescriptor descriptor = new CqlLibraryDescriptor().setLibraryId("CohortHelpers").setVersion("1.0.0").setFormat(Format.CQL);
CqlLibrary library = provider.getLibrary(descriptor);
assertEquals(Format.CQL, library.getDescriptor().getFormat());
assertTrue(library.getContent().startsWith("library"));
descriptor.setFormat(Format.ELM);
library = provider.getLibrary(descriptor);
assertEquals(Format.ELM, library.getDescriptor().getFormat());
assertTrue(library.getContent().startsWith("<?xml"));
}
Aggregations