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 961620de..05777345 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 @@ -12,7 +12,6 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.codec.digest.DigestUtils; -import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.cqframework.cql.cql2elm.CqlTranslator; import org.cqframework.cql.cql2elm.LibraryBuilder; 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 f7011644..e56df3e9 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 @@ -2,11 +2,8 @@ import gov.cms.mat.cql_elm_translation.ResourceFileUtil; import gov.cms.mat.cql_elm_translation.cql_translator.TranslationResource; -import gov.cms.mat.cql_elm_translation.data.DataCriteria; import gov.cms.mat.cql_elm_translation.data.RequestData; import gov.cms.mat.cql_elm_translation.dto.SourceDataCriteria; -import gov.cms.mat.cql_elm_translation.utils.cql.parsing.model.CQLCode; -import gov.cms.mat.cql_elm_translation.utils.cql.parsing.model.CQLValueSet; import org.cqframework.cql.cql2elm.CqlTranslator; import org.cqframework.cql.cql2elm.LibraryBuilder; import org.junit.jupiter.api.BeforeEach; @@ -18,8 +15,6 @@ import org.mockito.junit.jupiter.MockitoExtension; import java.util.List; -import java.util.Map; -import java.util.Set; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; @@ -32,50 +27,55 @@ @ExtendWith(MockitoExtension.class) public class DataCriteriaServiceTest implements ResourceFileUtil { - @Mock - private CqlConversionService cqlConversionService; + @Mock private CqlConversionService cqlConversionService; - @InjectMocks - private DataCriteriaService dataCriteriaService; + @InjectMocks private DataCriteriaService dataCriteriaService; private final String token = "token"; private String cql; private RequestData requestData; + @BeforeEach void setup() { cql = getData("/qdm_data_criteria_retrieval_test.cql"); requestData = - RequestData.builder() - .cqlData(cql) - .showWarnings(false) - .signatures(LibraryBuilder.SignatureLevel.All) - .annotations(true) - .locators(true) - .disableListDemotion(true) - .disableListPromotion(true) - .disableMethodInvocation(false) - .validateUnits(true) - .resultTypes(true) - .build(); + RequestData.builder() + .cqlData(cql) + .showWarnings(false) + .signatures(LibraryBuilder.SignatureLevel.All) + .annotations(true) + .locators(true) + .disableListDemotion(true) + .disableListPromotion(true) + .disableMethodInvocation(false) + .validateUnits(true) + .resultTypes(true) + .build(); } @Test void testGetSourceDataCriteria() { - CqlTranslator translator = TranslationResource.getInstance(false) - .buildTranslator(requestData.getCqlDataInputStream(), requestData.createMap()); + CqlTranslator translator = + TranslationResource.getInstance(false) + .buildTranslator(requestData.getCqlDataInputStream(), requestData.createMap()); - Mockito.doNothing().when(cqlConversionService).setUpLibrarySourceProvider(anyString(), anyString()); - when(cqlConversionService.processCqlData(any(RequestData.class))) - .thenReturn(translator); + Mockito.doNothing() + .when(cqlConversionService) + .setUpLibrarySourceProvider(anyString(), anyString()); + when(cqlConversionService.processCqlData(any(RequestData.class))).thenReturn(translator); - List sourceDataCriteria = dataCriteriaService.getSourceDataCriteria(cql, token); + List sourceDataCriteria = + dataCriteriaService.getSourceDataCriteria(cql, token); // source data criteria for value set assertThat(sourceDataCriteria.size(), is(equalTo(2))); - assertThat(sourceDataCriteria.get(0).getCodeListId(), is(equalTo("2.16.840.1.113883.3.666.5.307"))); + assertThat( + sourceDataCriteria.get(0).getCodeListId(), is(equalTo("2.16.840.1.113883.3.666.5.307"))); assertThat(sourceDataCriteria.get(0).getQdmTitle(), is(equalTo("Encounter Inpatient"))); assertThat(sourceDataCriteria.get(0).getType(), is(equalTo("EncounterPerformed"))); - assertThat(sourceDataCriteria.get(0).getDescription(), is(equalTo("Encounter, Performed: Encounter Inpatient"))); + assertThat( + sourceDataCriteria.get(0).getDescription(), + is(equalTo("Encounter, Performed: Encounter Inpatient"))); assertFalse(sourceDataCriteria.get(0).isDrc()); // source data criteria for direct reference code @@ -83,27 +83,33 @@ void testGetSourceDataCriteria() { assertTrue(sourceDataCriteria.get(1).isDrc()); assertThat(sourceDataCriteria.get(1).getQdmTitle(), is(equalTo("Clinical Examples"))); assertThat(sourceDataCriteria.get(1).getType(), is(equalTo("EncounterPerformed"))); - assertThat(sourceDataCriteria.get(1).getDescription(), is(equalTo("Encounter, Performed: Clinical Examples"))); + assertThat( + sourceDataCriteria.get(1).getDescription(), + is(equalTo("Encounter, Performed: Clinical Examples"))); } @Test void testGetSourceDataCriteriaWhenNoSourceCriteriaFound() { - String cql = "library DataCriteriaRetrivalTest version '0.0.000'\n" + - "using QDM version '5.6'\n" + - "valueset \"Encounter Inpatient\": 'urn:oid:2.16.840.1.113883.3.666.5.307'\n" + - "parameter \"Measurement Period\" Interval\n" + - "context Patient\n" + - "define \"Qualifying Encounters\":\n true"; + String cql = + "library DataCriteriaRetrivalTest version '0.0.000'\n" + + "using QDM version '5.6'\n" + + "valueset \"Encounter Inpatient\": 'urn:oid:2.16.840.1.113883.3.666.5.307'\n" + + "parameter \"Measurement Period\" Interval\n" + + "context Patient\n" + + "define \"Qualifying Encounters\":\n true"; RequestData data = requestData.toBuilder().cqlData(cql).build(); - CqlTranslator translator = TranslationResource.getInstance(false) - .buildTranslator(data.getCqlDataInputStream(), data.createMap()); + CqlTranslator translator = + TranslationResource.getInstance(false) + .buildTranslator(data.getCqlDataInputStream(), data.createMap()); - Mockito.doNothing().when(cqlConversionService).setUpLibrarySourceProvider(anyString(), anyString()); - when(cqlConversionService.processCqlData(any(RequestData.class))) - .thenReturn(translator); + Mockito.doNothing() + .when(cqlConversionService) + .setUpLibrarySourceProvider(anyString(), anyString()); + when(cqlConversionService.processCqlData(any(RequestData.class))).thenReturn(translator); - List sourceDataCriteria = dataCriteriaService.getSourceDataCriteria(cql, token); + List sourceDataCriteria = + dataCriteriaService.getSourceDataCriteria(cql, token); // source data criteria for value set assertThat(sourceDataCriteria.size(), is(equalTo(0)));