use of uk.nhs.adaptors.connector.model.PatientMigrationRequest 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.connector.model.PatientMigrationRequest in project nia-patient-switching-standard-adaptor by NHSDigital.
the class EhrExtractMessageHandlerTest method prepareMigrationRequestAndMigrationStatusMocks.
@SneakyThrows
private void prepareMigrationRequestAndMigrationStatusMocks() {
PatientMigrationRequest migrationRequest = PatientMigrationRequest.builder().losingPracticeOdsCode(LOSING_ODE_CODE).winningPracticeOdsCode(WINNING_ODE_CODE).build();
MigrationStatusLog migrationStatusLog = MigrationStatusLog.builder().date(OffsetDateTime.ofInstant(Instant.now(), ZoneId.systemDefault())).build();
when(migrationRequestDao.getMigrationRequest(CONVERSATION_ID)).thenReturn(migrationRequest);
when(migrationStatusLogService.getLatestMigrationStatusLog(CONVERSATION_ID)).thenReturn(migrationStatusLog);
}
use of uk.nhs.adaptors.connector.model.PatientMigrationRequest in project nia-patient-switching-standard-adaptor by NHSDigital.
the class EhrExtractMessageHandlerTest method When_HandleMessage_WithMapToBundleThrows_Expect_BundleMappingException.
@Test
public void When_HandleMessage_WithMapToBundleThrows_Expect_BundleMappingException() throws BundleMappingException, AttachmentNotFoundException, ValidationException, InlineAttachmentProcessingException {
InboundMessage inboundMessage = new InboundMessage();
inboundMessage.setPayload(readInboundMessagePayloadFromFile());
inboundMessage.setExternalAttachments(new ArrayList<>());
PatientMigrationRequest migrationRequest = PatientMigrationRequest.builder().losingPracticeOdsCode(LOSING_ODE_CODE).winningPracticeOdsCode(WINNING_ODE_CODE).build();
when(migrationRequestDao.getMigrationRequest(CONVERSATION_ID)).thenReturn(migrationRequest);
when(attachmentReferenceUpdaterService.updateReferenceToAttachment(inboundMessage.getAttachments(), CONVERSATION_ID, inboundMessage.getPayload())).thenReturn(inboundMessage.getPayload());
doThrow(new BundleMappingException("Test Exception")).when(bundleMapperService).mapToBundle(any(RCMRIN030000UK06Message.class), any());
assertThrows(BundleMappingException.class, () -> ehrExtractMessageHandler.handleMessage(inboundMessage, CONVERSATION_ID));
}
use of uk.nhs.adaptors.connector.model.PatientMigrationRequest in project nia-patient-switching-standard-adaptor by NHSDigital.
the class EHRTimeoutHandlerTest method When_CheckForTimeouts_WithSdsRetrievalException_Expect_MigrationLogNotUpdated.
@Test
public void When_CheckForTimeouts_WithSdsRetrievalException_Expect_MigrationLogNotUpdated() {
List<PatientMigrationRequest> requests = List.of(mockRequest);
when(migrationRequestService.getMigrationRequestByCurrentMigrationStatus(EHR_EXTRACT_TRANSLATED)).thenReturn(requests);
when(persistDurationService.getPersistDurationFor(any(), eq(EHR_EXTRACT_MESSAGE_NAME))).thenThrow(new SdsRetrievalException("Test exception"));
ehrTimeoutHandler.checkForTimeouts();
verify(migrationStatusLogService, times(0)).addMigrationStatusLog(any(), any());
}
use of uk.nhs.adaptors.connector.model.PatientMigrationRequest in project nia-patient-switching-standard-adaptor by NHSDigital.
the class PatientTransferService method getBundleResource.
public String getBundleResource() {
var conversationId = mdcService.getConversationId();
PatientMigrationRequest patientMigrationRequest = patientMigrationRequestDao.getMigrationRequest(conversationId);
return patientMigrationRequest.getBundleResource();
}
Aggregations