File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
intTest/java/uk/nhs/adaptors/gp2gp/ehr
test/java/uk/nhs/adaptors/gp2gp/ehr/mapper Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 5252import uk .nhs .adaptors .gp2gp .mhs .MhsRequestBuilder ;
5353import uk .nhs .adaptors .gp2gp .mhs .exception .MhsConnectionException ;
5454import uk .nhs .adaptors .gp2gp .mhs .exception .MhsServerErrorException ;
55+ import uk .nhs .adaptors .gp2gp .ehr .exception .EhrValidationException ;
5556import uk .nhs .adaptors .gp2gp .mhs .model .OutboundMessage ;
5657import uk .nhs .adaptors .gp2gp .testcontainers .ActiveMQExtension ;
5758import uk .nhs .adaptors .gp2gp .testcontainers .MongoDBExtension ;
@@ -356,6 +357,20 @@ public void When_ExtractCoreThrowsMhsServerErrorException_Expect_ExceptionThrown
356357 assertThat (ehrExtractStatusUpdated .getEhrExtractCore ()).isNull ();
357358 }
358359
360+ @ Test
361+ public void When_EhrExtractMapperFailsWithEhrValidationException_Expect_ExceptionThrownAndDbNotUpdated () {
362+ doThrow (EhrValidationException .class )
363+ .when (ehrDocumentMapper ).generateMhsPayload (any (), anyString (), anyString (), anyString ());
364+
365+ assertThatExceptionOfType (EhrValidationException .class )
366+ .isThrownBy (() -> sendEhrExtractCoreTaskExecutor .execute (sendEhrExtractCoreTaskDefinition ));
367+
368+ var ehrExtractStatusUpdated = reloadEhrStatus ();
369+
370+ assertThat (ehrExtractStatusUpdated .getEhrExtractCore ()).isNull ();
371+
372+ }
373+
359374 @ BeforeEach
360375 public void prepareCommonStubbing () {
361376 when (gp2gpConfiguration .getLargeEhrExtractThreshold ()).thenReturn (BinaryUtils .getBytesLengthOfString (SEVENTEEN_BYTE_PAYLOAD ) - 1 );
Original file line number Diff line number Diff line change 66import static org .junit .jupiter .api .Assertions .assertThrows ;
77import static org .mockito .Mockito .when ;
88import static org .mockito .Mockito .mock ;
9- import static org . mockito . Mockito . lenient ;
9+
1010
1111import java .time .Instant ;
1212import java .time .temporal .ChronoUnit ;
@@ -97,7 +97,7 @@ void When_BundleHasNoMappableContent_Expect_EhrValidationExceptionIsThrown() {
9797 .build ();
9898 var bundle = mock (Bundle .class );
9999
100- lenient (). when (nonConsultationResourceMapper .mapRemainingResourcesToEhrCompositions (any (Bundle .class )))
100+ when (nonConsultationResourceMapper .mapRemainingResourcesToEhrCompositions (any (Bundle .class )))
101101 .thenReturn (Collections .emptyList ());
102102
103103 EhrValidationException thrown = assertThrows (EhrValidationException .class , () ->
You can’t perform that action at this time.
0 commit comments