Skip to content

Commit 4650cdc

Browse files
WIP file
1 parent b1ec7c7 commit 4650cdc

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

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

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,30 @@ void When_MappingParsedCondition_With_RelatedClinicalContentAllergy_Expect_LinkS
305305
assertThat(actualXml).isEqualTo(expectedXml);
306306
}
307307

308-
// It works but the indentation is giving me pain in the test comparison
308+
@Test
309+
void When_MappingParsedCondition_With_ActualProblemMedicationRequest_Expect_LinkSetXml() {
310+
final Condition condition = getConditionResourceFromJson(INPUT_JSON_WITH_ACTUAL_PROBLEM_MEDICATION_REQUEST);
311+
final String expectedXml = getXmlStringFromFile(OUTPUT_XML_MEDICATION_REQUEST_ACTUAL_PROBLEM);
312+
313+
when(codeableConceptCdMapper.mapCodeableConceptToCdForTransformedActualProblemHeader(
314+
any(CodeableConcept.class)))
315+
.thenReturn(CodeableConceptMapperMockUtil.ACTUAL_PROBLEM_CODE);
316+
when(messageContext.getIdMapper()).thenReturn(idMapper);
317+
when(messageContext.getAgentDirectory()).thenReturn(agentDirectory);
318+
when(messageContext.getInputBundleHolder()).thenReturn(inputBundle);
319+
320+
IdType conditionId = buildIdType(ResourceType.Condition, CONDITION_ID);
321+
when(idMapper.getOrNew(ResourceType.Condition, conditionId)).thenReturn(CONDITION_ID);
322+
when(idMapper.getOrNew(any(Reference.class))).thenAnswer(answerWithObjectId(ResourceType.Condition));
323+
when(agentDirectory.getAgentId(any(Reference.class))).thenAnswer(answerWithObjectId());
324+
when(randomIdGeneratorService.createNewId()).thenReturn(GENERATED_ID);
325+
lenient().doNothing().when(conditionLinkSetMapperSpy).testForValidReferences(any());
326+
327+
final String actualXml = conditionLinkSetMapperSpy.mapConditionToLinkSet(condition, false);
328+
329+
assertThat(actualXml).isEqualTo(expectedXml);
330+
}
331+
309332
@Test
310333
void When_MappingParsedCondition_With_AllergyIntolerance_Expect_LinkSetXml() {
311334
final Condition condition =
@@ -512,8 +535,7 @@ private static Stream<Arguments> testObservationArguments() {
512535
return Stream.of(
513536
Arguments.of(INPUT_JSON_NO_ACTUAL_PROBLEM, OUTPUT_XML_WITH_GENERATED_PROBLEM_IS_NESTED, true),
514537
Arguments.of(INPUT_JSON_NO_ACTUAL_PROBLEM_NO_DATE, OUTPUT_XML_WITH_NULL_FLAVOR_OBSERVATION_STATEMENT_AVAILABILITY_TIME,
515-
true),
516-
Arguments.of(INPUT_JSON_WITH_ACTUAL_PROBLEM_MEDICATION_REQUEST, OUTPUT_XML_MEDICATION_REQUEST_ACTUAL_PROBLEM, false)
538+
true)
517539
);
518540
}
519541

service/src/test/java/uk/nhs/adaptors/gp2gp/utils/CodeableConceptMapperMockUtil.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ public class CodeableConceptMapperMockUtil {
55
public static final String ACTUAL_PROBLEM_CODE =
66
"<code code=\"55607006\" codeSystem=\"2.16.840.1.113883.2.1.3.2.4.15\" displayName=\"Problem\">";
77

8-
public static final String TEST_CONDITION_CODE = "<code code=\"55607006\" codeSystem=\"2.16.840.1.113883.2.1.3.2.4.15\" displayName=\"Problem\">\n" +
9-
" <originalText>Test Condition</originalText>\n" +
10-
" </code>";
8+
public static final String TEST_CONDITION_CODE =
9+
"<code code=\"55607006\" codeSystem=\"2.16.840.1.113883.2.1.3.2.4.15\" displayName=\"Problem\">" +
10+
"<originalText>Test Condition</originalText>" +
11+
"</code>";
1112

1213
}

0 commit comments

Comments
 (0)