2323import org .junit .jupiter .params .provider .MethodSource ;
2424import org .mockito .Mock ;
2525import org .mockito .junit .jupiter .MockitoExtension ;
26- import org .mockito .junit .jupiter .MockitoSettings ;
27- import org .mockito .quality .Strictness ;
28-
2926import uk .nhs .adaptors .gp2gp .common .service .ConfidentialityService ;
3027import uk .nhs .adaptors .gp2gp .common .service .FhirParseService ;
3128import uk .nhs .adaptors .gp2gp .common .service .RandomIdGeneratorService ;
3229import uk .nhs .adaptors .gp2gp .ehr .exception .EhrMapperException ;
3330import uk .nhs .adaptors .gp2gp .utils .ResourceTestFileUtils ;
3431
3532@ ExtendWith (MockitoExtension .class )
36- @ MockitoSettings (strictness = Strictness .LENIENT )
3733class ObservationToNarrativeStatementMapperTest {
3834 private static final String TEST_ID = "394559384658936" ;
3935 private static final String TEST_FILE_DIRECTORY = "/ehr/mapper/observation/" ;
@@ -68,7 +64,6 @@ class ObservationToNarrativeStatementMapperTest {
6864
6965 @ BeforeEach
7066 void setUp () {
71- when (randomIdGeneratorService .createNewId ()).thenReturn (TEST_ID );
7267 when (randomIdGeneratorService .createNewOrUseExistingUUID (anyString ())).thenReturn (TEST_ID );
7368
7469 messageContext = new MessageContext (randomIdGeneratorService );
@@ -86,6 +81,8 @@ void tearDown() {
8681 @ ParameterizedTest
8782 @ MethodSource ("resourceFileParams" )
8883 void When_MappingObservationJson_Expect_NarrativeStatementXmlOutput (String inputJson , String outputXml ) {
84+ when (randomIdGeneratorService .createNewId ()).thenReturn (TEST_ID );
85+
8986 messageContext .getAgentDirectory ().getAgentId (buildReference (ResourceType .Practitioner , "something" ));
9087 messageContext .getAgentDirectory ().getAgentId (buildReference (ResourceType .Organization , "something" ));
9188
@@ -144,16 +141,17 @@ void When_MappingObservationWithInvalidParticipantResourceType_Expect_MapperExce
144141 @ ParameterizedTest
145142 @ MethodSource ("resourceFileParamsThrowError" )
146143 void When_MappingObservationWithAttachmentAndSampleData_Expect_MapperException (String inputJson , Class expectedClass ) {
144+ when (randomIdGeneratorService .createNewId ()).thenReturn (TEST_ID );
145+
147146 var jsonInput = ResourceTestFileUtils .getFileContent (inputJson );
148147 Observation parsedObservation = new FhirParseService ().parseResource (jsonInput , Observation .class );
149-
150148 var exception = assertThrows (EhrMapperException .class , () ->
151- observationToNarrativeStatementMapper .mapObservationToNarrativeStatement (parsedObservation , true ));
152-
149+ observationToNarrativeStatementMapper .mapObservationToNarrativeStatement (parsedObservation , true ));
153150 assertThat (exception .getMessage ()).isEqualTo (String .format (
154- "Observation value type %s not supported." , expectedClass ));
151+ "Observation value type %s not supported." , expectedClass ));
155152 }
156153
154+
157155 private static Stream <Arguments > resourceFileParamsThrowError () {
158156 return Stream .of (
159157 Arguments .of (INPUT_JSON_WITH_SAMPLED_DATA_VALUE , SampledData .class ),
0 commit comments