From 2a157a725bc90703ea8d46787a6a5325c7a245e7 Mon Sep 17 00:00:00 2001 From: Luis Pabon Date: Tue, 17 Dec 2024 16:19:32 -0500 Subject: [PATCH] Completed HL7Parser coverage --- .../rse2e/hl7/HL7Parser.java | 5 +-- .../rse2e/hl7/HL7ParserTest.groovy | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/rs-e2e/src/main/java/gov/hhs/cdc/trustedintermediary/rse2e/hl7/HL7Parser.java b/rs-e2e/src/main/java/gov/hhs/cdc/trustedintermediary/rse2e/hl7/HL7Parser.java index e37be8098..e3d2efbbf 100644 --- a/rs-e2e/src/main/java/gov/hhs/cdc/trustedintermediary/rse2e/hl7/HL7Parser.java +++ b/rs-e2e/src/main/java/gov/hhs/cdc/trustedintermediary/rse2e/hl7/HL7Parser.java @@ -81,10 +81,7 @@ public static Map getEncodingCharacterMap(String encodingChar return Map.of( FIELD_DELIMITER_NAME, HL7Parser.DEFAULT_FIELD_DELIMITER, - COMPONENT_DELIMITER_NAME, - encodingCharacters.length > 0 - ? encodingCharacters[0] - : HL7Parser.DEFAULT_COMPONENT_DELIMITER, + COMPONENT_DELIMITER_NAME, HL7Parser.DEFAULT_COMPONENT_DELIMITER, REPETITION_DELIMITER_NAME, encodingCharacters.length > 1 ? encodingCharacters[1] diff --git a/rs-e2e/src/test/groovy/gov/hhs/cdc/trustedintermediary/rse2e/hl7/HL7ParserTest.groovy b/rs-e2e/src/test/groovy/gov/hhs/cdc/trustedintermediary/rse2e/hl7/HL7ParserTest.groovy index 55f8bd0a2..e88ece145 100644 --- a/rs-e2e/src/test/groovy/gov/hhs/cdc/trustedintermediary/rse2e/hl7/HL7ParserTest.groovy +++ b/rs-e2e/src/test/groovy/gov/hhs/cdc/trustedintermediary/rse2e/hl7/HL7ParserTest.groovy @@ -71,4 +71,36 @@ OBX|1|ST|57723-9^Unique bar code number of Current sample^LN||123456||||||F|||20 then: out == null } + + def "getEncodingCharacterMap uses default definitions when encoding characters are not available"() { + when: + def out = HL7Parser.getEncodingCharacterMap("tes") + + then: + out.size() > 0 + } + + def "getEncodingCharacterMap uses default definitions if the encoding characters are blank"() { + when: + def out = HL7Parser.getEncodingCharacterMap(" ") + + then: + out.size() > 0 + } + + def "getEncodingCharacterMap uses default definitions if the encoding characters are whitespace"() { + when: + def out = HL7Parser.getEncodingCharacterMap("") + + then: + out.size() > 0 + } + + def "getEncodingCharacterMap uses default definitions if the encoding characters are null"() { + when: + def out = HL7Parser.getEncodingCharacterMap(null) + + then: + out.size() > 0 + } }