Skip to content

Commit e444da4

Browse files
authored
Niad 1137/codeable concept cd mapper (#1367)
* test no longer ignores whitespace * addressed whitespace disparity between expected and actual output xml in tests
1 parent 379f37c commit e444da4

File tree

5 files changed

+39
-40
lines changed

5 files changed

+39
-40
lines changed

service/src/main/resources/templates/codeable_concept_cd_template.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<code{{#nullFlavor}} nullFlavor="UNK"{{/nullFlavor}}{{^nullFlavor}} code="{{mainCode}}" codeSystem="{{mainCodeSystem}}" displayName="{{mainDisplayName}}"{{/nullFlavor}}>
22
{{#mainOriginalText}}
3-
<originalText>{{mainOriginalText}}</originalText>
3+
<originalText>{{mainOriginalText}}</originalText>
44
{{/mainOriginalText}}
55
{{#translations}}
66
<translation code="{{code}}" codeSystem="{{system}}" displayName="{{display}}" />

service/src/test/java/uk/nhs/adaptors/gp2gp/ehr/mapper/CodeableConceptCdMapperTest.java

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void When_MappingStubbedCodeableConcept_Expect_HL7CdObjectXml(String inputJson,
8181
var outputMessage = codeableConceptCdMapper.mapCodeableConceptToCd(codeableConcept);
8282
assertThat(outputMessage)
8383
.describedAs(TestArgumentsLoaderUtil.FAIL_MESSAGE, inputJson, outputXml)
84-
.isEqualToIgnoringWhitespace(expectedOutput);
84+
.isEqualTo(expectedOutput);
8585
}
8686

8787
@Test
@@ -118,7 +118,7 @@ void When_MappingCodeableConceptWithNonSnomedCodeSystems_Expect_ManifestedXmlCon
118118

119119
var outputMessageXml = codeableConceptCdMapper.mapCodeableConceptToCd(codeableConcept);
120120

121-
assertThat(outputMessageXml).isEqualToIgnoringWhitespace(expectedOutputXml);
121+
assertThat(outputMessageXml).isEqualTo(expectedOutputXml);
122122
}
123123

124124
@Test
@@ -148,7 +148,7 @@ void When_MappingCodeableConceptWithUnknownNonSnomedCodeSystem_Expect_Manifested
148148

149149
var outputMessageXml = codeableConceptCdMapper.mapCodeableConceptToCd(codeableConcept);
150150

151-
assertThat(outputMessageXml).isEqualToIgnoringWhitespace(expectedOutputXml);
151+
assertThat(outputMessageXml).isEqualTo(expectedOutputXml);
152152
}
153153

154154
@Test
@@ -181,16 +181,15 @@ void When_MapToNullFlavorCodeableConceptForAllergyWithoutSnomedCode_Expect_Origi
181181
}""";
182182
var expectedOutputXML = """
183183
<code nullFlavor="UNK">
184-
</code>
185-
""";
184+
</code>""";
186185
var codeableConcept = fhirParseService.parseResource(inputJson, AllergyIntolerance.class).getCode();
187186

188187
var outputXml = codeableConceptCdMapper.mapToNullFlavorCodeableConceptForAllergy(
189188
codeableConcept,
190189
AllergyIntolerance.AllergyIntoleranceClinicalStatus.ACTIVE
191190
);
192191

193-
assertThat(outputXml).isEqualToIgnoringWhitespace(expectedOutputXML);
192+
assertThat(outputXml).isEqualTo(expectedOutputXML);
194193
}
195194

196195
@ParameterizedTest
@@ -203,7 +202,7 @@ void When_MappingStubbedCodeableConceptForActualProblemHeader_Expect_HL7CdObject
203202
var outputMessage = codeableConceptCdMapper.mapCodeableConceptToCdForTransformedActualProblemHeader(codeableConcept);
204203
assertThat(outputMessage)
205204
.describedAs(TestArgumentsLoaderUtil.FAIL_MESSAGE, inputJson, outputXml)
206-
.isEqualToIgnoringWhitespace(expectedOutput);
205+
.isEqualTo(expectedOutput);
207206
}
208207

209208
@ParameterizedTest
@@ -218,7 +217,7 @@ void When_MappingStubbedCodeableConceptAsResolvedAllergy_Expect_HL7CdObjectXml(S
218217

219218
assertThat(outputMessage)
220219
.describedAs(TestArgumentsLoaderUtil.FAIL_MESSAGE, inputJson, outputXml)
221-
.isEqualToIgnoringWhitespace(expectedOutput);
220+
.isEqualTo(expectedOutput);
222221
}
223222

224223
@ParameterizedTest
@@ -233,7 +232,7 @@ void When_MappingStubbedCodeableConceptAsActiveAllergy_Expect_HL7CdObjectXml(Str
233232

234233
assertThat(outputMessage)
235234
.describedAs(TestArgumentsLoaderUtil.FAIL_MESSAGE, inputJson, outputXml)
236-
.isEqualToIgnoringWhitespace(expectedOutput);
235+
.isEqualTo(expectedOutput);
237236
}
238237

239238
@Nested
@@ -251,7 +250,7 @@ void When_WithoutCoding_Expect_NullFlavorCdXmlWithoutOriginalText() {
251250

252251
var outputMessage = codeableConceptCdMapper.mapCodeableConceptToCdForBloodPressure(codeableConcept);
253252

254-
assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutput);
253+
assertThat(outputMessage).isEqualTo(expectedOutput);
255254
}
256255

257256
@Test
@@ -277,7 +276,7 @@ void When_WithSnomedCodingWithDisplay_Expect_SnomedCdXmlWithOriginalText() {
277276

278277
var outputMessage = codeableConceptCdMapper.mapCodeableConceptToCdForBloodPressure(codeableConcept);
279278

280-
assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutput);
279+
assertThat(outputMessage).isEqualTo(expectedOutput);
281280
}
282281

283282
@Test
@@ -312,7 +311,7 @@ void When_WithSnomedCodingWithoutDisplayWithDescriptionExtensionWithoutDisplay_E
312311

313312
var outputMessage = codeableConceptCdMapper.mapCodeableConceptToCdForBloodPressure(codeableConcept);
314313

315-
assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutput);
314+
assertThat(outputMessage).isEqualTo(expectedOutput);
316315
}
317316

318317
@Test
@@ -348,7 +347,7 @@ <originalText>Prothrombin time (observed)</originalText>
348347

349348
var outputMessage = codeableConceptCdMapper.mapCodeableConceptToCdForBloodPressure(codeableConcept);
350349

351-
assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutput);
350+
assertThat(outputMessage).isEqualTo(expectedOutput);
352351
}
353352

354353
@Test
@@ -386,7 +385,7 @@ void When_WithSnomedCodingAndLegacyCodings_Expect_SnomedCdXmlWithTranslations()
386385

387386
var outputMessage = codeableConceptCdMapper.mapCodeableConceptToCdForBloodPressure(codeableConcept);
388387

389-
assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutput);
388+
assertThat(outputMessage).isEqualTo(expectedOutput);
390389
}
391390

392391
@Test
@@ -413,7 +412,7 @@ <originalText>Prothrombin time (observed)</originalText>
413412

414413
var outputMessage = codeableConceptCdMapper.mapCodeableConceptToCdForBloodPressure(codeableConcept);
415414

416-
assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutput);
415+
assertThat(outputMessage).isEqualTo(expectedOutput);
417416
}
418417

419418
@Test
@@ -440,7 +439,7 @@ void When_WithNonSnomedCodingNoTextWithDisplay_Expect_NullFlavorCdXmlWithOrigina
440439

441440
var outputMessage = codeableConceptCdMapper.mapCodeableConceptToCdForBloodPressure(codeableConcept);
442441

443-
assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutput);
442+
assertThat(outputMessage).isEqualTo(expectedOutput);
444443
}
445444

446445
@Test
@@ -477,7 +476,7 @@ void When_WithNonSnomedCodingWithDescriptionExtensionWithoutDisplay_Expect_Snome
477476

478477
var outputMessage = codeableConceptCdMapper.mapCodeableConceptToCdForBloodPressure(codeableConcept);
479478

480-
assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutput);
479+
assertThat(outputMessage).isEqualTo(expectedOutput);
481480
}
482481

483482
@Test
@@ -514,7 +513,7 @@ <originalText>Prothrombin time (observed)</originalText>
514513

515514
var outputMessage = codeableConceptCdMapper.mapCodeableConceptToCdForBloodPressure(codeableConcept);
516515

517-
assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutput);
516+
assertThat(outputMessage).isEqualTo(expectedOutput);
518517
}
519518

520519
@Test
@@ -545,7 +544,7 @@ void When_WithoutSnomedCodingAndWithLegacyCodings_Expect_NullFlavorSnomedCdXmlWi
545544

546545
var outputMessage = codeableConceptCdMapper.mapCodeableConceptToCdForBloodPressure(codeableConcept);
547546

548-
assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutput);
547+
assertThat(outputMessage).isEqualTo(expectedOutput);
549548
}
550549
}
551550

@@ -585,7 +584,7 @@ <originalText>Prothrombin time (observed)</originalText>
585584

586585
var outputMessage = codeableConceptCdMapper.mapToNullFlavorCodeableConcept(codeableConcept);
587586

588-
assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutput);
587+
assertThat(outputMessage).isEqualTo(expectedOutput);
589588
}
590589

591590
@Test
@@ -621,7 +620,7 @@ void When_WithSnomedCodingNoTextNoDisplayWithNonDescriptionExtension_Expect_Snom
621620

622621
var outputMessage = codeableConceptCdMapper.mapToNullFlavorCodeableConcept(codeableConcept);
623622

624-
assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutput);
623+
assertThat(outputMessage).isEqualTo(expectedOutput);
625624
}
626625

627626
@Test
@@ -649,7 +648,7 @@ <originalText>Prothrombin time (observed)</originalText>
649648

650649
var outputMessage = codeableConceptCdMapper.mapToNullFlavorCodeableConcept(codeableConcept);
651650

652-
assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutput);
651+
assertThat(outputMessage).isEqualTo(expectedOutput);
653652
}
654653

655654
@Test
@@ -687,7 +686,7 @@ void When_WithNonSnomedCodingWithNoTextWithNonDescriptionExtension_Expect_Snomed
687686

688687
var outputMessage = codeableConceptCdMapper.mapToNullFlavorCodeableConcept(codeableConcept);
689688

690-
assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutput);
689+
assertThat(outputMessage).isEqualTo(expectedOutput);
691690
}
692691

693692
@Test
@@ -723,7 +722,7 @@ void When_WithNonSnomedCodingWithNoDisplayNoTextWithDescriptionExtNoDisplayExt_E
723722

724723
var outputMessage = codeableConceptCdMapper.mapToNullFlavorCodeableConcept(codeableConcept);
725724

726-
assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutput);
725+
assertThat(outputMessage).isEqualTo(expectedOutput);
727726
}
728727

729728
@Test
@@ -761,7 +760,7 @@ void When_WithNonSnomedCodingWithDisplayNoTextWithDescriptionExtNoDisplayExt_Exp
761760

762761
var outputMessage = codeableConceptCdMapper.mapToNullFlavorCodeableConcept(codeableConcept);
763762

764-
assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutput);
763+
assertThat(outputMessage).isEqualTo(expectedOutput);
765764
}
766765

767766
@Test
@@ -799,7 +798,7 @@ void When_WithNonSnomedCodingNoTextWithDescriptionExtWithDisplayExt_Expect_Snome
799798

800799
var outputMessage = codeableConceptCdMapper.mapToNullFlavorCodeableConcept(codeableConcept);
801800

802-
assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutput);
801+
assertThat(outputMessage).isEqualTo(expectedOutput);
803802
}
804803

805804
@Test
@@ -826,7 +825,7 @@ void When_WithNonSnomedCodingNoTextNoDescriptionExtension_Expect_SnomedCdXmlWith
826825

827826
var outputMessage = codeableConceptCdMapper.mapToNullFlavorCodeableConcept(codeableConcept);
828827

829-
assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutput);
828+
assertThat(outputMessage).isEqualTo(expectedOutput);
830829
}
831830

832831
@Test
@@ -851,7 +850,7 @@ void When_WithNonSnomedCodingNoDisplayNoTextNoDescriptionExtension_Expect_Snomed
851850

852851
var outputMessage = codeableConceptCdMapper.mapToNullFlavorCodeableConcept(codeableConcept);
853852

854-
assertThat(outputMessage).isEqualToIgnoringWhitespace(expectedOutput);
853+
assertThat(outputMessage).isEqualTo(expectedOutput);
855854
}
856855
}
857856

@@ -866,7 +865,7 @@ void When_MappingCdForTopic_With_RelatedProblem_Expect_HL7CdObjectXml(String inp
866865

867866
assertThat(outputString)
868867
.describedAs(TestArgumentsLoaderUtil.FAIL_MESSAGE, inputJson, outputXml)
869-
.isEqualToIgnoringWhitespace(expectedOutput);
868+
.isEqualTo(expectedOutput);
870869
}
871870

872871
@ParameterizedTest
@@ -880,7 +879,7 @@ void When_MappingCdForMedication_Expect_HL7CdObjectXml(String inputJson, String
880879

881880
assertThat(outputString)
882881
.describedAs(TestArgumentsLoaderUtil.FAIL_MESSAGE, inputJson, outputXml)
883-
.isEqualToIgnoringWhitespace(expectedOutput);
882+
.isEqualTo(expectedOutput);
884883
}
885884

886885
@Test
@@ -891,7 +890,7 @@ void When_MapToCdForTopic_With_RelatedProblemAndTitle_Expect_ProblemCodeAndTitle
891890
var expectedOutput = ResourceTestFileUtils.getFileContent(CD_FOR_TOPIC_RELATED_PROBLEM_AND_TITLE);
892891
var outputString = codeableConceptCdMapper.mapToCdForTopic(codeableConcept, TEST_TITLE);
893892

894-
assertThat(outputString).isEqualToIgnoringWhitespace(expectedOutput);
893+
assertThat(outputString).isEqualTo(expectedOutput);
895894
}
896895

897896
@Test
@@ -901,7 +900,7 @@ void When_MapToCdForTopic_With_TitleOnly_Expect_UnspecifiedProblemAndTitle() {
901900
var outputString = codeableConceptCdMapper.mapToCdForTopic(TEST_TITLE);
902901

903902
assertThat(outputString)
904-
.isEqualToIgnoringWhitespace(expectedOutput);
903+
.isEqualTo(expectedOutput);
905904
}
906905

907906
@Test
@@ -910,7 +909,7 @@ void When_MapToCdForTopic_Without_RelatedProblemOrTile_Expect_UnspecifiedProblem
910909
var expectedOutput = ResourceTestFileUtils.getFileContent(CD_FOR_TOPIC_UNSPECIFIED);
911910
var outputString = codeableConceptCdMapper.getCdForTopic();
912911

913-
assertThat(outputString).isEqualToIgnoringWhitespace(expectedOutput);
912+
assertThat(outputString).isEqualTo(expectedOutput);
914913
}
915914

916915
@Test
@@ -919,7 +918,7 @@ void When_MapToCdForCategory_With_Title_Expect_OtherCategoryAndOriginalText() {
919918
var expectedOutput = ResourceTestFileUtils.getFileContent(CD_FOR_CATEGORY_TITLE);
920919
var outputString = codeableConceptCdMapper.mapToCdForCategory(TEST_TITLE);
921920

922-
assertThat(outputString).isEqualToIgnoringWhitespace(expectedOutput);
921+
assertThat(outputString).isEqualTo(expectedOutput);
923922
}
924923

925924
@Test
@@ -928,7 +927,7 @@ void When_GetCdForCategory_Expect_OtherCategory() {
928927
var expectedOutput = ResourceTestFileUtils.getFileContent(CD_FOR_CATEGORY_NO_TITLE);
929928
var outputString = codeableConceptCdMapper.getCdForCategory();
930929

931-
assertThat(outputString).isEqualToIgnoringWhitespace(expectedOutput);
930+
assertThat(outputString).isEqualTo(expectedOutput);
932931
}
933932

934933
@Test
@@ -939,6 +938,6 @@ void When_MapToCdForMedication_With_RelatedProblemAndTitle_Expect_ConceptIdAndTi
939938
var expectedOutput = ResourceTestFileUtils.getFileContent(CD_FOR_TOPIC_RELATED_PROBLEM_AND_TITLE);
940939
var outputString = codeableConceptCdMapper.mapToCdForTopic(codeableConcept, TEST_TITLE);
941940

942-
assertThat(outputString).isEqualToIgnoringWhitespace(expectedOutput);
941+
assertThat(outputString).isEqualTo(expectedOutput);
943942
}
944943
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<code code="55607006" codeSystem="2.16.840.1.113883.2.1.3.2.4.15" displayName="Problem">
2-
<originalText>Happy puppet syndrome</originalText>
2+
<originalText>Happy puppet syndrome</originalText>
33
</code>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<code code="55607006" codeSystem="2.16.840.1.113883.2.1.3.2.4.15" displayName="Problem">
2-
<originalText>Happy puppet syndrome</originalText>
2+
<originalText>Happy puppet syndrome</originalText>
33
</code>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<code nullFlavor="UNK">
2-
<originalText>Happy puppet syndrome</originalText>
2+
<originalText>Happy puppet syndrome</originalText>
33
</code>

0 commit comments

Comments
 (0)