diff --git a/.github/workflows/maven-ci.yml b/.github/workflows/maven-ci.yml index 2412c18..6d22351 100644 --- a/.github/workflows/maven-ci.yml +++ b/.github/workflows/maven-ci.yml @@ -30,7 +30,7 @@ jobs: permissions: contents: read packages: write - if: github.ref == 'refs/heads/1.0.1_hotfix' + if: github.ref == 'refs/heads/1.0.2_hotfix' steps: - uses: actions/checkout@v4 - name: Set up JDK 17 diff --git a/pom.xml b/pom.xml index 0d3d5e1..488115c 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 gov.cms.madie madie-translator-commons - 1.0.2 + 1.0.3-SNAPSHOT UTF-8 17 diff --git a/src/main/java/gov/cms/madie/cql_elm_translator/service/CqlLibraryService.java b/src/main/java/gov/cms/madie/cql_elm_translator/service/CqlLibraryService.java index 3b2584e..d83d61a 100644 --- a/src/main/java/gov/cms/madie/cql_elm_translator/service/CqlLibraryService.java +++ b/src/main/java/gov/cms/madie/cql_elm_translator/service/CqlLibraryService.java @@ -62,7 +62,7 @@ public String getLibraryCql(String name, String version, String accessToken) { UsingProperties libraryUsing = new CqlTextParser(responseEntity.getBody()).getUsing(); if (libraryUsing.getLine().equals(MadieLibrarySourceProvider.getUsingProperties().getLine()) - || supportedLibraries.contains(libraryUsing.getLibraryType())) { + && supportedLibraries.contains(libraryUsing.getLibraryType())) { return responseEntity.getBody(); } log.error("Library model and version does not match the Measure model and version"); diff --git a/src/test/java/gov/cms/madie/cql_elm_translator/services/CqlLibraryServiceTest.java b/src/test/java/gov/cms/madie/cql_elm_translator/services/CqlLibraryServiceTest.java index 48fc226..ee74676 100644 --- a/src/test/java/gov/cms/madie/cql_elm_translator/services/CqlLibraryServiceTest.java +++ b/src/test/java/gov/cms/madie/cql_elm_translator/services/CqlLibraryServiceTest.java @@ -78,7 +78,7 @@ void getLibraryCql() { } @Test - void getLibraryCqlThrowCqlIncludeException() { + void getLibraryCqlWrongModelThrowCqlIncludeException() { String cql = "library QICoreCommon version '1.3.000'\n" + "using QICore version '4.1.1'\n" @@ -97,6 +97,46 @@ void getLibraryCqlThrowCqlIncludeException() { () -> cqlLibraryService.getLibraryCql(cqlLibraryName, cqlLibraryVersion, accessToken)); } + @Test + void getLibraryCqlWrongVersionThrowCqlIncludeException() { + String cql = + "library QICoreCommon version '1.3.000'\n" + + "using QICore version '4.1.1'\n" + + "Response Cql String"; + cqlLibraryService.setUpLibrarySourceProvider(cql, "ACCESS_TOKEN"); + + String wrongLibrarycql = + "library QICoreCommon version '1.3.000'\n" + + "using QICore version '6.0.0'\n" + + "Response Cql String"; + when(restTemplate.exchange( + libraryUri, HttpMethod.GET, new HttpEntity<>(httpHeaders), String.class)) + .thenReturn(new ResponseEntity<>(wrongLibrarycql, HttpStatus.OK)); + assertThrows( + CqlIncludeException.class, + () -> cqlLibraryService.getLibraryCql(cqlLibraryName, cqlLibraryVersion, accessToken)); + } + + @Test + void getLibraryCqlWrongModelAndVersionThrowCqlIncludeException() { + String cql = + "library QICoreCommon version '1.3.000'\n" + + "using QICore version '4.1.1'\n" + + "Response Cql String"; + cqlLibraryService.setUpLibrarySourceProvider(cql, "ACCESS_TOKEN"); + + String wrongLibrarycql = + "library QICoreCommon version '1.3.000'\n" + + "using FHIR version '4.0.1'\n" + + "Response Cql String"; + when(restTemplate.exchange( + libraryUri, HttpMethod.GET, new HttpEntity<>(httpHeaders), String.class)) + .thenReturn(new ResponseEntity<>(wrongLibrarycql, HttpStatus.OK)); + assertThrows( + CqlIncludeException.class, + () -> cqlLibraryService.getLibraryCql(cqlLibraryName, cqlLibraryVersion, accessToken)); + } + @Test void getLibraryCqlReturnsNull() { when(restTemplate.exchange(