Skip to content

Commit

Permalink
MAT-6785, MAT-6631: fix description bug for combined descriptions, fi…
Browse files Browse the repository at this point in the history
…xing broken unit tests
  • Loading branch information
nmorasb committed Mar 5, 2024
1 parent e252364 commit c107efb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/main/java/gov/cms/madie/util/MappingUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static String getPopulationDescription(Measure measure, PopulationType po
.name()
.equalsIgnoreCase(population.getName().name())
&& StringUtils.isNotBlank(population.getDescription()))
.map(p -> p.getDefinition().replaceAll("[\\t\\n\\r]+", " "))
.map(p -> p.getDescription().replaceAll("[\\t\\n\\r]+", " "))
.collect(Collectors.joining(" "));
} else if (CollectionUtils.isNotEmpty(group.getMeasureObservations())
&& isPopulationObservation(populationType)) {
Expand All @@ -81,7 +81,7 @@ && isPopulationObservation(populationType)) {
observation ->
StringUtils.isNotBlank(observation.getDefinition())
&& StringUtils.isNotBlank(observation.getDescription()))
.map(mo -> mo.getDefinition().replaceAll("[\\t\\n\\r]+", " "))
.map(mo -> mo.getDescription().replaceAll("[\\t\\n\\r]+", " "))
.collect(Collectors.joining(" "));
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import gov.cms.madie.models.measure.Measure;
import gov.cms.madie.packaging.utils.ResourceFileUtil;
import gov.cms.madie.services.SimpleXmlService;
import gov.cms.madie.services.TranslationServiceClient;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -35,6 +36,7 @@ class PackageControllerMvcTest implements ResourceFileUtil {
@MockBean private PackagingService packagingService;
@MockBean private SimpleXmlService simpleXmlService;
@MockBean private HqmfService hqmfService;
@MockBean private TranslationServiceClient translationServiceClient;
@Autowired private MockMvc mockMvc;

private static final String TEST_USER_ID = "john_doe";
Expand Down Expand Up @@ -83,6 +85,8 @@ void testGetMeasureSimpleXml() throws Exception {
String measureJson = getStringFromTestResource("/measures/qdm-test-measure.json");
Mockito.when(simpleXmlService.measureToSimpleXml(any(QdmMeasure.class), any(CqlLookups.class)))
.thenReturn("<measure></measure>");
Mockito.when(translationServiceClient.getCqlLookups(any(QdmMeasure.class), anyString()))
.thenReturn(CqlLookups.builder().build());
mockMvc
.perform(
MockMvcRequestBuilders.put("/qdm/measures/simple-xml")
Expand All @@ -95,6 +99,8 @@ void testGetMeasureSimpleXml() throws Exception {
.andReturn();
verify(simpleXmlService, times(1))
.measureToSimpleXml(any(QdmMeasure.class), any(CqlLookups.class));
verify(translationServiceClient, times(1))
.getCqlLookups(any(QdmMeasure.class), anyString());
}

@Test
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/gov/cms/madie/util/MappingUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ void getPopulationDescriptionGroupTwoDescription() {
.build();
String output =
MappingUtil.getPopulationDescription(measure, PopulationType.INITIAL_POPULATION);
assertThat(output, equalTo("IP Description\nIPG2 Description"));
assertThat(output, equalTo("IP Description IPG2 Description"));
}

@Test
Expand Down Expand Up @@ -356,6 +356,6 @@ void getPopulationDescriptionGroupMultipleDescriptions() {
assertThat(
output,
equalTo(
"Denominator Obs Description\nNumerator Obs Description\nG2 Denominator Obs Description\nG2 Numerator Obs Description"));
"Denominator Obs Description Numerator Obs Description G2 Denominator Obs Description G2 Numerator Obs Description"));
}
}

0 comments on commit c107efb

Please sign in to comment.