Skip to content

Commit

Permalink
MAT-7929: Fixing conditional that wasn't checking for model/version m…
Browse files Browse the repository at this point in the history
…atches correctly
  • Loading branch information
gregory-akins committed Dec 12, 2024
1 parent c409e38 commit 74bea7b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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(
Expand Down

0 comments on commit 74bea7b

Please sign in to comment.