Skip to content

Commit 5b82a93

Browse files
Refactor unit tests for skeleton ERH extract tests and inline XML (#647)
Removed unneeded xml files following refactor
1 parent 5c67f3e commit 5b82a93

4 files changed

Lines changed: 54 additions & 674 deletions

File tree

service/src/test/java/uk/nhs/adaptors/gp2gp/gpc/StructuredRecordMappingServiceTest.java

Lines changed: 54 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import uk.nhs.adaptors.gp2gp.ehr.mapper.parameters.EhrExtractTemplateParameters;
3838
import uk.nhs.adaptors.gp2gp.mhs.model.Identifier;
3939
import uk.nhs.adaptors.gp2gp.mhs.model.OutboundMessage;
40-
import uk.nhs.adaptors.gp2gp.utils.ResourceTestFileUtils;
4140
import wiremock.org.custommonkey.xmlunit.DetailedDiff;
4241
import wiremock.org.custommonkey.xmlunit.XMLUnit;
4342

@@ -218,12 +217,34 @@ private Bundle getBundleWith(DocumentReference... documentReferences) {
218217
@SneakyThrows
219218
public void When_BuildingSkeletonForEhrExtract_Expect_XmlWithSingleComponent() {
220219
var documentId = "DocumentId";
221-
var skeletonComponent = "<component />";
222-
223-
var inputRealEhrExtract = ResourceTestFileUtils
224-
.getFileContent("/ehr/mapper/ehrExtract/ehrExtract.xml");
225-
var expectedSkeletonEhrExtract = ResourceTestFileUtils
226-
.getFileContent("/ehr/mapper/ehrExtract/expectedSkeletonEhrExtract.xml");
220+
var skeletonComponent = "<component>This is the newly added skeleton component</component>";
221+
222+
var inputRealEhrExtract = """
223+
<EhrExtract classCode="EXTRACT" moodCode="EVN">
224+
<id root="test-id-1" />
225+
<statusCode code="COMPLETE" />
226+
<component typeCode="COMP">
227+
<ehrFolder classCode="FOLDER" moodCode="EVN">
228+
<id root="test-id-2" />
229+
<statusCode code="COMPLETE" />
230+
<component>This is a component to be removed</component>
231+
<component>This is also a component to be removed</component>
232+
</ehrFolder>
233+
</component>
234+
</EhrExtract>""";
235+
236+
var expectedSkeletonEhrExtract = """
237+
<EhrExtract classCode="EXTRACT" moodCode="EVN">
238+
<id root="test-id-1"/>
239+
<statusCode code="COMPLETE"/>
240+
<component typeCode="COMP">
241+
<ehrFolder classCode="FOLDER" moodCode="EVN">
242+
<id root="test-id-2"/>
243+
<statusCode code="COMPLETE"/>
244+
<component>This is the newly added skeleton component</component>
245+
</ehrFolder>
246+
</component>
247+
</EhrExtract>""";
227248

228249
when(ehrExtractMapper.buildEhrCompositionForSkeletonEhrExtract(any())).thenReturn(skeletonComponent);
229250

@@ -236,12 +257,32 @@ public void When_BuildingSkeletonForEhrExtract_Expect_XmlWithSingleComponent() {
236257
@Test
237258
public void When_BuildingSkeletonForEhrExtractWithoutChildComponentNodesToReplace_Expect_XMLWithSingleComponent() throws Exception {
238259
var documentId = "DocumentId";
239-
var skeletonComponent = "<component />";
240-
241-
var inputRealEhrExtract = ResourceTestFileUtils
242-
.getFileContent("/ehr/mapper/ehrExtract/ehrExtractWithNoComponentsToReplaceForSkeleton.xml");
243-
var expectedSkeletonEhrExtract = ResourceTestFileUtils
244-
.getFileContent("/ehr/mapper/ehrExtract/expectedSkeletonEhrExtract.xml");
260+
var skeletonComponent = "<component>This is the newly added skeleton component</component>";
261+
262+
var inputRealEhrExtract = """
263+
<EhrExtract classCode="EXTRACT" moodCode="EVN">
264+
<id root="test-id-1"/>
265+
<statusCode code="COMPLETE"/>
266+
<component typeCode="COMP">
267+
<ehrFolder classCode="FOLDER" moodCode="EVN">
268+
<id root="test-id-2"/>
269+
<statusCode code="COMPLETE"/>
270+
</ehrFolder>
271+
</component>
272+
</EhrExtract>""";
273+
274+
var expectedSkeletonEhrExtract = """
275+
<EhrExtract classCode="EXTRACT" moodCode="EVN">
276+
<id root="test-id-1"/>
277+
<statusCode code="COMPLETE"/>
278+
<component typeCode="COMP">
279+
<ehrFolder classCode="FOLDER" moodCode="EVN">
280+
<id root="test-id-2"/>
281+
<statusCode code="COMPLETE"/>
282+
<component>This is the newly added skeleton component</component>
283+
</ehrFolder>
284+
</component>
285+
</EhrExtract>""";
245286

246287
when(ehrExtractMapper.buildEhrCompositionForSkeletonEhrExtract(any())).thenReturn(skeletonComponent);
247288

service/src/test/resources/ehr/mapper/ehrExtract/ehrExtract.xml

Lines changed: 0 additions & 264 deletions
This file was deleted.

0 commit comments

Comments
 (0)