Skip to content

Commit

Permalink
CNDE-1403 Unit tests fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sveselev committed Oct 30, 2024
1 parent d7e094e commit 27765f4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ private String extractValFromMessage(String topic, String payload) {
}
} else if (topic.endsWith(Entity.OBSERVATION.getName())) {
String domainCd = objectMapper.readTree(payload).get(PAYLOAD).path("obs_domain_cd_st_1").asText();
String ctrlCd = Optional.ofNullable(objectMapper.readTree(payload).get("ctrl_cd_display_form"))
String ctrlCd = Optional.ofNullable(objectMapper.readTree(payload).get(PAYLOAD).get("ctrl_cd_display_form"))
.filter(node -> !node.isNull()).map(JsonNode::asText).orElse(null);

if (MORB_REPORT.equals(ctrlCd)) {
Expand All @@ -336,9 +336,6 @@ private String extractValFromMessage(String topic, String payload) {
}

private boolean assertMatches(String value, String... vals ) {
if ("null".equals(value)) {
value = null;
}
return Arrays.asList(vals).contains(value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ void testPostProcessObservationMorb() {
"'{\"payload\":{\"observation_uid\":123, \"obs_domain_cd_st_1\": \"Result\",\"ctrl_cd_display_form\": \"LabReport\"}}'",
"'{\"payload\":{\"observation_uid\":123, \"obs_domain_cd_st_1\": \"R_Order\",\"ctrl_cd_display_form\": \"LabReportMorb\"}}'",
"'{\"payload\":{\"observation_uid\":123, \"obs_domain_cd_st_1\": \"R_Result\",\"ctrl_cd_display_form\": \"LabReport\"}}'",
"'{\"payload\":{\"observation_uid\":123, \"obs_domain_cd_st_1\": \"I_Order\",\"ctrl_cd_display_form\": null}}'",
"'{\"payload\":{\"observation_uid\":123, \"obs_domain_cd_st_1\": \"I_Result\",\"ctrl_cd_display_form\": null}}'"
})
void testPostProcessObservationLab(String payload) {
Expand Down Expand Up @@ -265,8 +266,7 @@ void testPostProcessObservationLab(String payload) {
"'{\"payload\":{\"observation_uid\":123, \"obs_domain_cd_st_1\": \"Order\",\"ctrl_cd_display_form\": \"NoReport\"}}'",
"'{\"payload\":{\"observation_uid\":123, \"obs_domain_cd_st_1\": \"NoOrderOrResult\",\"ctrl_cd_display_form\": \"LabReport\"}}'",
"'{\"payload\":{\"observation_uid\":123, \"obs_domain_cd_st_1\": null,\"ctrl_cd_display_form\": \"LabReport\"}}'",
"'{\"payload\":{\"observation_uid\":123, \"obs_domain_cd_st_1\": \"C_Result\",\"ctrl_cd_display_form\": \"LabComment\"}}'",
"'{\"payload\":{\"observation_uid\":123, \"obs_domain_cd_st_1\": \"Result\",\"ctrl_cd_display_form\": null}}'"
"'{\"payload\":{\"observation_uid\":123, \"obs_domain_cd_st_1\": \"C_Result\",\"ctrl_cd_display_form\": \"LabComment\"}}'"
})
void testPostProcessObservationNoReport(String payload) {
String topic = "dummy_observation";
Expand Down Expand Up @@ -408,6 +408,7 @@ void testProduceDatamartTopicWithNoPatient() {

@ParameterizedTest
@CsvSource({
"'{\"payload\":{\"public_health_case_uid\":123,\"rdb_table_name_list\":null}}'",
"'{\"payload\":{\"patient_uid\":123}}'",
"'{\"payload\":{invalid}'"
})
Expand Down

0 comments on commit 27765f4

Please sign in to comment.