|
38 | 38 | import static org.assertj.core.api.Assumptions.assumeThatThrownBy; |
39 | 39 | import static org.junit.jupiter.api.Assertions.assertAll; |
40 | 40 | import static org.mockito.ArgumentMatchers.any; |
41 | | -import static org.mockito.Mockito.lenient; |
42 | | -import static org.mockito.Mockito.when; |
43 | | -import static org.mockito.Mockito.spy; |
| 41 | +import static org.mockito.Mockito.*; |
| 42 | +import static uk.nhs.adaptors.gp2gp.utils.CodeableConceptMapperMockUtil.TEST_CONDITION_CODE; |
44 | 43 | import static uk.nhs.adaptors.gp2gp.utils.ConfidentialityCodeUtility.NOPAT; |
45 | 44 | import static uk.nhs.adaptors.gp2gp.utils.ConfidentialityCodeUtility.NOPAT_HL7_CONFIDENTIALITY_CODE; |
46 | 45 | import static uk.nhs.adaptors.gp2gp.utils.ConfidentialityCodeUtility.NOSCRUB; |
@@ -260,27 +259,38 @@ void When_MappingParsedCondition_With_RelatedClinicalContentAllergy_Expect_LinkS |
260 | 259 | assertThat(actualXml).isEqualTo(expectedXml); |
261 | 260 | } |
262 | 261 |
|
| 262 | + // It works but the indentation is giving me pain in the test comparison |
263 | 263 | @Test |
264 | 264 | void When_MappingParsedCondition_With_AllergyIntolerance_Expect_LinkSetXml() { |
265 | | - final Condition condition = getConditionResourceFromJson(INPUT_JSON_WITH_ACTUAL_PROBLEM_ALLERGY_INTOLERANCE); |
266 | | - final String expectedXml = getXmlStringFromFile(OUTPUT_XML_ALLERGY_INTOLERANCE_ACTUAL_PROBLEM); |
| 265 | + final Condition condition = |
| 266 | + getConditionResourceFromJson(INPUT_JSON_WITH_ACTUAL_PROBLEM_ALLERGY_INTOLERANCE); |
| 267 | + final String expectedXml = |
| 268 | + getXmlStringFromFile(OUTPUT_XML_ALLERGY_INTOLERANCE_ACTUAL_PROBLEM); |
| 269 | + IdType conditionId = buildIdType(ResourceType.Condition, CONDITION_ID); |
267 | 270 |
|
268 | | - when(codeableConceptCdMapper.mapCodeableConceptToCd(any(CodeableConcept.class))) |
269 | | - .thenReturn(CodeableConceptMapperMockUtil.NULL_FLAVOR_CODE); |
270 | 271 | when(messageContext.getIdMapper()).thenReturn(idMapper); |
271 | 272 | when(messageContext.getAgentDirectory()).thenReturn(agentDirectory); |
272 | 273 | when(messageContext.getInputBundleHolder()).thenReturn(inputBundle); |
273 | | - |
274 | | - IdType conditionId = buildIdType(ResourceType.Condition, CONDITION_ID); |
275 | | - when(idMapper.getOrNew(ResourceType.Condition, conditionId)).thenReturn(CONDITION_ID); |
276 | | - when(idMapper.getOrNew(any(Reference.class))).thenAnswer(answerWithObjectId(ResourceType.Condition)); |
277 | | - when(agentDirectory.getAgentId(any(Reference.class))).thenAnswer(answerWithObjectId()); |
278 | | - when(randomIdGeneratorService.createNewId()).thenReturn(GENERATED_ID); |
279 | | - lenient().doNothing().when(conditionLinkSetMapperSpy).testForValidReferences(any()); |
280 | | - |
281 | | - final String actualXml = conditionLinkSetMapperSpy.mapConditionToLinkSet(condition, false); |
| 274 | + when(idMapper.getOrNew(ResourceType.Condition, conditionId)) |
| 275 | + .thenReturn(CONDITION_ID); |
| 276 | + when(idMapper.getOrNew(any(Reference.class))) |
| 277 | + .thenAnswer(answerWithObjectId(ResourceType.Condition)); |
| 278 | + when(agentDirectory.getAgentId(any(Reference.class))) |
| 279 | + .thenAnswer(answerWithObjectId()); |
| 280 | + when(randomIdGeneratorService.createNewId()) |
| 281 | + .thenReturn(GENERATED_ID); |
| 282 | + lenient().doNothing().when(conditionLinkSetMapperSpy) |
| 283 | + .testForValidReferences(any()); |
| 284 | + when(codeableConceptCdMapper.mapCodeableConceptToCdForTransformedActualProblemHeader( |
| 285 | + any(CodeableConcept.class))) |
| 286 | + .thenReturn(CodeableConceptMapperMockUtil.TEST_CONDITION_CODE); |
| 287 | + |
| 288 | + final String actualXml = |
| 289 | + conditionLinkSetMapperSpy.mapConditionToLinkSet(condition, false); |
282 | 290 |
|
283 | 291 | assertThat(actualXml).isEqualTo(expectedXml); |
| 292 | + verify(codeableConceptCdMapper).mapCodeableConceptToCdForTransformedActualProblemHeader(any()); |
| 293 | + verify(codeableConceptCdMapper, never()).mapCodeableConceptToCd(any()); |
284 | 294 | } |
285 | 295 |
|
286 | 296 | @Test |
@@ -457,7 +467,9 @@ private static Stream<Arguments> testObservationArguments() { |
457 | 467 | Arguments.of(INPUT_JSON_NO_ACTUAL_PROBLEM, OUTPUT_XML_WITH_GENERATED_PROBLEM_IS_NESTED, true), |
458 | 468 | Arguments.of(INPUT_JSON_WITH_ACTUAL_PROBLEM_CONDITION, OUTPUT_XML_WITH_CONDITION_NAMED_OBSERVATION_STATEMENT_GENERATED, false), |
459 | 469 | Arguments.of(INPUT_JSON_NO_ACTUAL_PROBLEM_NO_DATE, OUTPUT_XML_WITH_NULL_FLAVOR_OBSERVATION_STATEMENT_AVAILABILITY_TIME, |
460 | | - true) |
| 470 | + true), |
| 471 | + Arguments.of(INPUT_JSON_WITH_ACTUAL_PROBLEM_IMMUNIZATION, OUTPUT_XML_IMMUNIZATION_ACTUAL_PROBLEM, false), |
| 472 | + Arguments.of(INPUT_JSON_WITH_ACTUAL_PROBLEM_MEDICATION_REQUEST, OUTPUT_XML_MEDICATION_REQUEST_ACTUAL_PROBLEM, false) |
461 | 473 | ); |
462 | 474 | } |
463 | 475 |
|
|
0 commit comments