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_CallsMigrationStatusLogServiceAddMigrationStatusLog.
@Test
public void When_HandleMessageWithValidDataIsCalled_Expect_CallsMigrationStatusLogServiceAddMigrationStatusLog() throws JsonProcessingException, JAXBException, InlineAttachmentProcessingException, BundleMappingException, AttachmentNotFoundException, ParseException, SAXException {
InboundMessage inboundMessage = new InboundMessage();
prepareMocks(inboundMessage);
ehrExtractMessageHandler.handleMessage(inboundMessage, CONVERSATION_ID);
verify(migrationStatusLogService).addMigrationStatusLog(EHR_EXTRACT_RECEIVED, CONVERSATION_ID);
verify(migrationStatusLogService).updatePatientMigrationRequestAndAddMigrationStatusLog(CONVERSATION_ID, BUNDLE_STRING, INBOUND_MESSAGE_STRING, EHR_EXTRACT_TRANSLATED);
}
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_ItShouldNotTranslate.
@Test
public void When_HandleLargeMessageWithValidDataIsCalled_Expect_ItShouldNotTranslate() throws JAXBException, BundleMappingException, AttachmentNotFoundException, ParseException, JsonProcessingException, InlineAttachmentProcessingException, 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(bundleMapperService, times(0)).mapToBundle(any(), 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_HandleMessageWithValidDataIsCalled_Expect_CallsStatusLogServiceUpdatePatientMigrationRequestAndAddMigrationStatusLog.
@Test
public void When_HandleMessageWithValidDataIsCalled_Expect_CallsStatusLogServiceUpdatePatientMigrationRequestAndAddMigrationStatusLog() throws JsonProcessingException, JAXBException, InlineAttachmentProcessingException, BundleMappingException, AttachmentNotFoundException, ParseException, SAXException {
InboundMessage inboundMessage = new InboundMessage();
prepareMocks(inboundMessage);
ehrExtractMessageHandler.handleMessage(inboundMessage, CONVERSATION_ID);
verify(migrationStatusLogService).updatePatientMigrationRequestAndAddMigrationStatusLog(CONVERSATION_ID, BUNDLE_STRING, INBOUND_MESSAGE_STRING, EHR_EXTRACT_TRANSLATED);
}
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_WithStoreAttachmentsThrows_Expect_InlineAttachmentProcessingException.
@Test
public void When_HandleMessage_WithStoreAttachmentsThrows_Expect_InlineAttachmentProcessingException() throws JAXBException, InlineAttachmentProcessingException {
InboundMessage inboundMessage = new InboundMessage();
Bundle bundle = new Bundle();
bundle.setId("Test");
inboundMessage.setPayload(readInboundMessagePayloadFromFile());
inboundMessage.setAttachments(new ArrayList<>());
PatientMigrationRequest migrationRequest = PatientMigrationRequest.builder().losingPracticeOdsCode(LOSING_ODE_CODE).winningPracticeOdsCode(WINNING_ODE_CODE).build();
when(migrationRequestDao.getMigrationRequest(CONVERSATION_ID)).thenReturn(migrationRequest);
doThrow(new InlineAttachmentProcessingException("Test Exception")).when(attachmentHandlerService).storeAttachments(any(), any());
assertThrows(InlineAttachmentProcessingException.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_HandleMessageWithValidDataIsCalled_Expect_CallsAttachmentReferenceUpdaterServiceUpdateReferences.
@Test
public void When_HandleMessageWithValidDataIsCalled_Expect_CallsAttachmentReferenceUpdaterServiceUpdateReferences() throws JsonProcessingException, JAXBException, InlineAttachmentProcessingException, BundleMappingException, AttachmentNotFoundException, ParseException, SAXException {
InboundMessage inboundMessage = new InboundMessage();
prepareMocks(inboundMessage);
ehrExtractMessageHandler.handleMessage(inboundMessage, CONVERSATION_ID);
verify(attachmentReferenceUpdaterService).updateReferenceToAttachment(inboundMessage.getAttachments(), CONVERSATION_ID, inboundMessage.getPayload());
}
Aggregations