Search in sources :

Example 26 with InboundMessage

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);
}
Also used : InboundMessage(uk.nhs.adaptors.pss.translator.mhs.model.InboundMessage) Test(org.junit.jupiter.api.Test)

Example 27 with InboundMessage

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());
}
Also used : Bundle(org.hl7.fhir.dstu3.model.Bundle) ArrayList(java.util.ArrayList) InboundMessage(uk.nhs.adaptors.pss.translator.mhs.model.InboundMessage) Test(org.junit.jupiter.api.Test)

Example 28 with InboundMessage

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);
}
Also used : InboundMessage(uk.nhs.adaptors.pss.translator.mhs.model.InboundMessage) Test(org.junit.jupiter.api.Test)

Example 29 with InboundMessage

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));
}
Also used : PatientMigrationRequest(uk.nhs.adaptors.connector.model.PatientMigrationRequest) Bundle(org.hl7.fhir.dstu3.model.Bundle) InboundMessage(uk.nhs.adaptors.pss.translator.mhs.model.InboundMessage) InlineAttachmentProcessingException(uk.nhs.adaptors.pss.translator.exception.InlineAttachmentProcessingException) Test(org.junit.jupiter.api.Test)

Example 30 with InboundMessage

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());
}
Also used : InboundMessage(uk.nhs.adaptors.pss.translator.mhs.model.InboundMessage) Test(org.junit.jupiter.api.Test)

Aggregations

InboundMessage (uk.nhs.adaptors.pss.translator.mhs.model.InboundMessage)36 Test (org.junit.jupiter.api.Test)27 ArrayList (java.util.ArrayList)9 PatientAttachmentLog (uk.nhs.adaptors.connector.model.PatientAttachmentLog)8 Bundle (org.hl7.fhir.dstu3.model.Bundle)6 RCMRIN030000UK06Message (org.hl7.v3.RCMRIN030000UK06Message)6 SAXException (org.xml.sax.SAXException)6 PatientMigrationRequest (uk.nhs.adaptors.connector.model.PatientMigrationRequest)6 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)5 JAXBException (javax.xml.bind.JAXBException)5 BundleMappingException (uk.nhs.adaptors.pss.translator.exception.BundleMappingException)5 InlineAttachmentProcessingException (uk.nhs.adaptors.pss.translator.exception.InlineAttachmentProcessingException)5 EbxmlReference (uk.nhs.adaptors.pss.translator.model.EbxmlReference)5 ParseException (java.text.ParseException)4 Document (org.w3c.dom.Document)4 FileUtil.readResourceAsString (uk.nhs.adaptors.common.util.FileUtil.readResourceAsString)4 AttachmentNotFoundException (uk.nhs.adaptors.pss.translator.exception.AttachmentNotFoundException)4 XmlUnmarshallUtil.unmarshallString (uk.nhs.adaptors.pss.translator.util.XmlUnmarshallUtil.unmarshallString)4 DataFormatException (ca.uhn.fhir.parser.DataFormatException)3 AttachmentLogException (uk.nhs.adaptors.pss.translator.exception.AttachmentLogException)3