Skip to content

Commit abba751

Browse files
Merge branch 'main' into NIAD-1136
2 parents bd7fad7 + 9a08319 commit abba751

File tree

1 file changed

+55
-55
lines changed

1 file changed

+55
-55
lines changed

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

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,20 @@ void setUp() {
7979
final InputBundle inputBundle = new InputBundle(bundle);
8080

8181
when(messageContext.getIdMapper())
82-
.thenReturn(idMapper);
82+
.thenReturn(idMapper);
8383
when(messageContext.getInputBundleHolder())
84-
.thenReturn(inputBundle);
84+
.thenReturn(inputBundle);
8585
when(idMapper.getOrNew(ResourceType.Condition, conditionId))
86-
.thenReturn(CONDITION_ID);
86+
.thenReturn(CONDITION_ID);
8787
when(idMapper.getOrNew(any(Reference.class)))
88-
.thenAnswer(answerWithId());
88+
.thenAnswer(answerWithId());
8989

9090
conditionLinkSetMapper = new ConditionLinkSetMapper(
91-
messageContext,
92-
randomIdGeneratorService,
93-
codeableConceptCdMapper,
94-
participantMapper,
95-
confidentialityService
91+
messageContext,
92+
randomIdGeneratorService,
93+
codeableConceptCdMapper,
94+
participantMapper,
95+
confidentialityService
9696
);
9797
}
9898

@@ -103,26 +103,26 @@ void afterEach() {
103103

104104
private void initializeNullFlavorCodeableConceptMocks() {
105105
when(codeableConceptCdMapper.mapCodeableConceptToCd(any(CodeableConcept.class)))
106-
.thenReturn(NULL_FLAVOR_CODE);
106+
.thenReturn(NULL_FLAVOR_CODE);
107107
}
108108

109109
private void initializeAgentDirectoryMocks() {
110110
when(messageContext.getAgentDirectory())
111-
.thenReturn(agentDirectory);
111+
.thenReturn(agentDirectory);
112112
}
113113

114114
static Stream<Arguments> testArguments() {
115115
return Stream.of(
116-
Arguments.of("condition_all_included.json", "expected_output_linkset_1.xml", true),
117-
Arguments.of("condition_all_included.json", "expected_output_linkset_2.xml", false),
118-
Arguments.of("condition_major_significance.json", "expected_output_linkset_6.xml", false),
119-
Arguments.of("condition_related_clinical_content_list_reference.json", "expected_output_linkset_8.xml", false),
120-
Arguments.of("condition_related_clinical_content_suppressed_linkage_references.json", "expected_output_linkset_9.xml", false),
121-
Arguments.of("condition_2_related_clinical_content.json", "expected_output_linkset_10.xml", false),
122-
Arguments.of("condition_status_active.json", "expected_output_linkset_11.xml", false),
123-
Arguments.of("condition_status_inactive.json", "expected_output_linkset_12.xml", false),
124-
Arguments.of("condition_dates_present.json", "expected_output_linkset_13.xml", false),
125-
Arguments.of("condition_dates_not_present.json", "expected_output_linkset_14.xml", false)
116+
Arguments.of("condition_all_included.json", "expected_output_linkset_1.xml", true),
117+
Arguments.of("condition_all_included.json", "expected_output_linkset_2.xml", false),
118+
Arguments.of("condition_major_significance.json", "expected_output_linkset_6.xml", false),
119+
Arguments.of("condition_related_clinical_content_list_reference.json", "expected_output_linkset_8.xml", false),
120+
Arguments.of("condition_related_clinical_content_suppressed_linkage_references.json", "expected_output_linkset_9.xml", false),
121+
Arguments.of("condition_2_related_clinical_content.json", "expected_output_linkset_10.xml", false),
122+
Arguments.of("condition_status_active.json", "expected_output_linkset_11.xml", false),
123+
Arguments.of("condition_status_inactive.json", "expected_output_linkset_12.xml", false),
124+
Arguments.of("condition_dates_present.json", "expected_output_linkset_13.xml", false),
125+
Arguments.of("condition_dates_not_present.json", "expected_output_linkset_14.xml", false)
126126
);
127127
}
128128

@@ -135,7 +135,7 @@ void When_MappingParsedCondition_With_RealProblem_Expect_LinkSetXml(String condi
135135
initializeAgentDirectoryMocks();
136136
initializeNullFlavorCodeableConceptMocks();
137137
when(agentDirectory.getAgentId(any(Reference.class)))
138-
.thenAnswer(answerWithId());
138+
.thenAnswer(answerWithId());
139139

140140
final String actualXml = conditionLinkSetMapper.mapConditionToLinkSet(condition, isNested);
141141

@@ -144,29 +144,29 @@ void When_MappingParsedCondition_With_RealProblem_Expect_LinkSetXml(String condi
144144

145145
private static Stream<Arguments> testObservationArguments() {
146146
return Stream.of(
147-
Arguments.of("condition_no_problem.json", "expected_output_linkset_3.xml", true),
148-
Arguments.of("condition_actual_problem_condition.json", "expected_output_linkset_5.xml", false),
149-
Arguments.of("condition_no_problem_no_onsetdate.json", "expected_output_linkset_18.xml", true),
150-
Arguments.of("condition_related_clinical_content_allergy.json", "expected_output_linkset_19.xml", false)
147+
Arguments.of("condition_no_problem.json", "expected_output_linkset_3.xml", true),
148+
Arguments.of("condition_actual_problem_condition.json", "expected_output_linkset_5.xml", false),
149+
Arguments.of("condition_no_problem_no_onsetdate.json", "expected_output_linkset_18.xml", true),
150+
Arguments.of("condition_related_clinical_content_allergy.json", "expected_output_linkset_19.xml", false)
151151
);
152152
}
153153

154154
@ParameterizedTest
155155
@MethodSource("testObservationArguments")
156156
void When_MappingParsedCondition_With_ObservationActualProblem_Expect_LinkSetXml(
157-
String conditionJson,
158-
String outputXml,
159-
boolean isNested
157+
String conditionJson,
158+
String outputXml,
159+
boolean isNested
160160
) {
161161
final Condition condition = getConditionResourceFromJson(conditionJson);
162162
final String expectedXml = getXmlStringFromFile(outputXml);
163163

164164
initializeAgentDirectoryMocks();
165165
initializeNullFlavorCodeableConceptMocks();
166166
when(agentDirectory.getAgentId(any(Reference.class)))
167-
.thenAnswer(answerWithId());
167+
.thenAnswer(answerWithId());
168168
when(randomIdGeneratorService.createNewId())
169-
.thenReturn(GENERATED_ID);
169+
.thenReturn(GENERATED_ID);
170170

171171
final String actualXml = conditionLinkSetMapper.mapConditionToLinkSet(condition, isNested);
172172

@@ -181,10 +181,10 @@ void When_MappingParsedConditionWithoutMappedAgent_Expect_EhrMapperException() {
181181
initializeAgentDirectoryMocks();
182182
initializeNullFlavorCodeableConceptMocks();
183183
when(agentDirectory.getAgentId(any(Reference.class)))
184-
.thenThrow(propagatedException);
184+
.thenThrow(propagatedException);
185185

186186
assertThatThrownBy(() -> conditionLinkSetMapper.mapConditionToLinkSet(condition, false))
187-
.isEqualTo(propagatedException);
187+
.isEqualTo(propagatedException);
188188
}
189189

190190
@Test
@@ -195,8 +195,8 @@ void When_MappingParsedConditionWithAsserterNotPractitioner_Expect_EhrMapperExce
195195
initializeNullFlavorCodeableConceptMocks();
196196

197197
assertThatThrownBy(() -> conditionLinkSetMapper.mapConditionToLinkSet(condition, false))
198-
.isExactlyInstanceOf(EhrMapperException.class)
199-
.hasMessage("Condition.asserter must be a Practitioner");
198+
.isExactlyInstanceOf(EhrMapperException.class)
199+
.hasMessage("Condition.asserter must be a Practitioner");
200200
}
201201

202202
@Test
@@ -206,11 +206,11 @@ void When_MappingParsedCondition_With_ActualProblemImmunization_Expect_LinkSetXm
206206

207207
initializeAgentDirectoryMocks();
208208
when(codeableConceptCdMapper.mapCodeableConceptToCdForTransformedActualProblemHeader(any(CodeableConcept.class)))
209-
.thenReturn(TEST_CONDITION_CODE);
209+
.thenReturn(TEST_CONDITION_CODE);
210210
when(agentDirectory.getAgentId(any(Reference.class)))
211-
.thenAnswer(answerWithId());
211+
.thenAnswer(answerWithId());
212212
when(randomIdGeneratorService.createNewId())
213-
.thenReturn(GENERATED_ID);
213+
.thenReturn(GENERATED_ID);
214214

215215
final String actualXml = conditionLinkSetMapper.mapConditionToLinkSet(condition, false);
216216

@@ -224,11 +224,11 @@ void When_MappingParsedCondition_With_ActualProblemMedicationRequest_Expect_Link
224224

225225
initializeAgentDirectoryMocks();
226226
when(codeableConceptCdMapper.mapCodeableConceptToCdForTransformedActualProblemHeader(any(CodeableConcept.class)))
227-
.thenReturn(ACTUAL_PROBLEM_CODE);
227+
.thenReturn(ACTUAL_PROBLEM_CODE);
228228
when(agentDirectory.getAgentId(any(Reference.class)))
229-
.thenAnswer(answerWithId());
229+
.thenAnswer(answerWithId());
230230
when(randomIdGeneratorService.createNewId())
231-
.thenReturn(GENERATED_ID);
231+
.thenReturn(GENERATED_ID);
232232

233233
final String actualXml = conditionLinkSetMapper.mapConditionToLinkSet(condition, false);
234234

@@ -242,9 +242,9 @@ void When_MappingParsedCondition_With_AllergyIntolerance_Expect_LinkSetXml() {
242242

243243
initializeAgentDirectoryMocks();
244244
when(codeableConceptCdMapper.mapCodeableConceptToCdForTransformedActualProblemHeader(any(CodeableConcept.class)))
245-
.thenReturn(TEST_CONDITION_CODE);
245+
.thenReturn(TEST_CONDITION_CODE);
246246
when(agentDirectory.getAgentId(any(Reference.class)))
247-
.thenAnswer(answerWithId());
247+
.thenAnswer(answerWithId());
248248
when(randomIdGeneratorService.createNewId())
249249
.thenReturn(GENERATED_ID);
250250

@@ -258,8 +258,8 @@ void When_MappingParsedConditionCodeIsMissing_Expect_MapperException() {
258258
final Condition condition = getConditionResourceFromJson("condition_missing_code.json");
259259

260260
assertThatThrownBy(() -> conditionLinkSetMapper.mapConditionToLinkSet(condition, false))
261-
.isExactlyInstanceOf(EhrMapperException.class)
262-
.hasMessage("Condition code not present");
261+
.isExactlyInstanceOf(EhrMapperException.class)
262+
.hasMessage("Condition code not present");
263263
}
264264

265265
@Test
@@ -270,7 +270,7 @@ void When_MappingParsedConditionWithNoRelatedClinicalContent_Expect_LinkSetXml()
270270
initializeAgentDirectoryMocks();
271271
initializeNullFlavorCodeableConceptMocks();
272272
when(agentDirectory.getAgentId(any(Reference.class)))
273-
.thenAnswer(answerWithId());
273+
.thenAnswer(answerWithId());
274274

275275
final String actualXml = conditionLinkSetMapper.mapConditionToLinkSet(condition, false);
276276

@@ -285,7 +285,7 @@ void When_MappingConditionWithSuppressedMedicationRequestAsRelatedClinicalConten
285285
initializeAgentDirectoryMocks();
286286
initializeNullFlavorCodeableConceptMocks();
287287
when(agentDirectory.getAgentId(any(Reference.class)))
288-
.thenAnswer(answerWithId());
288+
.thenAnswer(answerWithId());
289289

290290
final String actualXml = conditionLinkSetMapper.mapConditionToLinkSet(condition, false);
291291

@@ -308,21 +308,21 @@ void When_MappingCondition_With_NopatMetaSecurity_Expect_ConfidentialityCodeInBo
308308
final Condition condition = getConditionResourceFromJson("condition_actual_problem_condition.json");
309309
final String linkSetXpath = "/Root/component[1]/LinkSet/" + ConfidentialityCodeUtility.getNopatConfidentialityCodeXpathSegment();
310310
final String observationStatementXpath = "/Root/component[2]/ObservationStatement/" + ConfidentialityCodeUtility
311-
.getNopatConfidentialityCodeXpathSegment();
311+
.getNopatConfidentialityCodeXpathSegment();
312312
ConfidentialityCodeUtility.appendNopatSecurityToMetaForResource(condition);
313313

314314
initializeAgentDirectoryMocks();
315315
initializeNullFlavorCodeableConceptMocks();
316316
when(confidentialityService.generateConfidentialityCode(conditionArgumentCaptor.capture()))
317-
.thenReturn(Optional.of(NOPAT_HL7_CONFIDENTIALITY_CODE));
317+
.thenReturn(Optional.of(NOPAT_HL7_CONFIDENTIALITY_CODE));
318318

319319
final String actualXml = wrapXmlInRootElement(conditionLinkSetMapper.mapConditionToLinkSet(condition, false));
320320
final String conditionSecurityCode = ConfidentialityCodeUtility.getSecurityCodeFromResource(conditionArgumentCaptor.getValue());
321321

322322
assertAll(
323-
() -> assertThatXml(actualXml).containsXPath(observationStatementXpath),
324-
() -> assertThatXml(actualXml).containsXPath(linkSetXpath),
325-
() -> assertThat(conditionSecurityCode).isEqualTo(NOPAT)
323+
() -> assertThatXml(actualXml).containsXPath(observationStatementXpath),
324+
() -> assertThatXml(actualXml).containsXPath(linkSetXpath),
325+
() -> assertThat(conditionSecurityCode).isEqualTo(NOPAT)
326326
);
327327
}
328328

@@ -334,14 +334,14 @@ void When_MappingCondition_With_NoScrubMetaSecurity_Expect_ConfidentialityCodeNo
334334
initializeAgentDirectoryMocks();
335335
initializeNullFlavorCodeableConceptMocks();
336336
when(confidentialityService.generateConfidentialityCode(conditionArgumentCaptor.capture()))
337-
.thenReturn(Optional.empty());
337+
.thenReturn(Optional.empty());
338338

339339
final String actualXml = conditionLinkSetMapper.mapConditionToLinkSet(condition, false);
340340
final String conditionSecurityCode = ConfidentialityCodeUtility.getSecurityCodeFromResource(conditionArgumentCaptor.getValue());
341341

342342
assertAll(
343-
() -> assertThat(actualXml).doesNotContainIgnoringCase(NOPAT_HL7_CONFIDENTIALITY_CODE),
344-
() -> assertThat(conditionSecurityCode).isEqualTo(NOSCRUB)
343+
() -> assertThat(actualXml).doesNotContainIgnoringCase(NOPAT_HL7_CONFIDENTIALITY_CODE),
344+
() -> assertThat(conditionSecurityCode).isEqualTo(NOSCRUB)
345345
);
346346
}
347347

0 commit comments

Comments
 (0)