Skip to content

Commit 4c45f7f

Browse files
Removed lenient from AllergyStructureMapperTest
1 parent 73e0988 commit 4c45f7f

File tree

1 file changed

+29
-17
lines changed

1 file changed

+29
-17
lines changed

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

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import static org.junit.jupiter.api.Assertions.assertThrows;
55
import static org.mockito.ArgumentMatchers.any;
66
import static org.mockito.ArgumentMatchers.anyString;
7-
import static org.mockito.Mockito.lenient;
87
import static org.mockito.Mockito.when;
98

109
import static uk.nhs.adaptors.gp2gp.utils.IdUtil.buildIdType;
@@ -71,12 +70,8 @@ private static Stream<Arguments> resourceFileParams() {
7170
Arguments.of("input-with-onset-date-only.json", "expected-uses-onset-date.xml"),
7271
Arguments.of("input-with-reason-end-date-only.json", "expected-uses-end-date.xml"),
7372
Arguments.of("input-with-no-dates.json", "expected-uses-null-flavor-date.xml"),
74-
Arguments.of("input-with-environment-category.json", "expected-uses-environment-category.xml"),
7573
Arguments.of("input-with-medication-category.json", "expected-uses-medication-category.xml"),
7674
Arguments.of("input-with-reaction.json", "expected-uses-reaction.xml"),
77-
Arguments.of("input-with-relation-to-condition-with-one-note.json", "expected-uses-relation-to-condition-with-one-note.xml"),
78-
Arguments.of("input-with-relation-to-condition-with-two-notes.json", "expected-uses-relation-to-condition-with-two-notes.xml"),
79-
Arguments.of("input-with-no-relation-to-condition.json", "expected-uses-no-relation-to-condition.xml"),
8075
Arguments.of("input-with-device-recorder-and-asserter.json", "expected-uses-device-recorder-and-asserter.xml"),
8176
Arguments.of("input-with-related-person-asserter.json", "expected-uses-related-person-asserter.xml"),
8277
Arguments.of("input-with-related-person-asserter-name-text.json", "expected-uses-related-person-asserter.xml"),
@@ -94,22 +89,21 @@ private static Stream<Arguments> resourceFileParams() {
9489
);
9590
}
9691

92+
private static Stream<Arguments> resourceFileParamsWithEnvironmentCategoryAndConditionRelatedData() {
93+
return Stream.of(
94+
Arguments.of("input-with-environment-category.json", "expected-uses-environment-category.xml"),
95+
Arguments.of("input-with-relation-to-condition-with-one-note.json", "expected-uses-relation-to-condition-with-one-note.xml"),
96+
Arguments.of("input-with-relation-to-condition-with-two-notes.json", "expected-uses-relation-to-condition-with-two-notes.xml"),
97+
Arguments.of("input-with-no-relation-to-condition.json", "expected-uses-no-relation-to-condition.xml")
98+
);
99+
}
100+
97101
@BeforeEach
98102
void setUp() {
99103
when(randomIdGeneratorService.createNewId()).thenReturn(TEST_ID);
100104
when(randomIdGeneratorService.createNewOrUseExistingUUID(anyString())).thenReturn(TEST_ID);
101-
102-
lenient().when(codeableConceptCdMapper.mapToNullFlavorCodeableConcept(any(CodeableConcept.class)))
103-
.thenReturn(CodeableConceptMapperMockUtil.NULL_FLAVOR_CODE);
104-
lenient().when(codeableConceptCdMapper.mapCodeableConceptToCd(any(CodeableConcept.class)))
105-
.thenReturn(CodeableConceptMapperMockUtil.NULL_FLAVOR_CODE);
106-
lenient().when(codeableConceptCdMapper.mapCodeableConceptToCdForAllergy(any(CodeableConcept.class),
107-
any(AllergyIntolerance.AllergyIntoleranceClinicalStatus.class)))
108-
.thenReturn(CodeableConceptMapperMockUtil.NULL_FLAVOR_CODE);
109-
lenient().when(codeableConceptCdMapper.mapToNullFlavorCodeableConceptForAllergy(any(CodeableConcept.class),
110-
any(AllergyIntolerance.AllergyIntoleranceClinicalStatus.class)))
111-
.thenReturn(CodeableConceptMapperMockUtil.NULL_FLAVOR_CODE);
112-
lenient().when(confidentialityService.generateConfidentialityCode(any()))
105+
when(randomIdGeneratorService.createNewOrUseExistingUUID(anyString())).thenReturn(TEST_ID);
106+
when(confidentialityService.generateConfidentialityCode(any()))
113107
.thenReturn(Optional.empty());
114108

115109
var bundleInput = ResourceTestFileUtils.getFileContent(INPUT_JSON_BUNDLE);
@@ -145,6 +139,24 @@ void When_MappingAllergyIntoleranceJson_Expect_AllergyStructureXmlOutput(String
145139
final var expectedMessage = ResourceTestFileUtils.getFileContent(TEST_FILE_DIRECTORY + outputXml);
146140
final var allergyIntolerance = parseAllergyIntoleranceFromJsonFile(TEST_FILE_DIRECTORY + inputJson);
147141

142+
when(codeableConceptCdMapper.mapToNullFlavorCodeableConceptForAllergy(any(CodeableConcept.class),
143+
any(AllergyIntolerance.AllergyIntoleranceClinicalStatus.class)))
144+
.thenReturn(CodeableConceptMapperMockUtil.NULL_FLAVOR_CODE);
145+
146+
String message = allergyStructureMapper.mapAllergyIntoleranceToAllergyStructure(allergyIntolerance);
147+
assertThat(message).contains(expectedMessage);
148+
}
149+
150+
@ParameterizedTest
151+
@MethodSource("resourceFileParamsWithEnvironmentCategoryAndConditionRelatedData")
152+
void When_MappingAllergyIntoleranceJson_Expect_AllergyStructureXmlOutputWithEnvironmentCategoryAndConditionRelatedData(String inputJson, String outputXml) {
153+
final var expectedMessage = ResourceTestFileUtils.getFileContent(TEST_FILE_DIRECTORY + outputXml);
154+
final var allergyIntolerance = parseAllergyIntoleranceFromJsonFile(TEST_FILE_DIRECTORY + inputJson);
155+
156+
when(codeableConceptCdMapper.mapCodeableConceptToCdForAllergy(any(CodeableConcept.class),
157+
any(AllergyIntolerance.AllergyIntoleranceClinicalStatus.class)))
158+
.thenReturn(CodeableConceptMapperMockUtil.NULL_FLAVOR_CODE);
159+
148160
String message = allergyStructureMapper.mapAllergyIntoleranceToAllergyStructure(allergyIntolerance);
149161
assertThat(message).contains(expectedMessage);
150162
}

0 commit comments

Comments
 (0)