@@ -165,8 +165,7 @@ void When_MappingParsedConditionWithoutMappedAgent_Expect_EhrMapperException() {
165165
166166 when (codeableConceptCdMapper .mapCodeableConceptToCd (any (CodeableConcept .class )))
167167 .thenReturn (CodeableConceptMapperMockUtil .NULL_FLAVOR_CODE );
168- when (messageContext .getIdMapper ()).thenReturn (idMapper );
169- when (messageContext .getAgentDirectory ()).thenReturn (agentDirectory );
168+ mockIdMapperAndAgentDirectory ();
170169 when (messageContext .getInputBundleHolder ()).thenReturn (inputBundle );
171170 when (idMapper .getOrNew (ResourceType .Condition , conditionId )).thenReturn (CONDITION_ID );
172171 when (idMapper .getOrNew (any (Reference .class ))).thenAnswer (answerWithObjectId (ResourceType .Condition ));
@@ -185,8 +184,7 @@ void When_MappingParsedConditionWithAsserterNotPractitioner_Expect_EhrMapperExce
185184
186185 when (codeableConceptCdMapper .mapCodeableConceptToCd (any (CodeableConcept .class )))
187186 .thenReturn (CodeableConceptMapperMockUtil .NULL_FLAVOR_CODE );
188- when (messageContext .getIdMapper ()).thenReturn (idMapper );
189- when (messageContext .getAgentDirectory ()).thenReturn (agentDirectory );
187+ mockIdMapperAndAgentDirectory ();
190188 when (messageContext .getInputBundleHolder ()).thenReturn (inputBundle );
191189
192190 IdType conditionId = buildIdType (ResourceType .Condition , CONDITION_ID );
@@ -209,8 +207,7 @@ void When_MappingParsedCondition_With_RealProblem_Expect_LinkSetXml(String condi
209207
210208 when (codeableConceptCdMapper .mapCodeableConceptToCd (any (CodeableConcept .class )))
211209 .thenReturn (CodeableConceptMapperMockUtil .NULL_FLAVOR_CODE );
212- when (messageContext .getIdMapper ()).thenReturn (idMapper );
213- when (messageContext .getAgentDirectory ()).thenReturn (agentDirectory );
210+ mockIdMapperAndAgentDirectory ();
214211 when (messageContext .getInputBundleHolder ()).thenReturn (inputBundle );
215212 when (idMapper .getOrNew (ResourceType .Condition , conditionId )).thenReturn (CONDITION_ID );
216213 when (idMapper .getOrNew (any (Reference .class ))).thenAnswer (answerWithObjectId (ResourceType .Condition ));
@@ -231,8 +228,7 @@ void When_MappingParsedCondition_With_ActualProblemContentAndIsObservation_Expec
231228
232229 when (codeableConceptCdMapper .mapCodeableConceptToCd (any (CodeableConcept .class )))
233230 .thenReturn (CodeableConceptMapperMockUtil .NULL_FLAVOR_CODE );
234- when (messageContext .getIdMapper ()).thenReturn (idMapper );
235- when (messageContext .getAgentDirectory ()).thenReturn (agentDirectory );
231+ mockIdMapperAndAgentDirectory ();
236232 when (messageContext .getInputBundleHolder ()).thenReturn (inputBundle );
237233
238234 IdType conditionId = buildIdType (ResourceType .Condition , CONDITION_ID );
@@ -254,8 +250,7 @@ void When_MappingParsedCondition_With_ActualProblemCondition_Expect_LinkSetXml()
254250
255251 when (codeableConceptCdMapper .mapCodeableConceptToCd (any (CodeableConcept .class )))
256252 .thenReturn (CodeableConceptMapperMockUtil .NULL_FLAVOR_CODE );
257- when (messageContext .getIdMapper ()).thenReturn (idMapper );
258- when (messageContext .getAgentDirectory ()).thenReturn (agentDirectory );
253+ mockIdMapperAndAgentDirectory ();
259254 when (messageContext .getInputBundleHolder ()).thenReturn (inputBundle );
260255
261256 IdType conditionId = buildIdType (ResourceType .Condition , CONDITION_ID );
@@ -279,8 +274,7 @@ void When_MappingParsedCondition_With_ActualProblemImmunization_Expect_LinkSetXm
279274 any (CodeableConcept .class )))
280275 .thenReturn (TEST_CONDITION_CODE );
281276
282- when (messageContext .getIdMapper ()).thenReturn (idMapper );
283- when (messageContext .getAgentDirectory ()).thenReturn (agentDirectory );
277+ mockIdMapperAndAgentDirectory ();
284278 when (messageContext .getInputBundleHolder ()).thenReturn (inputBundle );
285279
286280 IdType conditionId = buildIdType (ResourceType .Condition , CONDITION_ID );
@@ -301,8 +295,7 @@ void When_MappingParsedCondition_With_RelatedClinicalContentAllergy_Expect_LinkS
301295
302296 when (codeableConceptCdMapper .mapCodeableConceptToCd (any (CodeableConcept .class )))
303297 .thenReturn (CodeableConceptMapperMockUtil .NULL_FLAVOR_CODE );
304- when (messageContext .getIdMapper ()).thenReturn (idMapper );
305- when (messageContext .getAgentDirectory ()).thenReturn (agentDirectory );
298+ mockIdMapperAndAgentDirectory ();
306299 when (messageContext .getInputBundleHolder ()).thenReturn (inputBundle );
307300
308301 IdType conditionId = buildIdType (ResourceType .Condition , CONDITION_ID );
@@ -325,8 +318,7 @@ void When_MappingParsedCondition_With_ActualProblemMedicationRequest_Expect_Link
325318 when (codeableConceptCdMapper .mapCodeableConceptToCdForTransformedActualProblemHeader (
326319 any (CodeableConcept .class )))
327320 .thenReturn (CodeableConceptMapperMockUtil .ACTUAL_PROBLEM_CODE );
328- when (messageContext .getIdMapper ()).thenReturn (idMapper );
329- when (messageContext .getAgentDirectory ()).thenReturn (agentDirectory );
321+ mockIdMapperAndAgentDirectory ();
330322 when (messageContext .getInputBundleHolder ()).thenReturn (inputBundle );
331323
332324 IdType conditionId = buildIdType (ResourceType .Condition , CONDITION_ID );
@@ -349,8 +341,7 @@ void When_MappingParsedCondition_With_AllergyIntolerance_Expect_LinkSetXml() {
349341 getXmlStringFromFile (OUTPUT_XML_ALLERGY_INTOLERANCE_ACTUAL_PROBLEM );
350342 IdType conditionId = buildIdType (ResourceType .Condition , CONDITION_ID );
351343
352- when (messageContext .getIdMapper ()).thenReturn (idMapper );
353- when (messageContext .getAgentDirectory ()).thenReturn (agentDirectory );
344+ mockIdMapperAndAgentDirectory ();
354345 when (messageContext .getInputBundleHolder ()).thenReturn (inputBundle );
355346 when (idMapper .getOrNew (ResourceType .Condition , conditionId ))
356347 .thenReturn (CONDITION_ID );
@@ -380,8 +371,7 @@ void When_MappingParsedCondition_With_NoRelatedClinicalContent_Expect_LinkSetXml
380371
381372 when (codeableConceptCdMapper .mapCodeableConceptToCd (any (CodeableConcept .class )))
382373 .thenReturn (CodeableConceptMapperMockUtil .NULL_FLAVOR_CODE );
383- when (messageContext .getIdMapper ()).thenReturn (idMapper );
384- when (messageContext .getAgentDirectory ()).thenReturn (agentDirectory );
374+ mockIdMapperAndAgentDirectory ();
385375 when (messageContext .getInputBundleHolder ()).thenReturn (inputBundle );
386376 when (idMapper .getOrNew (ResourceType .Condition , conditionId )).thenReturn (CONDITION_ID );
387377 when (idMapper .getOrNew (any (Reference .class ))).thenAnswer (answerWithObjectId (ResourceType .Condition ));
@@ -424,8 +414,7 @@ void When_MappingCondition_With_SuppressedMedReqAsRelatedClinicalContent_Expect_
424414
425415 when (codeableConceptCdMapper .mapCodeableConceptToCd (any (CodeableConcept .class )))
426416 .thenReturn (CodeableConceptMapperMockUtil .NULL_FLAVOR_CODE );
427- when (messageContext .getIdMapper ()).thenReturn (idMapper );
428- when (messageContext .getAgentDirectory ()).thenReturn (agentDirectory );
417+ mockIdMapperAndAgentDirectory ();
429418 when (messageContext .getInputBundleHolder ()).thenReturn (inputBundle );
430419
431420 IdType conditionId = buildIdType (ResourceType .Condition , CONDITION_ID );
@@ -449,8 +438,7 @@ void When_MappingCondition_With_NopatMetaSecurity_Expect_ConfidentialityCodeInBo
449438 ConfidentialityCodeUtility .appendNopatSecurityToMetaForResource (condition );
450439 when (codeableConceptCdMapper .mapCodeableConceptToCd (any (CodeableConcept .class )))
451440 .thenReturn (CodeableConceptMapperMockUtil .NULL_FLAVOR_CODE );
452- when (messageContext .getIdMapper ()).thenReturn (idMapper );
453- when (messageContext .getAgentDirectory ()).thenReturn (agentDirectory );
441+ mockIdMapperAndAgentDirectory ();
454442 when (messageContext .getInputBundleHolder ()).thenReturn (inputBundle );
455443
456444 IdType conditionId = buildIdType (ResourceType .Condition , CONDITION_ID );
@@ -500,8 +488,7 @@ void When_MappingCondition_With_NoscrubMetaSecurity_Expect_ConfidentialityCodeNo
500488
501489 when (codeableConceptCdMapper .mapCodeableConceptToCd (any (CodeableConcept .class )))
502490 .thenReturn (CodeableConceptMapperMockUtil .NULL_FLAVOR_CODE );
503- when (messageContext .getIdMapper ()).thenReturn (idMapper );
504- when (messageContext .getAgentDirectory ()).thenReturn (agentDirectory );
491+ mockIdMapperAndAgentDirectory ();
505492 when (messageContext .getInputBundleHolder ()).thenReturn (inputBundle );
506493 IdType conditionId = buildIdType (ResourceType .Condition , CONDITION_ID );
507494 when (idMapper .getOrNew (ResourceType .Condition , conditionId )).thenReturn (CONDITION_ID );
@@ -520,6 +507,11 @@ void When_MappingCondition_With_NoscrubMetaSecurity_Expect_ConfidentialityCodeNo
520507 assertThat (conditionSecurityCode ).isEqualTo (NOSCRUB );
521508 }
522509
510+ private void mockIdMapperAndAgentDirectory () {
511+ when (messageContext .getIdMapper ()).thenReturn (idMapper );
512+ when (messageContext .getAgentDirectory ()).thenReturn (agentDirectory );
513+ }
514+
523515 private static Stream <Arguments > testArguments () {
524516 return Stream .of (
525517 Arguments .of (INPUT_JSON_WITH_ACTUAL_PROBLEM_OBSERVATION , OUTPUT_XML_WITH_IS_NESTED , true ),
0 commit comments