From ef91c41bfa04bbc5f9337b4a5ce85b70cb758dcf Mon Sep 17 00:00:00 2001 From: adongare Date: Fri, 26 May 2023 08:08:45 -0400 Subject: [PATCH] MAT-5567 more test cases --- .../cql_elm_translation/service/DataCriteriaService.java | 7 +++++++ .../service/DataCriteriaServiceTest.java | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/gov/cms/mat/cql_elm_translation/service/DataCriteriaService.java b/src/main/java/gov/cms/mat/cql_elm_translation/service/DataCriteriaService.java index 05777345..e93f6471 100644 --- a/src/main/java/gov/cms/mat/cql_elm_translation/service/DataCriteriaService.java +++ b/src/main/java/gov/cms/mat/cql_elm_translation/service/DataCriteriaService.java @@ -11,6 +11,7 @@ import gov.cms.mat.cql_elm_translation.utils.cql.parsing.model.CQLValueSet; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.collections4.MapUtils; import org.cqframework.cql.cql2elm.CqlTranslator; @@ -56,10 +57,16 @@ public DataCriteria parseDataCriteriaFromCql(String cql, String accessToken) { } public List getSourceDataCriteria(String cql, String accessToken) { + if (StringUtils.isBlank(cql)) { + log.info("Data criteria not found as cql is blank"); + return Collections.emptyList(); + } + DataCriteria dataCriteria = parseDataCriteriaFromCql(cql, accessToken); Map> criteriaWithValueSet = dataCriteria.getDataCriteriaWithValueSets(); if (MapUtils.isEmpty(criteriaWithValueSet)) { + log.info("Data criteria not found for given cql"); return Collections.emptyList(); } // data criteria from value sets diff --git a/src/test/java/gov/cms/mat/cql_elm_translation/service/DataCriteriaServiceTest.java b/src/test/java/gov/cms/mat/cql_elm_translation/service/DataCriteriaServiceTest.java index e56df3e9..0c8e8d68 100644 --- a/src/test/java/gov/cms/mat/cql_elm_translation/service/DataCriteriaServiceTest.java +++ b/src/test/java/gov/cms/mat/cql_elm_translation/service/DataCriteriaServiceTest.java @@ -111,7 +111,13 @@ void testGetSourceDataCriteriaWhenNoSourceCriteriaFound() { List sourceDataCriteria = dataCriteriaService.getSourceDataCriteria(cql, token); - // source data criteria for value set + assertThat(sourceDataCriteria.size(), is(equalTo(0))); + } + + @Test + void testGetSourceDataCriteriaWhenNoCqlProvided() { + List sourceDataCriteria = + dataCriteriaService.getSourceDataCriteria("", token); assertThat(sourceDataCriteria.size(), is(equalTo(0))); } }