Skip to content

Commit

Permalink
MAT-5567 remove unused imports
Browse files Browse the repository at this point in the history
  • Loading branch information
adongare committed May 26, 2023
1 parent d41eb2e commit 7a9b32e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -32,78 +27,89 @@

@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> sourceDataCriteria = dataCriteriaService.getSourceDataCriteria(cql, token);
List<SourceDataCriteria> 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
assertThat(sourceDataCriteria.size(), is(equalTo(2)));
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<DateTime>\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<DateTime>\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> sourceDataCriteria = dataCriteriaService.getSourceDataCriteria(cql, token);
List<SourceDataCriteria> sourceDataCriteria =
dataCriteriaService.getSourceDataCriteria(cql, token);

// source data criteria for value set
assertThat(sourceDataCriteria.size(), is(equalTo(0)));
Expand Down

0 comments on commit 7a9b32e

Please sign in to comment.