22
33import static org .assertj .core .api .Assertions .assertThat ;
44import static org .assertj .core .api .Assertions .assertThatExceptionOfType ;
5+ import static org .junit .jupiter .api .Assertions .assertDoesNotThrow ;
56import static org .mockito .ArgumentMatchers .any ;
67import static org .mockito .Mockito .doThrow ;
78
3435@ DirtiesContext
3536public class SendDocumentComponentTest {
3637 private static final String DOCUMENT_NAME = "some-conversation-id/document-name.json" ;
38+ public static final String OUTBOUND_MESSAGE_JSON = "src/intTest/resources/outboundMessage.json" ;
39+ public static final String OUTBOUND_MESSAGE_WITH_OVER_20MB_PAYLOAD_JSON
40+ = "src/intTest/resources/outboundMessageWithOver20MbPayload.json" ;
3741
3842 @ MockBean
3943 private MhsClient mhsClient ;
@@ -47,9 +51,21 @@ public class SendDocumentComponentTest {
4751 @ Autowired
4852 private LocalMockConnector localMockConnector ;
4953
54+ @ Test
55+ public void When_SendDocumentTaskRunsWithOver20MbPayloadMessage_Expect_NoException () throws IOException {
56+ var inputStream = readMessageAsInputStream (OUTBOUND_MESSAGE_WITH_OVER_20MB_PAYLOAD_JSON );
57+ localMockConnector .uploadToStorage (inputStream , inputStream .available (), DOCUMENT_NAME );
58+ var ehrExtractStatus = EhrExtractStatusTestUtils .prepareEhrExtractStatus ();
59+ ehrExtractStatusRepository .save (ehrExtractStatus );
60+
61+ var sendDocumentTaskDefinition = prepareTaskDefinition (ehrExtractStatus );
62+
63+ assertDoesNotThrow (() -> sendDocumentTaskExecutor .execute (sendDocumentTaskDefinition ));
64+ }
65+
5066 @ Test
5167 public void When_SendDocumentTaskRunsTwice_Expect_DatabaseOverwritesEhrExtractStatus () throws IOException {
52- var inputStream = readMessageAsInputStream ();
68+ var inputStream = readMessageAsInputStream (OUTBOUND_MESSAGE_JSON );
5369 localMockConnector .uploadToStorage (inputStream , inputStream .available (), DOCUMENT_NAME );
5470 var ehrExtractStatus = EhrExtractStatusTestUtils .prepareEhrExtractStatus ();
5571 ehrExtractStatusRepository .save (ehrExtractStatus );
@@ -67,7 +83,7 @@ public void When_SendDocumentTaskRunsTwice_Expect_DatabaseOverwritesEhrExtractSt
6783
6884 @ Test
6985 public void When_SendDocumentTask_WithMhsConnectionException_Expect_ExceptionThrownAndDatabaseNotUpdated () throws IOException {
70- var inputStream = readMessageAsInputStream ();
86+ var inputStream = readMessageAsInputStream (OUTBOUND_MESSAGE_JSON );
7187 localMockConnector .uploadToStorage (inputStream , inputStream .available (), DOCUMENT_NAME );
7288 var ehrExtractStatus = EhrExtractStatusTestUtils .prepareEhrExtractStatus ();
7389 ehrExtractStatusRepository .save (ehrExtractStatus );
@@ -87,7 +103,7 @@ public void When_SendDocumentTask_WithMhsConnectionException_Expect_ExceptionThr
87103
88104 @ Test
89105 public void When_SendDocumentTask_WithMhsServerFailureException_Expect_ExceptionThrownAndDataBaseNotUpdated () throws IOException {
90- var inputStream = readMessageAsInputStream ();
106+ var inputStream = readMessageAsInputStream (OUTBOUND_MESSAGE_JSON );
91107 localMockConnector .uploadToStorage (inputStream , inputStream .available (), DOCUMENT_NAME );
92108 var ehrExtractStatus = EhrExtractStatusTestUtils .prepareEhrExtractStatus ();
93109 ehrExtractStatusRepository .save (ehrExtractStatus );
@@ -105,8 +121,8 @@ public void When_SendDocumentTask_WithMhsServerFailureException_Expect_Exception
105121 assertThat (ehrExtractStatusHasSentDocuments (ehrExtractUpdated )).isFalse ();
106122 }
107123
108- private InputStream readMessageAsInputStream () throws IOException {
109- File file = new File ("src/intTest/resources/outboundMessage.json" );
124+ private InputStream readMessageAsInputStream (String pathname ) throws IOException {
125+ File file = new File (pathname );
110126 return new FileInputStream (file );
111127 }
112128
0 commit comments