Search in sources :

Example 6 with InboundMessage

use of uk.nhs.adaptors.pss.translator.mhs.model.InboundMessage in project nia-patient-switching-standard-adaptor by NHSDigital.

the class MhsQueueMessageHandlerTest method handleEhrExtractMessageWhenEhrExtractMessageHandlerThrowsErrorShouldReturnFalse.

@Test
public void handleEhrExtractMessageWhenEhrExtractMessageHandlerThrowsErrorShouldReturnFalse() throws JAXBException, JsonProcessingException, InlineAttachmentProcessingException, BundleMappingException, AttachmentNotFoundException, ParseException, SAXException {
    inboundMessage = new InboundMessage();
    prepareMocks(EHR_EXTRACT_INTERACTION_ID);
    doThrow(new JAXBException("Nobody expects the spanish inquisition!")).when(ehrExtractMessageHandler).handleMessage(inboundMessage, CONVERSATION_ID);
    boolean result = mhsQueueMessageHandler.handleMessage(message);
    assertFalse(result);
    verify(mdcService).applyConversationId(CONVERSATION_ID);
    verifyNoInteractions(acknowledgmentMessageHandler);
}
Also used : JAXBException(javax.xml.bind.JAXBException) InboundMessage(uk.nhs.adaptors.pss.translator.mhs.model.InboundMessage) Test(org.junit.jupiter.api.Test)

Example 7 with InboundMessage

use of uk.nhs.adaptors.pss.translator.mhs.model.InboundMessage in project nia-patient-switching-standard-adaptor by NHSDigital.

the class MhsQueueMessageHandlerTest method handleAcknowledgeMessageWithoutErrorsShouldReturnTrue.

@Test
public void handleAcknowledgeMessageWithoutErrorsShouldReturnTrue() throws SAXException {
    inboundMessage = new InboundMessage();
    prepareMocks(ACKNOWLEDGEMENT_INTERACTION_ID);
    boolean result = mhsQueueMessageHandler.handleMessage(message);
    assertTrue(result);
    verify(mdcService).applyConversationId(CONVERSATION_ID);
    verify(acknowledgmentMessageHandler).handleMessage(inboundMessage, CONVERSATION_ID);
    verifyNoInteractions(ehrExtractMessageHandler);
}
Also used : InboundMessage(uk.nhs.adaptors.pss.translator.mhs.model.InboundMessage) Test(org.junit.jupiter.api.Test)

Example 8 with InboundMessage

use of uk.nhs.adaptors.pss.translator.mhs.model.InboundMessage in project nia-patient-switching-standard-adaptor by NHSDigital.

the class AcknowledgmentMessageHandlerTest method handleMessageWithAckTypeCode.

@Test
public void handleMessageWithAckTypeCode() throws SAXException {
    inboundMessage = new InboundMessage();
    prepareXPathServiceMocks(ACK_TYPE_CODE);
    acknowledgmentMessageHandler.handleMessage(inboundMessage, CONVERSATION_ID);
    verify(migrationStatusLogService).addMigrationStatusLog(EHR_EXTRACT_REQUEST_ACKNOWLEDGED, CONVERSATION_ID);
}
Also used : InboundMessage(uk.nhs.adaptors.pss.translator.mhs.model.InboundMessage) Test(org.junit.jupiter.api.Test)

Example 9 with InboundMessage

use of uk.nhs.adaptors.pss.translator.mhs.model.InboundMessage in project nia-patient-switching-standard-adaptor by NHSDigital.

the class AcknowledgmentMessageHandlerTest method handleMessageWithNackTypeCode.

@Test
public void handleMessageWithNackTypeCode() throws SAXException {
    inboundMessage = new InboundMessage();
    prepareXPathServiceMocks(NACK_TYPE_CODE);
    acknowledgmentMessageHandler.handleMessage(inboundMessage, CONVERSATION_ID);
    verify(migrationStatusLogService).addMigrationStatusLog(EHR_EXTRACT_REQUEST_NEGATIVE_ACK, CONVERSATION_ID);
}
Also used : InboundMessage(uk.nhs.adaptors.pss.translator.mhs.model.InboundMessage) Test(org.junit.jupiter.api.Test)

Example 10 with InboundMessage

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_ShouldUploadFile.

@Test
public void When_CIDFragmentPartIsReceivedBeforeFragmentIndex_Expect_ShouldUploadFile() throws JAXBException, InlineAttachmentProcessingException, SkeletonEhrProcessingException, SAXException, AttachmentLogException, AttachmentNotFoundException, BundleMappingException, JsonProcessingException {
    InboundMessage message = new InboundMessage();
    prepareFragmentMocks(message);
    when(patientAttachmentLogService.findAttachmentLog(MESSAGE_ID, 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));
    // ACT
    copcMessageHandler.handleMessage(message, CONVERSATION_ID);
    // Assert
    verify(attachmentHandlerService).storeAttachementWithoutProcessing(anyString(), anyString(), anyString(), anyString());
}
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