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_CallsBundleMapperServiceMapToBundle.
@Test
public void When_HandleMessageWithValidDataIsCalled_Expect_CallsBundleMapperServiceMapToBundle() throws JsonProcessingException, JAXBException, InlineAttachmentProcessingException, BundleMappingException, AttachmentNotFoundException, ParseException, SAXException {
InboundMessage inboundMessage = new InboundMessage();
prepareMocks(inboundMessage);
ehrExtractMessageHandler.handleMessage(inboundMessage, CONVERSATION_ID);
// mapped item is private to the class, so we cannot test an exact object
verify(bundleMapperService).mapToBundle(any(RCMRIN030000UK06Message.class), any());
}
use of uk.nhs.adaptors.pss.translator.mhs.model.InboundMessage in project nia-patient-switching-standard-adaptor by NHSDigital.
the class EhrExtractMessageHandlerTest method When_HandleMessage_WithEncodeToJsonThrows_Expect_DataFormatException.
@Test
public void When_HandleMessage_WithEncodeToJsonThrows_Expect_DataFormatException() throws BundleMappingException, AttachmentNotFoundException, ValidationException, InlineAttachmentProcessingException {
InboundMessage inboundMessage = new InboundMessage();
inboundMessage.setPayload(readInboundMessagePayloadFromFile());
Bundle bundle = new Bundle();
bundle.setId("Test");
inboundMessage.setPayload(readInboundMessagePayloadFromFile());
inboundMessage.setExternalAttachments(new ArrayList<>());
PatientMigrationRequest migrationRequest = PatientMigrationRequest.builder().losingPracticeOdsCode(LOSING_ODE_CODE).winningPracticeOdsCode(WINNING_ODE_CODE).build();
when(bundleMapperService.mapToBundle(any(RCMRIN030000UK06Message.class), eq(LOSING_ODE_CODE))).thenReturn(bundle);
when(migrationRequestDao.getMigrationRequest(CONVERSATION_ID)).thenReturn(migrationRequest);
when(attachmentReferenceUpdaterService.updateReferenceToAttachment(inboundMessage.getAttachments(), CONVERSATION_ID, inboundMessage.getPayload())).thenReturn(inboundMessage.getPayload());
doThrow(new DataFormatException()).when(fhirParser).encodeToJson(bundle);
assertThrows(DataFormatException.class, () -> ehrExtractMessageHandler.handleMessage(inboundMessage, CONVERSATION_ID));
}
use of uk.nhs.adaptors.pss.translator.mhs.model.InboundMessage in project nia-patient-switching-standard-adaptor by NHSDigital.
the class EhrExtractMessageHandlerTest method When_HandleSingleMessageWithValidDataIsCalled_Expect_NotToCallSendContinueRequest.
@Test
public void When_HandleSingleMessageWithValidDataIsCalled_Expect_NotToCallSendContinueRequest() throws JsonProcessingException, JAXBException, InlineAttachmentProcessingException, BundleMappingException, AttachmentNotFoundException, ParseException, SAXException {
Bundle bundle = new Bundle();
bundle.setId("Test");
InboundMessage inboundMessage = new InboundMessage();
List<InboundMessage.ExternalAttachment> externalAttachmentsTestList = new ArrayList<>();
inboundMessage.setPayload(readInboundSingleMessagePayloadFromFile());
inboundMessage.setEbXML(readInboundSingleMessageEbXmlFromFile());
inboundMessage.setExternalAttachments(externalAttachmentsTestList);
prepareMigrationRequestAndMigrationStatusMocks();
when(attachmentReferenceUpdaterService.updateReferenceToAttachment(inboundMessage.getAttachments(), CONVERSATION_ID, inboundMessage.getPayload())).thenReturn(inboundMessage.getPayload());
EhrExtractMessageHandler ehrExtractMessageHandlerSpy = Mockito.spy(ehrExtractMessageHandler);
ehrExtractMessageHandlerSpy.handleMessage(inboundMessage, CONVERSATION_ID);
verify(ehrExtractMessageHandlerSpy, times(0)).sendContinueRequest(any(RCMRIN030000UK06Message.class), any(String.class), any(String.class), any(String.class), any(Instant.class));
}
use of uk.nhs.adaptors.pss.translator.mhs.model.InboundMessage in project nia-patient-switching-standard-adaptor by NHSDigital.
the class EhrExtractMessageHandlerTest method When_HandleLargeMessageWithValidDataIsCalled_Expect_AddAttachmentExactNumerOfTimesAsExternalAttachmentsList.
// We are no longer storing the payload as an attachment in the case of a Skelton message.
// @Test
// public void When_HandleLargeMessageWithValidDataIsCalled_Expect_StoreMessagePayload()
// throws
// JsonProcessingException,
// JAXBException,
// InlineAttachmentProcessingException,
// BundleMappingException,
// AttachmentNotFoundException,
// ParseException,
// SAXException {
//
// Bundle bundle = new Bundle();
// bundle.setId("Test");
//
// InboundMessage inboundMessage = new InboundMessage();
// List<InboundMessage.ExternalAttachment> externalAttachmentsTestList = new ArrayList<>();
// externalAttachmentsTestList.add(
// new InboundMessage.ExternalAttachment(
// "68E2A39F-7A24-449D-83CC-1B7CF1A9DAD7spine.nhs",
// "66B41202-C358-4B4C-93C6-7A10803F9584",
// "68E2A39F-7A24-449D-83CC-1B7CF1A9DAD7spine.nhs.ukExample1",
// "Filename=\"68E2A39F-7A24-449D-83CC-1B7CF1A9DAD7spine.nhs.ukExample1.gzip\" "
// + "ContentType=text/xml Compressed=Yes LargeAttachment=No OriginalBase64=Yes "
// + "DomainData=\"X-GP2GP-Skeleton: Yes\"")
// );
//
// inboundMessage.setPayload(readLargeInboundMessagePayloadFromFile());
// inboundMessage.setEbXML(readLargeInboundMessageEbXmlFromFile());
// inboundMessage.setExternalAttachments(externalAttachmentsTestList);
//
// prepareMigrationRequestAndMigrationStatusMocks();
//
// ehrExtractMessageHandler.handleMessage(inboundMessage, CONVERSATION_ID);
// verify(attachmentHandlerService, times(1)).storeAttachementWithoutProcessing(any(), any(), any(), any());
// }
@Test
public void When_HandleLargeMessageWithValidDataIsCalled_Expect_AddAttachmentExactNumerOfTimesAsExternalAttachmentsList() throws JsonProcessingException, JAXBException, InlineAttachmentProcessingException, BundleMappingException, AttachmentNotFoundException, ParseException, SAXException {
Bundle bundle = new Bundle();
bundle.setId("Test");
InboundMessage inboundMessage = new InboundMessage();
List<InboundMessage.ExternalAttachment> externalAttachmentsTestList = new ArrayList<>();
externalAttachmentsTestList.add(new InboundMessage.ExternalAttachment("68E2A39F-7A24-449D-83CC-1B7CF1A9DAD7spine.nhs", "66B41202-C358-4B4C-93C6-7A10803F9584", "68E2A39F-7A24-449D-83CC-1B7CF1A9DAD7spine.nhs.ukExample1", "Filename=\"68E2A39F-7A24-449D-83CC-1B7CF1A9DAD7spine.nhs.ukExample1.gzip\" " + "ContentType=text/xml Compressed=Yes LargeAttachment=No OriginalBase64=Yes " + "DomainData=\"X-GP2GP-Skeleton: Yes\""));
externalAttachmentsTestList.add(new InboundMessage.ExternalAttachment("68E2A39F-7A24-449D-83CC-1B7CF1A9DAD7spine.nhs", "66B41202-C358-4B4C-93C6-7A10803F9584", "68E2A39F-7A24-449D-83CC-1B7CF1A9DAD7spine.nhs.ukExample1", "Filename=\"68E2A39F-7A24-449D-83CC-1B7CF1A9DAD7spine.nhs.ukExample1.gzip\" " + "ContentType=text/xml Compressed=Yes LargeAttachment=No OriginalBase64=Yes " + "DomainData=\"X-GP2GP-Skeleton: Yes\""));
externalAttachmentsTestList.add(new InboundMessage.ExternalAttachment("68E2A39F-7A24-449D-83CC-1B7CF1A9DAD7spine.nhs", "66B41202-C358-4B4C-93C6-7A10803F9584", "68E2A39F-7A24-449D-83CC-1B7CF1A9DAD7spine.nhs.ukExample1", "Filename=\"68E2A39F-7A24-449D-83CC-1B7CF1A9DAD7spine.nhs.ukExample1.gzip\" " + "ContentType=text/xml Compressed=Yes LargeAttachment=No OriginalBase64=Yes"));
externalAttachmentsTestList.add(new InboundMessage.ExternalAttachment("68E2A39F-7A24-449D-83CC-1B7CF1A9DAD7spine.nhs", "66B41202-C358-4B4C-93C6-7A10803F9584", "68E2A39F-7A24-449D-83CC-1B7CF1A9DAD7spine.nhs.ukExample1", "Filename=\"68E2A39F-7A24-449D-83CC-1B7CF1A9DAD7spine.nhs.ukExample1.gzip\" " + "ContentType=text/xml Compressed=Yes LargeAttachment=No OriginalBase64=Yes"));
inboundMessage.setPayload(readLargeInboundMessagePayloadFromFile());
inboundMessage.setEbXML(readLargeInboundMessageEbXmlFromFile());
inboundMessage.setExternalAttachments(externalAttachmentsTestList);
prepareMigrationRequestAndMigrationStatusMocks();
ehrExtractMessageHandler.handleMessage(inboundMessage, CONVERSATION_ID);
verify(patientAttachmentLogService, times(externalAttachmentsTestList.size())).addAttachmentLog(any());
}
use of uk.nhs.adaptors.pss.translator.mhs.model.InboundMessage in project nia-patient-switching-standard-adaptor by NHSDigital.
the class EhrExtractMessageHandlerTest method When_HandleLargeMessageWithValidDataIsCalled_Expect_CallSendContinueRequest.
@Test
public void When_HandleLargeMessageWithValidDataIsCalled_Expect_CallSendContinueRequest() throws JsonProcessingException, JAXBException, InlineAttachmentProcessingException, BundleMappingException, AttachmentNotFoundException, ParseException, SAXException {
Bundle bundle = new Bundle();
bundle.setId("Test");
InboundMessage inboundMessage = new InboundMessage();
List<InboundMessage.ExternalAttachment> externalAttachmentsTestList = new ArrayList<>();
externalAttachmentsTestList.add(new InboundMessage.ExternalAttachment("68E2A39F-7A24-449D-83CC-1B7CF1A9DAD7spine.nhs", "66B41202-C358-4B4C-93C6-7A10803F9584", "68E2A39F-7A24-449D-83CC-1B7CF1A9DAD7spine.nhs.ukExample1", "Filename=\"68E2A39F-7A24-449D-83CC-1B7CF1A9DAD7spine.nhs.ukExample1.gzip\" " + "ContentType=text/xml Compressed=Yes LargeAttachment=No OriginalBase64=Yes " + "DomainData=\"X-GP2GP-Skeleton: Yes\""));
inboundMessage.setPayload(readLargeInboundMessagePayloadFromFile());
inboundMessage.setEbXML(readLargeInboundMessageEbXmlFromFile());
inboundMessage.setExternalAttachments(externalAttachmentsTestList);
prepareMigrationRequestAndMigrationStatusMocks();
EhrExtractMessageHandler ehrExtractMessageHandlerSpy = Mockito.spy(ehrExtractMessageHandler);
ehrExtractMessageHandlerSpy.handleMessage(inboundMessage, CONVERSATION_ID);
verify(ehrExtractMessageHandlerSpy).sendContinueRequest(any(RCMRIN030000UK06Message.class), any(String.class), any(String.class), any(String.class), any(Instant.class));
}
Aggregations