use of uk.nhs.adaptors.pss.translator.mhs.model.InboundMessage in project nia-patient-switching-standard-adaptor by NHSDigital.
the class COPCMessageHandlerTest method When_MIDFragmentRecordHasAnAttachmentLog_Expect_AttachmentLogToBeUpdated.
@Test
public void When_MIDFragmentRecordHasAnAttachmentLog_Expect_AttachmentLogToBeUpdated() throws JAXBException, InlineAttachmentProcessingException, SAXException, AttachmentLogException, AttachmentNotFoundException, BundleMappingException, JsonProcessingException {
var parentMid = "CBBAE92D-C7E8-4A9C-8887-F5AEBA1F8CE1";
var childMid = "28B31-4245-4AFC-8DA2-8A40623A5101";
InboundMessage message = new InboundMessage();
prepareFragmentIndexMocks(message);
when(patientAttachmentLogService.findAttachmentLog(MESSAGE_ID, CONVERSATION_ID)).thenReturn(buildPatientAttachmentLog(parentMid, null, true));
when(patientAttachmentLogService.findAttachmentLog(childMid, CONVERSATION_ID)).thenReturn(buildPartialPatientAttachmentLog(childMid, "text/plain"));
when(patientAttachmentLogService.findAttachmentLog("CBBAE92D-C7E8-4A9C-8887-F5AEBA1F8CE1", CONVERSATION_ID)).thenReturn(buildPatientAttachmentLog("047C22B4-613F-47D3-9A72-44A1758464FB", "CBBAE92D-C7E8-4A9C-8887-F5AEBA1F8CE1", true));
EbxmlReference reference = new EbxmlReference("First instance is always a payload", "mid:xxxx-xxxx-xxxx-xxxx", "docId");
EbxmlReference reference2 = new EbxmlReference("desc", "mid:28B31-4245-4AFC-8DA2-8A40623A5101", "docId");
List<EbxmlReference> attachmentReferenceDescription = new ArrayList<>();
attachmentReferenceDescription.add(reference);
attachmentReferenceDescription.add(reference2);
when(xmlParseUtilService.getEbxmlAttachmentsData(any())).thenReturn(attachmentReferenceDescription);
// ACT
copcMessageHandler.handleMessage(message, CONVERSATION_ID);
// ASSERT
verify(patientAttachmentLogService).updateAttachmentLog(patientLogCaptor.capture(), conversationIdCaptor.capture());
PatientAttachmentLog actual = patientLogCaptor.getValue();
assertThat(actual.getBase64()).isTrue();
assertThat(actual.getLargeAttachment()).isTrue();
assertThat(actual.getCompressed()).isFalse();
assertEquals(0, actual.getOrderNum());
assertEquals("047C22B4-613F-47D3-9A72-44A1758464FB", actual.getParentMid());
assertEquals(CONVERSATION_ID, conversationIdCaptor.getValue());
}
use of uk.nhs.adaptors.pss.translator.mhs.model.InboundMessage in project nia-patient-switching-standard-adaptor by NHSDigital.
the class COPCMessageHandlerTest method When_CIDFragmentPartIsReceivedInOrder_Expect_ShouldUploadFile.
@Test
public void When_CIDFragmentPartIsReceivedInOrder_Expect_ShouldUploadFile() throws JAXBException, InlineAttachmentProcessingException, SkeletonEhrProcessingException, SAXException, AttachmentLogException, AttachmentNotFoundException, BundleMappingException, JsonProcessingException {
InboundMessage message = new InboundMessage();
prepareExpectedFragmentMocks(message);
when(patientAttachmentLogService.findAttachmentLog(MESSAGE_ID, CONVERSATION_ID)).thenReturn(buildPatientAttachmentLog("047C22B4-613F-47D3-9A72-44A1758464FB", "CBBAE92D-C7E8-4A9C-8887-F5AEBA1F8CE1", true));
copcMessageHandler.handleMessage(message, CONVERSATION_ID);
verify(attachmentHandlerService).storeAttachementWithoutProcessing(filenameCaptor.capture(), payloadCaptor.capture(), conversationIdCaptor.capture(), contentTypeCaptor.capture());
assertEquals("E39E79A2-FA96-48FF-9373-7BBCB9D036E7.txt", filenameCaptor.getValue());
assertEquals("This is a payload", payloadCaptor.getValue());
assertEquals(CONVERSATION_ID, conversationIdCaptor.getValue());
assertEquals("xml/text", contentTypeCaptor.getValue());
}
use of uk.nhs.adaptors.pss.translator.mhs.model.InboundMessage in project nia-patient-switching-standard-adaptor by NHSDigital.
the class COPCMessageHandlerTest method When_CIDMessageFileIsProcessed_Expect_AttachmentLogUploadedColumnIsSetToTrue.
@Test
public void When_CIDMessageFileIsProcessed_Expect_AttachmentLogUploadedColumnIsSetToTrue() throws JAXBException, InlineAttachmentProcessingException, SAXException, AttachmentLogException, AttachmentNotFoundException, BundleMappingException, JsonProcessingException {
InboundMessage message = new InboundMessage();
prepareExpectedFragmentMocks(message);
when(patientAttachmentLogService.findAttachmentLog(MESSAGE_ID, CONVERSATION_ID)).thenReturn(buildPatientAttachmentLog("047C22B4-613F-47D3-9A72-44A1758464FB", "CBBAE92D-C7E8-4A9C-8887-F5AEBA1F8CE1", true));
copcMessageHandler.handleMessage(message, CONVERSATION_ID);
verify(patientAttachmentLogService).updateAttachmentLog(patientLogCaptor.capture(), conversationIdCaptor.capture());
PatientAttachmentLog actual = patientLogCaptor.getAllValues().get(0);
assertThat(actual.getUploaded()).isTrue();
assertEquals(CONVERSATION_ID, conversationIdCaptor.getValue());
}
use of uk.nhs.adaptors.pss.translator.mhs.model.InboundMessage in project nia-patient-switching-standard-adaptor by NHSDigital.
the class COPCMessageHandlerTest method When_CIDFragmentPartIsReceivedBeforeFragmentIndex_Expect_PartialLogToBeCreated.
@Test
public void When_CIDFragmentPartIsReceivedBeforeFragmentIndex_Expect_PartialLogToBeCreated() throws JAXBException, InlineAttachmentProcessingException, SAXException, AttachmentLogException, AttachmentNotFoundException, BundleMappingException, JsonProcessingException {
// fragmentAttachmentLog = buildPatientAttachmentLog("28B31-4245-4AFC-8DA2-8A40623A5101", "", 0, true);
// ARRANGE
var messageId = "CBBAE92D-C7E8-4A9C-8887-F5AEBA1F8CE1";
when(patientAttachmentLogService.findAttachmentLog(messageId, CONVERSATION_ID)).thenReturn(null).thenReturn(buildPatientAttachmentLog("047C22B4-613F-47D3-9A72-44A1758464FB", null, true));
when(patientAttachmentLogService.findAttachmentLog("047C22B4-613F-47D3-9A72-44A1758464FB", CONVERSATION_ID)).thenReturn(buildPatientAttachmentLog("047C22B4-613F-47D3-9A72-44A1758464FB", "CBBAE92D-C7E8-4A9C-8887-F5AEBA1F8CE1", true));
InboundMessage message = new InboundMessage();
prepareFragmentMocks(message);
// ACT
copcMessageHandler.handleMessage(message, CONVERSATION_ID);
// ASSERT
verify(patientAttachmentLogService).addAttachmentLog(patientLogCaptor.capture());
PatientAttachmentLog actual = patientLogCaptor.getAllValues().get(0);
assertThat(actual.getUploaded()).isTrue();
assertEquals("047C22B4-613F-47D3-9A72-44A1758464FB", actual.getMid());
assertEquals("E39E79A2-FA96-48FF-9373-7BBCB9D036E7_1.messageattachment", actual.getFilename());
assertEquals("xml/text", actual.getContentType());
assertEquals(1, actual.getPatientMigrationReqId());
}
use of uk.nhs.adaptors.pss.translator.mhs.model.InboundMessage in project nia-patient-switching-standard-adaptor by NHSDigital.
the class EhrExtractMessageHandlerTest method When_HandleMessageWithValidDataIsCalled_Expect_CallsAttachmentHandlerServiceStoreAttachments.
@Test
public void When_HandleMessageWithValidDataIsCalled_Expect_CallsAttachmentHandlerServiceStoreAttachments() throws JsonProcessingException, JAXBException, InlineAttachmentProcessingException, BundleMappingException, AttachmentNotFoundException, ParseException, SAXException {
InboundMessage inboundMessage = new InboundMessage();
prepareMocks(inboundMessage);
ehrExtractMessageHandler.handleMessage(inboundMessage, CONVERSATION_ID);
verify(attachmentHandlerService).storeAttachments(inboundMessage.getAttachments(), CONVERSATION_ID);
}
Aggregations